Last active
October 10, 2016 04:47
-
-
Save carpeliam/d90a31c7f043d1c71d5a0b7015aa4f52 to your computer and use it in GitHub Desktop.
simple little slackbot, along with CF manifest and node package
This file contains hidden or 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
--- | |
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 |
This file contains hidden or 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
{ | |
"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" | |
} | |
} |
This file contains hidden or 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 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