I am trying to build a bot using LUIS but it is a lot harder than I thought. So far I have managed to create my LUIS application and create an Intent and an Entity and I have created a few Utterances that seem to work fine.
I then created my bot and have hooked it up to Luis. When I test my bot it is working as expected. Now, for the fun part. I want to handle parameters. On Luis I added an action to my Intent:
As you can see I have added a prompt. 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 am going with this. If the user types Help me buy a camera, it will get to Choose category Intent and will have the correct Entity selected. But if they type Help me buy, it will still go to the correct Intent, but it will not have a selected Entity. I would like my bot to see that and use the text in the Prompt I created in LUIS and when the user selects their entity I want it to go back to LUIS with that parameter.
I have no idea how to do this and I can't find any tutorials on this. Any help would be appreciated (even links!)