Krumelur Krumelur - 1 year ago 68
C# Question

How to forward result of Prompt.Choice() to current dialog?

I'm using

to present different options to my users. The number of attempts is set to 0, so if they type in anything that is not a valid option, there won't be any retries.

In this case I would like to pass the entered text to the current dialog who has presented to prompt and let it handle the message.

What is the correct way of doing this? I tried creating a new activity in the resume-handler of the prompt dialog and directly call the
method but that a) does not work as expected and b) seems to be a hack.

An example would be a prompt that asks "I'm not sure what you want to do. Show help or keep trying?" with two options "Help" and "Keep trying". However, if the user now enters "what is one plus one?", I'd like the current dialog to handle this.

I could also ask differently: how can I replace the current dialog on top of the stack with another one? This would allow me to just call the same dialog.

Answer Source

I think that calling MessageReceivedAsync will be the way to go here. The key is to pass an IAwaitable from the activity you are creating.

The code should be like:

await MessageReceivedAsync(context, Awaitable.FromItem(yourActivity));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download