Created
April 22, 2016 20:04
-
-
Save devStepsize/8e427f582c15e118e5ed6a24dd561e52 to your computer and use it in GitHub Desktop.
Botkit conversation ask with array of multiple callbacks
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
// From https://github.com/howdyai/botkit#using-conversationask-with-an-array-of-callbacks | |
controller.hears(['question me'], 'message_received', function(bot,message) { | |
// start a conversation to handle this response. | |
bot.startConversation(message,function(err,convo) { | |
convo.ask('Shall we proceed Say YES, NO or DONE to quit.',[ | |
{ | |
pattern: 'done', | |
callback: function(response,convo) { | |
convo.say('OK you are done!'); | |
convo.next(); | |
} | |
}, | |
{ | |
pattern: bot.utterances.yes, | |
callback: function(response,convo) { | |
convo.say('Great! I will continue...'); | |
// do something else... | |
convo.next(); | |
} | |
}, | |
{ | |
pattern: bot.utterances.no, | |
callback: function(response,convo) { | |
convo.say('Perhaps later.'); | |
// do something else... | |
convo.next(); | |
} | |
}, | |
{ | |
default: true, | |
callback: function(response,convo) { | |
// just repeat the question | |
convo.repeat(); | |
convo.next(); | |
} | |
} | |
]); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment