I'm working on a bot in .NET. I have a scorable from which I would like to fire off a dialog D1, then end up with an empty stack. Or to put it another way, I want to fire off a new dialog, but instead of interrupting then resuming where I was at (like most scorable examples), end up with a blank dialog stack (like the Cancel scorable example).
Possibly relevant point : the dialog it fires off (D1) in turn puts another dialog (D2) on the stack which I also want to work properly before the stack gets cleared.
There is this example for a Cancel scorable : https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-global-handlers. Its purpose is to clear the dialog stack.
I would like to do that, but call another dialog first. I have tried this in the PostAsync() method of my scorable :
var interruption = dialog_D1.Void<object, IMessageActivity>();
_task.Call(interruption, null);
await _task.PollAsync(token);
_task.Reset();
However what happens is that PollAsync() fires and the dialog stack is cleared as soon as D1 calls D2. Which means that when you respond to D2, the stack is empty and RootDialog takes the input.
I've also tried this in the PostAsync() method of my scorable :
var interruption = dialog_D1.Void<object, IMessageActivity>();
_task.Call(interruption, AfterCallingDialog);
await _task.PollAsync(token);
...
private async Task AfterCallingDialog(IDialogContext context, IAwaitable<object> result)
{
_task.Reset();
}
But in that case the bot errors out with "IDialog method execution finished with multiple resume handlers specified through IDialogStack." as soon as it hits _task.Call()
Could anyone please suggest a fix for this or let me know of a different approach?
Thanks!
Lee
Funny how you can look at something for days then as soon as you post about it discover an answer. Here is what worked for me :
_task.Call(dialog_D1.Do(AfterChildDialog), null);
await _task.PollAsync(token);
...
private async Task AfterChildDialog(IBotContext arg1, IAwaitable<object> arg2)
{
_task.Reset();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With