Skip to content

Instantly share code, notes, and snippets.

@devStepsize
Created April 22, 2016 20:04
Show Gist options
  • Save devStepsize/8e427f582c15e118e5ed6a24dd561e52 to your computer and use it in GitHub Desktop.
Save devStepsize/8e427f582c15e118e5ed6a24dd561e52 to your computer and use it in GitHub Desktop.
Botkit conversation ask with array of multiple callbacks
// 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