LUIS conflict with Messenger's Location quick reply

一曲冷凌霜 提交于 2019-11-28 10:44:06

问题


How can I fix this LUIS producing an error when receiving a location from a user. Right now I am putting the messenger quick reply in a attachment-prompt.

Is the result from the user location an attachment? What is it? Because otherwise my attachment-prompt will do re-prompt loop.

Messenger location quick reply:

Result:

This is the exception:

System.ArgumentNullException: Value cannot be null. Parameter name: utterance at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.d*23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.d*10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.BotBuilderSamples.BasicBot.d*24.MoveNext() in C:\Users\bguevarra\Desktop\finko\FinkoBot\Bots\BasicBot.cs:line 104 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Builder.MiddlewareSet.d*3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Builder.BotAdapter.d__13.MoveNext()

My code:

 private static async Task<DialogTurnResult> SecondStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken))
        {
                Activity reply = stepContext.Context.Activity.CreateReply();

                reply.ChannelData = JObject.FromObject(
                new
                {
                    text = "loc",
                    quick_replies = new object[]
                    {
                        new
                        {
                            content_type = "text",
                            title = "Title",
                            payload = "PEYLOD",
                        },
                        new
                        {
                            content_type = "location",
                        },
                    },
                });

                return await stepContext.PromptAsync(
                   ATTACHPROMPT,
                   new PromptOptions
                   {
                       Prompt = reply,
                      // RetryPrompt = MessageFactory.Text("re prompting."),
                   });
        }        

private static async Task<DialogTurnResult> ThirdStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken))
        {
            await stepContext.Context.SendActivityAsync(MessageFactory.Text($"TEST")); // Not even reaching this next step

            var activity = stepContext.Context.Activity;
            var location = activity.Entities?.FirstOrDefault(e => e.Type == "Place");
            if (location != null)
            {
                var latitude = location.Properties["geo"]?["latitude"]?.ToString();
                var longitude = location.Properties["geo"]?["longitude"]?.ToString();

                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"{latitude} + {longitude} "));
            }

            return await stepContext.EndDialogAsync();
        }

来源:https://stackoverflow.com/questions/55356005/luis-conflict-with-messengers-location-quick-reply

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!