Search code examples
c#botframeworkazure-language-understanding

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


I am running botframework v4 code and testing it using chatbot emulator . Curently i am unable to reach the code flow where the luis intent code is present in [MainDialog.cs][1] .

Below is the line in MainDialog.cs file:

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

But ,when i enter some message in ChatBot ,every time flow ends at [FlightBookingRecognizer.cs][2] and below is the line where i am expecting luis intent to be 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 has the message which we enter in chatbot. And i am expecting the LUIS result in _recognizer.RecognizeAsync ,but there is no relevant data in this . I am trying to do something like below:-



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\13.core-bot\appsettings.json file).
In Luis you can import this file csharp_dotnetcore\13.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.sstatic.net/05Rbg.png
  [4]: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/13.core-bot
  [5]: https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-luis?view=azure-bot-service-4.0&tabs=csharp

Solution

  • This issue is resolved now.I am able to get the intent from Luis. When i used Luis host which is configured in appsettings.json in format https://xxxx.xxxx.xxxx I was not getting Luis Intent,but after removing https:// ,i am getting the result now. Thanks everybody for your efforts.