7

In a dialog, I want to ask the user for his email address. If the user entered an invalid email by mistake, I would like to be able to go back or get into some "loop" situation of keep asking him for his email until he enters a valid one. What's the best way to accomplish that? I couldn't find any way to go back a step in a waterfall dialog.

icedwater
  • 4,701
  • 3
  • 35
  • 50
Shahar
  • 159
  • 4

1 Answers1

4

You can by calling next({ resumed: builder.ResumeReason.back }) but there's actually a better way to do what you're trying to do.

In the latest v0.8.0 version of the library I added a new DialogAction.validatedPrompt() action that lets you create a new prompt with a custom validation routine. With that you can call your '/emailPrompt' dialog instead of Prompts.text() and you won't need to go backwards. Check out the basics-validatedPrompt example to see it in action.

Steven Ickman
  • 1,936
  • 1
  • 12
  • 7
  • as per libray version 3.8, `validatedPrompt()` has been deprecated and you should use `session.replaceDialog('dialogName', { reprompt: true });` instead. Check the [docs](https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-replace) for reference. – Srichakradhar Mar 07 '18 at 15:27