Created
July 8, 2017 13:27
-
-
Save jazzedge/223937f6a242bc77cdba3d5130651336 to your computer and use it in GitHub Desktop.
Bot - choice menu and reload menu
This file contains 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
// https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/basics-menus/app.js | |
//This Bot demonstrates how to create a simple menu for a bot. We've also added a | |
//reloadAction() to the menus dialog which lets you return to the menu from any | |
//child dialog by simply saying "menu" or "back". | |
bot.dialog('rootMenu', [ | |
function (session) { | |
builder.Prompts.choice(session, "Choose an option:", 'Flip A Coin|Roll Dice|Magic 8-Ball|Quit'); | |
}, | |
function (session, results) { | |
switch (results.response.index) { | |
case 0: | |
session.beginDialog('flipCoinDialog'); | |
break; | |
case 1: | |
session.beginDialog('rollDiceDialog'); | |
break; | |
case 2: | |
session.beginDialog('magicBallDialog'); | |
break; | |
default: | |
session.endDialog(); | |
break; | |
} | |
}, | |
function (session) { | |
// Reload menu | |
session.replaceDialog('rootMenu'); | |
} | |
]).reloadAction('showMenu', null, { matches: /^(menu|back)/i }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment