Skip to content

Instantly share code, notes, and snippets.

@carpeliam
Last active October 10, 2016 04:47
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 carpeliam/d90a31c7f043d1c71d5a0b7015aa4f52 to your computer and use it in GitHub Desktop.
Save carpeliam/d90a31c7f043d1c71d5a0b7015aa4f52 to your computer and use it in GitHub Desktop.
simple little slackbot, along with CF manifest and node package
---
applications:
- name: your-app-here
command: node slack.js
# no-route: true
health-check-type: none
domain: cfapps.io
env:
SLACK_API_TOKEN: your-token-here
{
"name": "wow, what a cool slack bot you just created",
"version": "1.0.0",
"description": "build whatever you can imagine",
"scripts": {
"test": "echo \"Error: no test specified... yet!\" && exit 1"
},
"keywords": [
"slack",
"bot"
],
"author": "This is you",
"license": "open source is good! open source your bot and add your license here",
"dependencies": {
"botkit": "^0.4.0"
}
}
var Botkit = require('botkit');
var token = process.env.SLACK_API_TOKEN || '';
var controller = Botkit.slackbot({
debug: process.env.NODE_ENV !== 'production'
//include "log: false" to disable logging
//or a "logLevel" integer from 0 to 7 to adjust logging verbosity
});
// connect the bot to a stream of messages
controller.spawn({ token: token }).startRTM();
// give the bot something to listen for.
controller.hears('reserve', [
'direct_message', 'direct_mention', 'mention'
],
function(bot, message) {
bot.reply(message, 'You just reserved a spot. Well, not really.');
}
);
controller.hears('remove me', [
'direct_message', 'direct_mention', 'mention'
],
function(bot, message) {
bot.reply(message, 'Thanks for letting me know! I\'ll remove you from the queue. Well, not really.');
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment