LUIS与Messenger的位置快速回复

时间:2019-03-26 11:25:45

标签: c# botframework luis messenger

从用户那里收到位置信息后,如何解决此LUIS产生错误的问题。现在,我会将Messenger的快速回复放入附件提示中。

用户位置的结果是否为附件?它是什么?因为否则我的附件提示将重新提示循环。

信使位置快速回复:

enter image description here

结果:

enter image description here

这是例外:

  

System.ArgumentNullException:值不能为null。参数名称:Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.d * 23.MoveNext()处的讲话---从上次引发异常的位置开始的堆栈跟踪---在System.Runtime.ExceptionServices.ExceptionDispatchInfo处。 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.d * 10.MoveNext( )-从先前抛出异常的位置开始的堆栈跟踪--在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)在System.Runtime.CompilerServices的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.BotBuilderSamples.BasicBot.d * 24.MoveNext()中的.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务),位于C:\ Users \ bguevarra \ Desktop \ finko \ FinkoBot \ Bots \ BasicBot.cs:第104行---堆栈结束从先前引发异常的位置跟踪---在Sys System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的tem.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的Microsoft.Bot.Builder.MiddlewareSetd 3.MoveNext()-从上一个引发异常的位置开始的堆栈跟踪--在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.Bot.Builder.BotAdapter.d__13.MoveNext()上的.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

我的代码:

 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();
        }

0 个答案:

没有答案