重新创建根对话框的会话

Recreate session of root dialog

我正在使用 Microsoft Bot 框架构建 Messenger 机器人。

我添加了菜单,我想这样处理菜单:

if (activity.Text == "item1_postback" || activity.Text == "item2_postback")
{
  await Conversation.SendAsync(activity, () => new MenuDialog());

}
else
{
  await Conversation.SendAsync(activity, () => new RootLuisDialog());
}

item1_postback 和 item2_postback 是菜单中的按钮。

在 MenuDialog 中我有函数。 当 MenuDialog 中的所有内容都完成后,我想 "restore" 根对话框并从 RootLuisDialog 重新创建根对话框。

我试过 context.Done 和 context.Reset,但它不起作用。

知道在 MenuDialog 完成后如何重置根对话框吗?

在您的消息端点中,只调用您的根对话框

await Conversation.SendAsync(activity, () => new RootLuisDialog());

在您的 RootLuisDialog 中,添加 [RegexPattern("^item1_postback")] 个动作检测器以处理 post 个后退。

在这些操作中,通过调用

启动菜单子对话框

context.Call(new MenuDialog(), (context, result) => { /*Do something. at this point your are back to the parent dialog.*/});

在您的 MenuDialog 完成后(这意味着您应该在某处调用 done(some_result) 您将返回父对话框 RootLuisDialog 并继续处理新的用户命令。