Shivain Mattoo
Shivain Mattoo

Reputation: 39

how can i use luis action binding to trigger an intent after prompting the user for mentioning missing entities

This post is in context to bot framework in C#(.Net)

so i wanted to know that if my expected utterance from the user is:

"show me the projects starting on 3rd march"

but the user misses the date entity and writes

"show me the projects starting on"

now i want to prompt the user for the date(which is the missing entity) that please mention the date.

and then simply run the intent now.

Which is the best approach to take it forward ?

Upvotes: 1

Views: 401

Answers (2)

Fei Han
Fei Han

Reputation: 27805

In Nicolas R’s reply, he has shared idea and approach to achieve your requirement, you can refer to it.

Besides, you can refer to the following sample code to prompt for providing the date when the specific intent is reached and required entity is missing.

[Serializable]
public class BasicLuisDialog : LuisDialog<object>
{

    string bdate;
    public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute(
        "{ID_here}",
        "{subscriptionKey_here}", 
        domain: "westus.api.cognitive.microsoft.com")))
    {
    }

    //....
    //for other intents

    [LuisIntent("GetProjectInfo")]
    public async Task GetProjectInfoIntent(IDialogContext context, LuisResult result) 
    {

        if (result.Entities.Count == 0)
        {
            PromptDialog.Text(
            context: context,
            resume: ResumeGetDate,
            prompt: "Please enter the date",
            retry: "Please try again.");
        }
        else
        {
            await this.ShowLuisResult(context, result);
        }


    }

    public async Task ResumeGetDate(IDialogContext context, IAwaitable<string> mes)
    {
        bdate = await mes;

        await context.PostAsync($"You reached GetProjectInfo intent. And you entered the date: {bdate}");

        context.Wait(MessageReceived);
    }


    private async Task ShowLuisResult(IDialogContext context, LuisResult result) 
    {
        await context.PostAsync($"You have reached {result.Intents[0].Intent}. You said: {result.Query}");
        context.Wait(MessageReceived);
    }
}

Test result:

enter image description here

Upvotes: 3

Nicolas R
Nicolas R

Reputation: 14619

Which is the best approach to take it forward ?

  • Create a method that handles the intent (method1) and another for the business case that should be done after (method2)
  • In method1, check for your possible missing data. If none, call method2, else call a method (method3) to get the missing values, and in the resume of this method3 call method2 when you have your values

Upvotes: 2

Related Questions