環境
mPro:botkit_test thr3a$ sw_vers ProductName: Mac OS X ProductVersion: 10.11.5 BuildVersion: 15F34 mPro:botkit_test thr3a$ npm -v 3.8.3 mPro:botkit_test thr3a$ node -v v5.10.0
APIキーの取得
ココからキーを取得して控えておく
インストール
npm install -S botkit
var Botkit = require('botkit'); var controller = Botkit.slackbot({ debug: false }); # プログラム controller.spawn({ token: 'API KEY' }).startRTM() controller.hears('ping',['direct_message','direct_mention','mention'],function(bot,message) { bot.reply(message,'pong'); });
起動
mPro:botkit_test thr3a$ node bot.js info: ** No persistent storage method specified! Data may be lost when process shuts down. info: ** Setting up custom handlers for processing Slack messages info: ** API CALL: https://slack.com/api/rtm.start notice: ** BOT ID: debug ...attempting to connect to RTM! notice: RTM websocket opened