Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

c# - LUIS conflict with Messenger's Location quick reply

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:

enter image description here

Result:

enter image description here

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:UsersguevarraDesktopfinkoFinkoBotBotsBasicBot.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();
        }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...