【问题标题】:Track if LUIS intent has already been triggered跟踪是否已触发 LUIS 意图
【发布时间】:2018-05-10 17:56:54
【问题描述】:

如何跟踪 LUIS 意图是否已被触发??
使用渠道:Facebook

场景
用户 : 奥迪 TT 详情
机器人:[汽车详情....]
网友:谢谢
Bot:您希望我们与您联系吗? (提供是或否提示)
用户:[选择选项(是或否)]...
下次同一用户聊天...或稍后在同一对话中
网友:你们有奥迪TT的零件吗?
机器人:是的,我们有以下可用部件
用户:非常感谢!
机器人:很高兴提供帮助 -> 机器人不能提供 “您希望我们与您联系吗?” 再次提示

我正在使用 LUIS 意图来检测用户是否在说“谢谢”,然后触发提示。如何跟踪意图是否已被触发

[LuisIntent ("Gratitude")]  
public async Task Gratitude(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)  
{               
    if( intent_has_not_been_triggered_for_user)
       PromptDialog.Choice(context,
             ResumeAfterGratitude,
             new[] { "Yes", "No"},
             "Thank you. Would you like us to contact you?",
             promptStyle: PromptStyle.Keyboard, attempts: 4
           );

   else  
      await context.PostAsync("Glad to help");  
}

【问题讨论】:

    标签: c# botframework azure-language-understanding qnamaker


    【解决方案1】:

    您可以使用context.UserData 来存储与用户关联的数据。

    在您的情况下,您可以设置值以防UserData 中不存在该值,方法是使用诸如GratitudeTriggered 之类的键,并且每次检查用户数据中是否存在该键。您还可以根据需要自定义逻辑,例如匹配特定值、值的存在等。

    示例代码:

    [LuisIntent("Gratitude")]
    public async Task Gratitude(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
    {
        if (context.UserData.TryGetValue("GratitudeTriggered", out bool gratitudeTriggered))
        {
            //Triggered for the first time, store it in UserData that the Gratitude is triggered
            context.UserData.SetValue("GratitudeTriggered", "yes");
    
            PromptDialog.Choice(context,
                  ResumeAfterGratitude,
                  new[] { "Yes", "No" },
                  "Thank you. Would you like us to contact you?",
                  promptStyle: PromptStyle.Keyboard, attempts: 4
                );
        }
        else
            await context.PostAsync("Glad to help");
    }
    

    【讨论】:

      猜你喜欢
      • 2018-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-07
      • 1970-01-01
      • 2012-03-07
      • 2016-04-30
      • 2013-08-17
      相关资源
      最近更新 更多