无法在Azure机器人框架中调用Luis

时间:2019-10-24 11:53:32

标签: azure .net-core botframework luis

enter image description here我是dotnet以及Luis和bot框架的菜鸟。

我正在尝试通过

在我的计算机上运行一些机器人样本。

https://github.com/microsoft/BotBuilder-Samples

我对此特别感兴趣

https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/13.core-bot

当我运行机器人时,它无法连接到Luis(请参阅下面的错误消息)。

  • 我通过导入应用程序中提供的意图在Luis中创建并发布了一个应用程序。
  • 我在正确的JSON文件中编写了LuisAppId,LuisAPIKey和LuisAPIHostName(请参见下文)。
  • 我将dotnet库添加到了项目中:dotnet添加了Cognitive.LUIS.Programmatic包

然后,我只需在正确的文件夹中使用cmd "dotnet run"运行代码。

此处是 app.setting JSON。我将subscription-key用作LuisAPIKey,将应用程序ID用作LuisAppId。

{
  "MicrosoftAppId": "",
  "MicrosoftAppPassword": "",
  "LuisAppId": "2aa2b9c5-#######################7b557",
  "LuisAPIKey": "1069d###############4347da9",
  "LuisAPIHostName": "westus.api.cognitive.microsoft.com/luis/api/v2.0"
}

机器人正在我的本地主机上运行。但这是行不通的。

  

bot:今天有什么可以帮助您的?说出类似“   2020年3月22日从巴黎飞往柏林的航班”

     

我:“请预订2020年3月22日从巴黎飞往柏林的航班”

     

机器人:“机器人遇到错误或错误。”

     

机器人:“要继续运行该机器人,请修复该机器人的源代码”


On the cmd line : 
"fail: Microsoft.Bot.Builder.Integration.AspNet.Core.BotFrameworkHttpAdapter[0]
      [OnTurnError] unhandled error : Operation returned an invalid status code 'NotFound'
Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models.APIErrorException: Operation returned an invalid status code 'NotFound'
   at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Prediction.ResolveWithHttpMessagesAsync(String appId, String query, Nullable`1 timezoneOffset, Nullable`1 verbose, Nullable`1 staging, Nullable`1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable`1 log, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.PredictionExtensions.ResolveAsync(IPrediction operations, String appId, String query, Nullable`1 timezoneOffset, Nullable`1 verbose, Nullable`1 staging, Nullable`1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable`1 log, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeInternalAsync(ITurnContext turnContext, LuisPredictionOptions predictionOptions, Dictionary`2 telemetryProperties, Dictionary`2 telemetryMetrics, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS\LuisRecognizer.cs:line 345
   at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeAsync[T](ITurnContext turnContext, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS\LuisRecognizer.cs:line 163
   at Microsoft.BotBuilderSamples.FlightBookingRecognizer.RecognizeAsync[T](ITurnContext turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\FlightBookingRecognizer.cs:line 38
   at Microsoft.BotBuilderSamples.Dialogs.MainDialog.ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Dialogs\MainDialog.cs:line 67
   at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.OnStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 166
   at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.RunStepAsync(DialogContext dc, Int32 index, DialogReason reason, Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 188
   at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.ResumeDialogAsync(DialogContext dc, DialogReason reason, Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 113
   at Microsoft.Bot.Builder.Dialogs.DialogContext.EndDialogAsync(Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 196
   at Microsoft.Bot.Builder.Dialogs.Prompt`1.ContinueDialogAsync(DialogContext dc, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\Prompt.cs:line 147
   at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
   at Microsoft.Bot.Builder.Dialogs.ComponentDialog.ContinueDialogAsync(DialogContext outerDc, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\ComponentDialog.cs:line 84
   at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
   at Microsoft.Bot.Builder.Dialogs.DialogExtensions.RunAsync(Dialog dialog, ITurnContext turnContext, IStatePropertyAccessor`1 accessor, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogExtensions.cs:line 18
   at Microsoft.BotBuilderSamples.Bots.DialogBot`1.OnMessageActivityAsync(ITurnContext`1 turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Bots\DialogBot.cs:line 48
   at Microsoft.BotBuilderSamples.Bots.DialogBot`1.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Bots\DialogBot.cs:line 36
   at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotFrameworkAdapter.cs:line 995
   at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\MiddlewareSet.cs:line 55
   at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotAdapter.cs:line 167"

如前所述,我是新手,因此,对以上内容的任何见解将不胜感激!

1 个答案:

答案 0 :(得分:4)

问题出在您的 --add Microsoft.Net.ComponentGroup.TargetingPacks.Common中。您只需要 --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Workload.VCTools。如果这不起作用,请尝试 --add Microsoft.VisualStudio.Workload.MSBuildTools。该示例经常更改,一旦LUIS发布其新的API端点,我们计划在所有示例和文档中对其进行标准化。

Here's the instructions in the Sample README

Here's a Pull Request noting how common this issue is

编辑:正如下面提到的@vikasramereddi一样,您还需要确保将LUIS应用发布到Production而不是Staging。