Slack Integration with Botkit and NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(<strong>process.env.DASHBOT_API_KEY</strong>).slack;

After you create your Botkit controller, simply add send and receive middleware

const controller = Botkit.slackbot();
// Add the dashbot middleware

Slack Buttons

Starting with this slack button example, here is how you add Slack Button reporting to your bot.

Since Botkit does not send button interactions through its middleware, we need to log the button presses and interactive replies when they are made.

When you receive and send an interactive message, log it (you also must set the channel on the reply):

controller.on('interactive_message_callback', (bot, message) => {
  <strong>dashbot.logIncoming(bot.identity, bot.team_info, message);</strong>
  <strong> =;
  dashbot.logOutgoing(bot.identity, bot.team_info, replyMessage);</strong>
  bot.replyInteractive(message, replyMessage)

If you set the interactive_replies: true option in botkit, the incoming message is received by the middleware, but you still must send dashbot the outgoing message with the channel set:

controller.on('direct_message', (bot, message) => {
  <strong> =;</strong>
  <strong>dashbot.logOutgoing(bot.identity, bot.team_info, replyMessage);</strong>
  bot.replyInteractive(message, replyMessage)


View sample code for a complete Slack bot example.