Each bot needs its own API key for tracking.
Create a bot to get an API key.
npm install --save dashbot
Use the API key created above.
const dashbot = require('dashbot')(<strong>process.env.DASHBOT_API_KEY</strong>).slack;
const controller = Botkit.slackbot();
controller.configureSlackApp(...);
// Add the dashbot middleware
<strong>controller.middleware.receive.use(dashbot.receive);
controller.middleware.send.use(dashbot.send);</strong>
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>replyMessage.channel = message.channel;
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>replyMessage.channel = message.channel;</strong>
<strong>dashbot.logOutgoing(bot.identity, bot.team_info, replyMessage);</strong>
bot.replyInteractive(message, replyMessage)
View sample code for a complete Slack bot example.