问题描述
使用Boal进行工作,该Bot使用ADAL(AuthBot)进行身份验证,然后通过Post-Auth获得用户输入并发送到LUIS以收集意图/实体.我使用返回的内容来构建发送到Sharepoint Online REST API的URI.如果用户输入有效,Sharepoint将返回我解析的JSON并返回给用户.
Working on a Bot that authenticates using ADAL (AuthBot) and then post-Auth takes the user input and sends to LUIS to gather intents/entities. I use what's returned to build a URI that I send to Sharepoint Online REST API. If user input is valid, Sharepoint returns JSON that I parse and return to user.
麻烦的是在身份验证后让用户输入我的LUIS类.我从我的MessageController调用AuthBot ActionDialog.
The trouble is getting the user input to my LUIS class after authentication. I call AuthBot ActionDialog from my MessageController.
if (message.Type == "Message")
{
return await Conversation.SendAsync(message, () => new ActionDialog());
}
在ActionDialog中,我不确定如何将消息移动到LUIS类
Within ActionDialog, I'm not sure how to move move the Message to the LUIS Class
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类是标准的,看起来像这样:
The LUIS Class is standard and looks like this:
//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>
有什么想法吗?谢谢.
Any Ideas? Thanks.
推荐答案
我假设您正在使用 AuthBot (通过查看代码).
I assume that you are using AuthBot (by looking at the code).
您需要添加以下内容:
await base.MessageReceived(context, item);
这只会将消息传递给LUISDialog的MessageReceived实现;它将向LUIS发出查询,以了解应执行哪个意图.
That will just pass the message to LUISDialog's MessageReceived implementation; which will issue a query to LUIS to understand which intent should be executed.
这篇关于在MessageController外部和身份验证之后调用LUIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!