An Introduction To Integrations
var Botkit = require('Botkit');
var controller = Botkit.slackbot();
var bot = controller.spawn({
token: my_slack_bot_token
})
bot.startRTM(function(err,bot,payload) {
if (err) {
throw new Error('Could not connect to Slack');
}
});
// reply to @bot hello
controller.on('direct_mention',function(bot,message) {
// reply to _message_ by using the _bot_ object
bot.reply(message,'I heard you mention me!');
});
// reply to a direct message
controller.on('direct_message',function(bot,message) {
// reply to _message_ by using the _bot_ object
bot.reply(message,'You are talking directly to me');
});
{
"text": "This is the text of the message.",
"username": "webhook",
"icon_emoji": "eyes",
"channel": "#general"
}