How to call LUIS Dialog inside LUIS Dialog?

假装没事ソ 提交于 2019-12-04 04:35:12

You could repeat the logic that is on the MessegaReceived of the LUIS dialog, to achieve what you want to do. Basically, this code should be pretty aligned to what you need:

var tasks = this.services.Select(s => s.QueryAsync(messageHandled, CancellationToken.None)).ToArray();
var winner = this.BestResultFrom(await Task.WhenAll(tasks));

IntentActivityHandler handler = null;
if (winner == null || !this.handlerByIntent.TryGetValue(winner.BestIntent.Intent, out handler))
{
    handler = this.handlerByIntent[string.Empty];
}

if (handler != null)
{
    await handler(context, null, winner?.Result);
}

The pieces of the code that are referring to things with "this" are part of the LUIS Dialog you are inherited from.

  • services, are the collection of LuisServices instantiated based on your LuisModel attributes.
  • IntentActivityHandler is the handler that the LuisIntent decorated method are "implementing" with the method signature.
  • handlerbyIntent is a Dictionary with the key being the intent names of your dialog and the handler being the method that needs to be called for that intent.

Check this for more details and make sure you are using the latest version of the BotBuilder SDK (at the moment of this post: v3.2.1)

There's no need to copy logic from MessegaReceived. You can just call MessegaReceived:

private async Task EmailDialogDone(IDialogContext context, IAwaitable<string> argument)
{
   await MessageReceived(context, new AwaitableFromItem<IMessageActivity>((IMessageActivity)context.Activity));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!