我正在使用Microsoft.Bot.Builder.Dialog.Promptoptions类,它接受一个委托和需要的ResumeAfter(IDialogContext context,IAwaitable result)
但是,我要打电话的代表不是 私有异步任务测试(IDialogContext上下文,IAwaitable结果)
而是具有以下
的LUIS代理[LuisIntent( “测试”) 私有异步任务测试(IDialogContext上下文,LuisResult结果)
听到一些关于如何调用LUIS归因方法的想法将非常感激
private async Task ProductChoice(IDialogContext context, IAwaitable<string> result)
{
PromptDialog.Choice<string>(
context,
ProductOverview,
this.productOptions,
"Which plaform are you interested in?",
"Ooops, what you wrote is not a valid option, please try again",
3,
PromptStyle.PerLine);
await context.PostAsync(context.MakeMessage());
}
[LuisIntent ("Products")]
public async Task ProductOverview(IDialogContext context, LuisResult result)
{
string product = "";
EntityRecommendation rec;
Activity activity = (Activity)context.MakeMessage();
Attachment attachment;
if (result.TryFindEntity("ProductName", out rec))
{
//Here you could include other rich cards
attachment = CreateNewHeroCard(product = rec.Entity);
activity.Attachments.Add(attachment);
await context.PostAsync(activity);
}
else
{
await context.PostAsync("Sorry, their is no product by that name");
}
}
答案 0 :(得分:2)
首先,你要做的事情是不可能的。
然后是其他一些事情:
PostAsync
后,您不应发送Prompt
。LUIS
Intent方法中的某些逻辑,则需要将该逻辑提取到LUIS和提示的ResumeAfter方法都可以调用的公共方法中。当然,该常用方法不应该包含与LuisResult
相关的任何内容,因为这在ResumeAfter方法中不可用。当调用ResumeAfter方法时; LUIS不会被召唤。 LUIS
,那么就必须编写更多的代码,但它是可行的ProductOverview
方法,那么您可以将其作为标准方法执行,但是(并且再次),请记住您不会在那里使用LuisResult,所以你必须发送一个空值并在ProductOverview
方法中相应地处理它。类似的东西:
private async Task ProductChoice(IDialogContext context, IAwaitable<string> result)
{
PromptDialog.Choice<string>(
context,
AfterPromptChoiceMethod,
this.productOptions,
"Which plaform are you interested in?",
"Ooops, what you wrote is not a valid option, please try again",
3,
PromptStyle.PerLine);
await context.PostAsync(context.MakeMessage());
}
private async Task AfterPromptChoiceMethod(IDialogContext context, IAwaitable<string> result)
{
await ProductOverview(context, null);
}