Skip to content

Instantly share code, notes, and snippets.

@perfectmak
Last active May 14, 2016 19:37
Show Gist options
  • Save perfectmak/35bc2cede4c506f9b80578a163674d8f to your computer and use it in GitHub Desktop.
Save perfectmak/35bc2cede4c506f9b80578a163674d8f to your computer and use it in GitHub Desktop.
const pinger = require('./ping-bot');
const Botkit = require('botkit');
//require beepboop's library
const BeepBoop = require('beepboop-botkit');
//as usual, initialize a slackbot controller
const controller = Botkit.slackbot();
/**
* But instead of spawning a process, you pass the controller to BeepBoop.
* BeepBoop handles managing processes for different teams that install your app,
* and it routes all the required controller events to make it easy to handle.
*/
const beepboop = BeepBoop.start(controller, {
debug: true //you might want to enable debug for testing :)
});
//then as usual handle when a direct message or direct mention event is triggered
controller.on(['direct_message', 'direct_mention'], (bot, message) => {
pinger(message.text, (response) => {
bot.reply(message, response);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment