我正在使用Microsoft Bot Framework FormFlow来吸引用户填写表单。完成此操作后,Dialog结束,并执行为ResumeWith
参数指定的方法(在本例中为quoteComplete
):
var quoteForm = new FormDialog<Quote>(new Quote(),
quoteFormBuilder.BuildForm, FormOptions.PromptInStart);
context.Call<Quote>(quoteForm, quoteComplete);
在此,quoteComplete
我希望机器人告诉用户它正在获取报价,这可能需要几秒钟。然后执行一个异步调用来执行报价,并且在返回时,我希望机器人显示另一条带有报价值的消息:
await context.PostAsync("I will now calculate your quote. I won't be long...");
context.Wait(MessageReceived);
//Simulate getting the quote
Task.Delay(5000).ContinueWith(t =>
{
context.PostAsync("Your quote is £133.54");
});
我还尝试通过以下文档中的以下建议来发送多个答复Delay().ContinueWith
:
var message = context.MakeMessage();
message.Text = "Your quote is for £133.54";
var connector = new ConnectorClient();
connector.Messages.SendMessage(message);
但是我得到一个Access Denied
错误。
尝试通过以下方式实例化客户端
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var client = scope.Resolve<IConnectorClient>();
client.Messages.SendMessage(message);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句