Created
April 17, 2016 13:27
-
-
Save KimuraTakaumi/cbccee8f70420d716c4d68e6e9d1975b to your computer and use it in GitHub Desktop.
Botkitを使ってSlackユーザーに要件を尋ねる
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
var Botkit = require('botkit'); | |
var controller = Botkit.slackbot({ | |
debug: false | |
}); | |
controller.spawn({ | |
token: process.env.token | |
}).startRTM(); | |
controller.hears('weather', 'direct_mention', function(bot,message) { | |
console.log(message); | |
askWeather = function(response, convo) { | |
console.log(response); | |
convo.ask('明日は雨です。車で出かけられますか?', function(response, convo) { | |
console.log(response); | |
convo.say('承知しました。'); | |
if(response.text == 'yes'){ | |
askCar(response, convo); | |
} | |
convo.next(); | |
}); | |
}; | |
askCar = function(response, convo) { | |
convo.ask('折りたたみ傘が必要ですか?', function(response, convo) { | |
if(response.text == 'yes') { | |
convo.say('承知いたしました。ご用意いたします。'); | |
} else { | |
convo.say('お気をつけてください。'); | |
} | |
convo.next(); | |
}); | |
}; | |
bot.startConversation(message, askWeather); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment