Handling multiple dialogs in Microsoft bot framework

With version V4 of Microsoft Bot Framework, FormFlow needs to be replaced by Waterfall Dialog. Here we can use stepContext.Values (dictionary) to maintain state across waterfall steps and present user with choice prompt for Yes or No response and then repeat the waterfall dialog in case of Yes response else end the dialog in last waterfall step.

Add below waterfall in constructor of your base Component dialog and repeat the waterfall as per user choice.

WaterfallStep[] myWaterfallDialog = new WaterfallStep[]
{ 
    this.waterfallStepToGetUserOrder,
    .......
    this.promptUserForChoiceStep,
    this.EndDialogStep
}
AddDialog(new WaterfallDialog("mydialog", myWaterfallDialog);

To manage multiple dialogs you need to use the Dialog Chains. You can either manage the stack of dialogs explicitly (using Call/Done) or implicitly using the Chain fluent methods. Here is sample of how to use it.

If the set of things that the user can select are already predefined I would then recommend using FormFlow. The Pizza & Sandwich samples are good examples of how to handle orders with a predefined set of options.

Tags:

Botframework