使用 Bot Framework v4 代码时无法映射 LUIS 意图

Unable to map LUIS intent while using the Bot Framework v4 code

我是 运行 botframework v4 代码并使用聊天机器人模拟器对其进行测试。目前我无法到达 [MainDialog.cs][1] 中存在 luis 意图代码的代码流。

下面是 MainDialog.cs 文件中的行:

 var luisResult = await _luisRecognizer.RecognizeAsync<FlightBooking>(stepContext.Context, cancellationToken);

但是,当我在 ChatBot 中输入一些消息时,每次流程都在 [FlightBookingRecognizer.cs][2] 处结束,下面是我期望 luis 意图 matched/fetched 的行。

public virtual async Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
    => await _recognizer.RecognizeAsync(turnContext, cancellationToken);

public virtual async Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
     where T : IRecognizerConvert, new()
    => await _recognizer.RecognizeAsync<T>(turnContext, cancellationToken);

turnContext 包含我们在聊天机器人中输入的消息。 我期待 LUIS 结果为 _recognizer.RecognizeAsync,但此中没有相关数据。 我正在尝试执行以下操作:-



But, my code flow ends here and i get error in ChatBot emulator as attached in screenshot.[![enter image description here][3]][3]


Steps to reproduce:
1. Download or pull the project from github and then Open the CoreBot.csproj  in Visual studio from this link .
[CoreBot Project][4]

2. Then select CoreBot and build it (Don't forget to add luis app id,key and host in csharp_dotnetcore.core-bot\appsettings.json file).
In Luis you can import this file csharp_dotnetcore.core-bot\CognitiveModels\FlightBooking.json and then train and publish it.
In Luis.ai go to My apps, and click Import App. Choose the file JSON file for the app you want to import and click Import.

3. Also put debug breakpoints in MainDialog.cs class (line 67 jus before switch statement) and FlightBookingRecognizer.cs class (last 2 lines ) .

4.Run the project in IIS browser mode and not in console mode ,it will open in browser you will see this link  http://localhost:3978/ 

5. In chatbot Emulator open this link http://localhost:3979/api/messages

6. You will see cards in chatbot as per attached screenshot.

7. Enter a message which is given in chatbot example i.e "Flight to paris"

8. You will see debug point ends at FlightRecognizer.cs class last line and turnContext has your message but _recognizer.RecognizeAsync doesn't carry any information about the Luis intent .

9.Also,it is not clear that LUIS intent is matched from local file or luis.ai 


More info can be found here [Microsoft documentation about this v4 code][5]
Please Help.


  [1]: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/13.core-bot/Dialogs/MainDialog.cs
  [2]: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/13.core-bot/FlightBookingRecognizer.cs
  [3]: https://i.stack.imgur.com/05Rbg.png
  [4]: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/13.core-bot
  [5]: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-luis?view=azure-bot-service-4.0&tabs=csharp

V4 MessageController 应该很少(如果有的话)改变骨架。在这一行中:

await _adapter.ProcessAsync(Request, response, _bot);

...您可以看到控制器将 Request 传递给了 _bot。使用您的机器人来处理对话。

the CoreBot sample, you can see that after the message hits the BotController (which is equivalent to MessageController, it goes to DialogBot 中调用对话框的地方:

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
    Logger.LogInformation("Running dialog with Message Activity.");

    // Run the Dialog with the new message Activity.
    await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
}

它 "knows" 这样做,因为在 Startup.cs 中,它使用依赖注入来添加机器人和对话框,以便 BotControllerDialogBot 可以使用他们分别是:

services.AddTransient<IBot, DialogAndWelcomeBot<MainDialog>>();

在迁移之前,我强烈、强烈建议设置 CoreBot 并通读它,直到您了解它的工作原理。它可能会对以后的迁移问题有所帮助。

此问题已解决 now.I 我能够从 Luis 那里得到意图。 当我使用以 appsettings.json 格式配置的 Luis 主机时 https://xxxx.xxxx.xxxx 我没有得到 Luis Intent,但是在删除 https:// 之后,我现在得到了结果。 感谢大家的努力。