【问题标题】:Call LUIS outside of MessageController and after Authentication在 MessageController 之外和身份验证之后调用 LUIS
【发布时间】:2016-10-26 21:28:40
【问题描述】:

处理使用 ADAL (AuthBot) 进行身份验证的 Bot,然后进行身份验证后获取用户输入并发送到 LUIS 以收集意图/实体。我使用返回的内容构建发送到 Sharepoint Online REST API 的 URI。如果用户输入有效,Sharepoint 会返回我解析并返回给用户的 JSON。

问题是在身份验证后将用户输入输入到我的 LUIS 类。我从我的 MessageController 调用 AuthBot ActionDialog。

        if (message.Type == "Message")
        {
            return await Conversation.SendAsync(message, () => new ActionDialog());
        }           

在 ActionDialog 中,我不确定如何将消息移动到 LUIS 类

   public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> item)
    {
        var message = await item;
        if (message.Text == "logon")
        {
            if (string.IsNullOrEmpty(await context.GetAccessToken(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"])))
            {
                await context.Forward(new AzureAuthDialog(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"]), this.ResumeAfterAuth, message, CancellationToken.None);
            }
            else
            {
                context.Wait(MessageReceivedAsync);
            }
        }
        else if (string.IsNullOrEmpty(await context.GetAccessToken(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"])))
        {
            await context.Forward(new AzureAuthDialog(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"]), this.ResumeAfterAuth, message, CancellationToken.None);
        }
        else
        {
            //this is where I want to send the next user input from bot to LUIS class.                
        }
    }    

LUIS 类是标准的,如下所示:

//Define the LuisModel that will be used.  The LuisModel JSON file can be found at ~/json/letseat.json
[LuisModel("ModelID", "ModelSecret")]
[Serializable]
public class LuisDialog : LuisDialog<object>

有什么想法吗?谢谢。

【问题讨论】:

    标签: sharepoint bots botframework azure-language-understanding


    【解决方案1】:

    我假设您使用的是AuthBot(通过查看代码)。

    您需要添加以下内容:

     await base.MessageReceived(context, item);
    

    这只会将消息传递给 LUISDialog 的 MessageReceived 实现;这将向 LUIS 发出查询以了解应执行的意图。

    【讨论】:

    • 感谢埃贾迪布。假设您的意思是将 MessageReceived 行放在我的 LUIS 类中,对吗?
    • @EzequielJadib 那行应该在哪里?在意图方法的开始?还有它是如何工作的?
    • 如果您覆盖了该方法,则在 MessageReceivedAsync 中
    • @EzequielJadib 有没有机会为 Luis 和 ActionDialog 类提供代码示例?这样会更清楚。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-30
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多