Microsoft Bot Framework, LUIS and action options

I am trying to create a bot using LUIS, but it is much more complicated than I thought. So far, I have managed to create my LUIS application and create Intent and Entity , and I have created several expressions that seem to work fine.

Then I created my bot and connected it to Louis. When I test my bot, it works as expected. Now, for the fun part. I want to handle the parameters. On Luis, I added an action for my intention :

enter image description here

As you can see, I added an invitation. My code in my bot currently looks like this:

/// <summary> /// Tries to find the category /// </summary> /// <param name="result">The Luis result</param> /// <param name="alarm"></param> /// <returns></returns> public string TryFindCategory(LuisResult result) { // Variable for the title EntityRecommendation title; // If we find our enenty, return it if (result.TryFindEntity(PiiiCK.Category, out title)) return title.Entity; // Default fallback return null; } [LuisIntent("Choose category")] public async Task ChooseCategory(IDialogContext context, LuisResult result) { // Get our category var category = TryFindCategory(result); var response = "The category you have chosen is not in the system just yet."; switch (category) { case "camera": response = $"You need help buying a { category }, is this correct?"; this.started = true; break; default: if (!string.IsNullOrEmpty(category)) response = $"Sorry, PiiiCK does not deal with { category.Pluralise() } just yet."; break; } // Post our response back to the user await context.PostAsync(response); // Execute the message recieved delegate context.Wait(MessageReceived); } 

I think you can guess where I'm going. If the user types Help me buy a camera , he will receive the value Select category and the correct Entity will be selected. But if they type Help me buy , it still comes up with the right intention, but it will not have a dedicated Entity . I want my bot to see this and use the text in Prompt , which I created in LUIS, and when the user selects his object , I want him to return to LUIS with this parameter.

I donโ€™t know how to do this, and I canโ€™t find any tutorials on this. Any help would be appreciated (even links!)

+5
source share
1 answer

First of all, you need to make sure that in your statements containing categories, you designate them as a Category object. This is done by simply selecting the words / words that represent your entity, and then clicking on the actual category before sending your statement.

Statement Designation

Regardless of the action options you added. To check the action parameters, you need to go through the actual intention. IntentRecommendation has an Actions property; which contains the Parameters property.

Action options

Something to add here is that in the develop branch the BotFramework team just added support for the LUIS v2 API and added some new cabability.

For example, now LuisDialog will act if your intention requires parameters, and they are not provided. In this scenario (which seems yours), LuisDialog will automatically launch LuisActionDialog and ask the user to specify the missing parameter using the Prompt message that you defined in the action parameter.

Please note that this is not yet published as a Nuget package.

+1
source

Source: https://habr.com/ru/post/1259733/


All Articles