Skip to content

Instantly share code, notes, and snippets.

@jazzedge
Last active July 28, 2017 10:14
Show Gist options
  • Select an option

  • Save jazzedge/6fd0d6090ae066f601f931a4e9bb829d to your computer and use it in GitHub Desktop.

Select an option

Save jazzedge/6fd0d6090ae066f601f931a4e9bb829d to your computer and use it in GitHub Desktop.
Bot - Restart a dialog: reloadAction
//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