Skip to content

Instantly share code, notes, and snippets.

@johngriffin
Last active June 14, 2016 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johngriffin/20c991c0c36ac39e11f86da4dd99cd50 to your computer and use it in GitHub Desktop.
Save johngriffin/20c991c0c36ac39e11f86da4dd99cd50 to your computer and use it in GitHub Desktop.
var Botkit = require('botkit')
var token = process.env.SLACK_TOKEN
var controller = Botkit.slackbot({
// reconnect to Slack RTM when connection goes bad
retry: Infinity,
debug: false
})
// Connect to Slack RTM
controller.spawn({
token: token
}).startRTM(function (err, bot, payload) {
if (err) {
throw new Error(err)
}
console.log('Connected to Slack RTM')
})
// Say "I'm here" when we're invited to join a channel
controller.on('bot_channel_join', function (bot, message) {
bot.reply(message, "I'm here!")
})
// Say "Hello" when we hear "hi"
controller.hears(['hi'], ['ambient', 'direct_message','direct_mention','mention'], function (bot, message) {
bot.reply(message, 'Hello.')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment