Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IbrahimTareq
Created May 4, 2018 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IbrahimTareq/6550c7851ecc3cbb6c1124c30635c6aa to your computer and use it in GitHub Desktop.
Save IbrahimTareq/6550c7851ecc3cbb6c1124c30635c6aa to your computer and use it in GitHub Desktop.
Start-up code for your Slackbot
// Add support for environmental variables
require('dotenv/config');
// Import botkit package
var Botkit = require('botkit');
// Create a controller for the Slackbot
var controller = Botkit.slackbot({
  debug: false
});
// Use the token to connect the bot to your Slack app
controller.spawn({
  token: process.env.TOKEN
}).startRTM();
// Determine behaviour of the Slackbot
controller.hears(['hello', 'hi'], ['ambient', 'direct_mention', 'mention'], function (bot, message) {
  bot.reply(message, "Hello.");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment