在提示用户提及缺少的实体后,我如何使用 luis 操作绑定来触发意图

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

此 post 与 C#(.Net) 中的机器人框架相关

所以我想知道如果我对用户的预期话语是:

"show me the projects starting on 3rd march"

但用户错过了日期实体并写入

"show me the projects starting on"

现在我想提示用户输入日期(这是缺少的实体),请注明日期。

然后简单地 运行 现在的意图。

推进它的最佳方法是什么?

Which is the best approach to take it forward ?

  • 创建一个处理意图的方法(方法 1)和另一个用于应该在(方法 2)之后完成的业务案例
  • 在方法 1 中,检查您可能丢失的数据。如果none,调用方法2,否则调用一个方法(方法3)来获取缺失值,并在这个方法3的恢复中当你有你的值时调用方法2

Nicolas R的回复中分享了实现你的要求的思路和方法,你可以参考一下。

此外,您可以参考下面的示例代码,提示提供达到特定意图和缺少所需实体的日期。

[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);
    }
}

测试结果: