如何在Microsoft Bot Framework

时间:2016-05-15 20:35:18

标签: c# botframework

我正在使用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错误。

2 个答案:

答案 0 :(得分:2)

尝试以下列方式实例化客户端

String PUBLIC_KEY_STRING = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxl4aRnRMBB9GZk";
byte[] bytes = DatatypeConverter.parseBase64Binary(PUBLIC_KEY_STRING);
System.out.println(Arrays.toString(bytes));

答案 1 :(得分:0)

一旦异步任务获得结果,您应该能够使用ConnectorClient向传入消息发送响应

Here's指向文档的链接