Created
July 10, 2017 15:50
-
-
Save jazzedge/1707c8382e62f307797cf558be784d6a to your computer and use it in GitHub Desktop.
Bot - Prompt with buttons that disappear and re-prompt if answer not permitted
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
| bot.dialog('/', [ | |
| function (session) { | |
| var msg = new builder.Message(session) | |
| .text("Thank you for expressing interest in our premium golf shirt! What color of shirt would you like?") | |
| .suggestedActions( | |
| builder.SuggestedActions.create( | |
| session, [ | |
| builder.CardAction.imBack(session, "green", "green"), | |
| builder.CardAction.imBack(session, "blue", "blue"), | |
| builder.CardAction.imBack(session, "red", "red") | |
| ] | |
| )); | |
| builder.Prompts.text(session, msg); | |
| }, | |
| function(session, results) { | |
| var reply = results.response; | |
| switch(reply.toLowerCase().trim()) | |
| { | |
| case 'red': case 'blue': case 'green': | |
| session.send('I like ' + results.response + ' too!'); | |
| session.endConversation('All done!'); | |
| break; | |
| default: | |
| session.send("I'm sorry, that answer is not recognized. Let's try again..."); | |
| session.replaceDialog('/'); | |
| } | |
| //Shouldn't get here | |
| } | |
| ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment