Skip to content

Instantly share code, notes, and snippets.

@devStepsize
Created April 22, 2016 20:06
Show Gist options
  • Save devStepsize/c8d1b8333b9a98445bd3409edb4b2654 to your computer and use it in GitHub Desktop.
Save devStepsize/c8d1b8333b9a98445bd3409edb4b2654 to your computer and use it in GitHub Desktop.
Botkit conversation with multiple stages by chaining asks
// From https://github.com/howdyai/botkit#multi-stage-conversations
controller.hears(['pizzatime'], 'message_recieved', function(bot,message) {
askFlavor = function(response, convo) {
convo.ask('What flavor of pizza do you want?', function(response, convo) {
convo.say('Awesome.');
askSize(response, convo);
convo.next();
});
}
askSize = function(response, convo) {
convo.ask('What size do you want?', function(response, convo) {
convo.say('Ok.')
askWhereDeliver(response, convo);
convo.next();
});
}
askWhereDeliver = function(response, convo) {
convo.ask('So where do you want it delivered?', function(response, convo) {
convo.say('Ok! Good bye.');
convo.next();
});
}
bot.startConversation(message, askFlavor);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment