I\'m trying to create a dialog in which I define multiple waterfall steps. In the context of this dialog, I need sometimes to go back to the previous waterfall step accordin
You can use the option parameter in the method "ReplaceDialogAsync" and skip steps with the method "NextAsync".
For example in my waterfall steps (defined in the constructor):
AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
{
IntroStepAsync,
ActStepAsync,
FinalStepAsync
}));
// The initial child Dialog to run.
InitialDialogId = nameof(WaterfallDialog);
If you want pass to second step (in my case ActStepAsync) from the final step (FinalStepAsync) , when I going to replace the dialog I use the created a label in the Dialog:
private const string FLAG = "MY_FLAG";
When I invoke the method from final step I do this :
return await stepContext.ReplaceDialogAsync(InitialDialogId, FLAG, cancellationToken);
So I only need check the option in the first step if the context has the flag :
// Use the text provided in FinalStepAsync or the default if it is the first time.
var messageText = stepContext.Options?.ToString() ?? "welcome-message";
if (messageText.Equals(FLAG_REPROMPT))
{
return await stepContext.NextAsync(null,cancellationToken);
}
Later this you are in the second step