Botframework 从保存的对话启动FormDialog
这在某种程度上建立在主动式用例示例的基础上,我有一个简单的用例:Botframework 从保存的对话启动FormDialog,botframework,Botframework,这在某种程度上建立在主动式用例示例的基础上,我有一个简单的用例: 当用户启动与bot的对话时,bot保存活动对象 存在API终结点 当api端点被触发时 将检索活动对象,从与到交换,并通过SendToConversationAsync将消息发送回用户 是否可以通过检索或重新创建IDialoge对象来启动FormDialog,而不仅仅是将活动消息重播给用户,以便使用适当的表单触发context.Call 我尝试过使用各种各样的东西,但在用户端什么也没有出现;具体来说,我试过了 await Conv
await Conversation.SendAsync(message, () => new MakeSomeFormDialog());
及
而互动的例子——
Task Interactive(IDialog form) where T : class
然而,我认为这是一个互动的例子,但我认为这是试图发布到bot?结果是相当直接的。我向销售代表寻求帮助,他们为我指明了正确的方向 下面是涵盖此案例的主动式bot示例 特别是这段代码 公共课堂会话发起者 { //注意:当然你不想在这里看到它。最终你需要将它保存在某个表中 //将此作为静态变量表示我们只能记住一个用户:) 公共静态字符串恢复cookie
//This will interrupt the conversation and send the user to SurveyDialog, then wait until that's done
public static async Task Resume()
{
var message = ResumptionCookie.GZipDeserialize(resumptionCookie).GetMessage();
var client = new ConnectorClient(new Uri(message.ServiceUrl));
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(CancellationToken.None);
var stack = scope.Resolve<IDialogStack>();
//interrupt the stack
var dialog =new SurveyDialog();
stack.Call(dialog.Void<object, IMessageActivity>(), null);
await stack.PollAsync(CancellationToken.None);
//flush dialog stack
await botData.FlushAsync(CancellationToken.None);
}
}
}
//这将中断对话并将用户发送到SurveyDialog,然后等待完成
公共静态异步任务恢复()
{
var message=ResumptionCookie.gzip反序列化(ResumptionCookie.GetMessage();
var client=newconnectorclient(新Uri(message.ServiceUrl));
使用(var scope=DialogModule.BeginLifetimeScope(Conversation.Container,message))
{
var botData=scope.Resolve();
等待botData.LoadAsync(CancellationToken.None);
var stack=scope.Resolve();
//中断堆栈
var对话框=新建SurveyDialog();
调用(dialog.Void(),null);
wait stack.PollAsync(CancellationToken.None);
//刷新对话框堆栈
等待botData.FlushAsync(CancellationToken.None);
}
}
}
返回上下文并用另一个对话框(可以是表单对话框)中断。是的,这应该是可能的。你有更具体的问题吗?更新了问题-谢谢。
//This will interrupt the conversation and send the user to SurveyDialog, then wait until that's done
public static async Task Resume()
{
var message = ResumptionCookie.GZipDeserialize(resumptionCookie).GetMessage();
var client = new ConnectorClient(new Uri(message.ServiceUrl));
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(CancellationToken.None);
var stack = scope.Resolve<IDialogStack>();
//interrupt the stack
var dialog =new SurveyDialog();
stack.Call(dialog.Void<object, IMessageActivity>(), null);
await stack.PollAsync(CancellationToken.None);
//flush dialog stack
await botData.FlushAsync(CancellationToken.None);
}
}
}