6

I am using Microsoft Bot Framework FormFlow to get a user to complete a form. Having completed it that Dialog ends and the method specified for the ResumeWith parameter (in this case quoteComplete) is executed:

var quoteForm = new FormDialog<Quote>(new Quote(), quoteFormBuilder.BuildForm, FormOptions.PromptInStart); context.Call<Quote>(quoteForm, quoteComplete); 

In quoteComplete I want the bot to tell the user that it is getting a quote and that it may takes a few seconds. An async call to perform the quote is then done and on it's return I want the bot to show another message with the value of the quote:

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"); }); 

I also tried following advice in the documentation for sending multiple replies by putting this in the Delay().ContinueWith:

var message = context.MakeMessage(); message.Text = "Your quote is for £133.54"; var connector = new ConnectorClient(); connector.Messages.SendMessage(message); 

However I get an Access Denied error for this.

2
  • Did you ever resolve this? Commented May 19, 2016 at 11:13
  • I'm afraid not - still hoping someone with an answer will chip in! :( Commented May 19, 2016 at 18:16

2 Answers 2

2

Try instantiating the client in the following way

using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message)) { var client = scope.Resolve<IConnectorClient>(); client.Messages.SendMessage(message); } 
Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks for this, but I wonder if you could update your answer with an explanation as to why this is necessary? Otherwise I'm just cut and pasting more SO magic! :)
0

You should be able to use the ConnectorClient to send a response to the incoming message once your async task gets you a result

Here's the link to the documentation

1 Comment

That's what I tried on my second attempt in my OP, but got Access Denied. Is there an easy way to construct the message - it's not obvious how I would use CreateReplyMessage when I am initiating the message.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.