【发布时间】:2019-08-07 01:00:06
【问题描述】:
我在 bot 框架 v4 上找不到任何文档,类似于 bot v3 中关于调用对话和通过外部 API 操作对话框堆栈的以下实现:
这就是 bot v3 中的代码的样子
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, messageToBot))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(CancellationToken.None);
//This is our dialog stack
var task = scope.Resolve<IDialogTask>();
//interrupt the stack.This means that we're stopping whatever conversation that is currently happening with the user
//Then adding this stack to run and once it's finished, we will be back to the original conversation
var dialog = new LoginCompletedDialog();
var interruption = dialog.Void<object, IMessageActivity>();
task.Call(interruption, null);
await task.Forward(interruption, null, null);
await task.PollAsync(CancellationToken.None);
//flush dialog stack
await botData.FlushAsync(CancellationToken.None);
}
谁能告诉我如何在 bot framework v4 中实现这个功能?
【问题讨论】:
-
您的代码对我来说有点奇怪,即使对于 v3。您能否分享您的代码所基于的任何示例或文档,并详细说明它应该做什么?这里的上下文是什么?该代码在哪个文件中?
-
该代码中断了机器人当前的对话,它可以在对话框堆栈顶部添加对话框。这用于使用 autofac 进行主动消息传递
-
我的回答可以接受吗?
标签: c# botframework bots