Last active
July 28, 2017 10:14
-
-
Save jazzedge/6fd0d6090ae066f601f931a4e9bb829d to your computer and use it in GitHub Desktop.
Bot - Restart a dialog: reloadAction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //See: https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-actions | |
| // Order dinner. | |
| bot.dialog('orderDinner', [ | |
| //...waterfall steps... | |
| ]) | |
| // Once triggered, will restart the dialog. | |
| .reloadAction('startOver', 'Ok, starting over.', { | |
| matches: /^start over$/i | |
| }); | |
| // In cases where you need to pass additional arguments into the reloaded dialog, you can add a dialogArgs option to the action. | |
| //This '' | |
| // option is passed into the args parameter. Rewriting the sample code above to receive an argument on a reload action will look //something like this: | |
| // Order dinner. | |
| bot.dialog('orderDinner', [ | |
| function(session, args, next){ | |
| if(args && args.isReloaded){ | |
| // Reload action was triggered. | |
| } | |
| session.send("Lets order some dinner!"); | |
| builder.Prompts.choice(session, "Dinner menu:", dinnerMenu); | |
| } | |
| //...other waterfall steps... | |
| ]) | |
| // Once triggered, will restart the dialog. | |
| .reloadAction('startOver', 'Ok, starting over.', { | |
| matches: /^start over$/i, | |
| dialogArgs: { | |
| isReloaded: true; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment