3

Is exist way to change root dialog to different one during conversation:

Conversation.SendAsync((IMessageActivity)context.Activity, () => new RootDialogA())

We have application where it start with one rootdialog and on some point we want to run another root dialog:

Conversation.SendAsync((IMessageActivity)context.Activity, () => new RootDialogB())

D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
Vladimir B
  • 170
  • 1
  • 13
  • Possible duplicate of [Handling multiple dialogs in Microsoft bot framework](https://stackoverflow.com/questions/37169371/handling-multiple-dialogs-in-microsoft-bot-framework) – Ezequiel Jadib Oct 20 '17 at 14:42

1 Answers1

2

Yes there is. Using context.Call() or context.Forward() you can switch between dialogs. Please take a look at this sample project

Generally what people do is have a root dialog that routes to another dialog based on the context of the conversation. Here is an example from the sample I think where the root dialog is routing to another dialog using the context.Call() method:

private async Task SendWelcomeMessageAsync(IDialogContext context)
{
    await context.PostAsync("Hi, I'm the Basic Multi Dialog bot. Let's get started.");

    context.Call(new NameDialog(), this.NameDialogResumeAfter);
}

You must provide a resume after method that fires off when the called dialog has completed. In the sample it looks like this:

private async Task NameDialogResumeAfter(IDialogContext context, IAwaitable<string> result)
{
    try
    {
        this.name = await result;

        context.Call(new AgeDialog(this.name), this.AgeDialogResumeAfter);
    }
    catch (TooManyAttemptsException)
    {
        await context.PostAsync("I'm sorry, I'm having issues understanding you. Let's try again.");

        await this.SendWelcomeMessageAsync(context);
    }
}
Nicolas R
  • 13,812
  • 2
  • 28
  • 57
D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34