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.
Can you go back a step in a waterfall dialog if the user entered wrong data? #botframework
Asked Answered
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.
© 2022 - 2024 — McMap. All rights reserved.
validatedPrompt()
has been deprecated and you should usesession.replaceDialog('dialogName', { reprompt: true });
instead. Check the docs for reference. – Tailrace