A framework for slack bots
- Install the latest node (
--harmony
is required) - Fork skynet
- Clone Fork
npm Install
npm start
- Add a new outgoing web hook configured to your liking
- Create a file/bot handler in the bot directory (we'll assume its foo.js)
- Add the bot config to your json files (make sure the name match's the name of your file)
{
"bots" : [{
"name" : "foo",
"tokens" : {
"incoming" : "[TOKEN_FROM_HOOK]"
}
}]
}
- deploy
- enjoy
Keep in mind that bots are routed by the POST'ed token
A few utilities have been added for convenience
module.exports = function *() {
if (this.request.body.text ==='hello bot') {
this.respond('hello human'); // sends the text as { text: text } (required for slack parsing)
} else {
this.error(400, 'OH NO!') // sends the error as { error: text } (ignored by slack, for testing only)
}
}
- John Hofrichter