Skip to content

Instantly share code, notes, and snippets.

View perfectmak's full-sized avatar
🎯
Focusing

Perfect Makanju perfectmak

🎯
Focusing
View GitHub Profile
const pinger = require('./ping-bot');
//listen for direct message and direct mention events
controller.on(['direct_message', 'direct_mention'], (bot, message) => {
pinger(message.text, (response) => {
//send message reply to users
bot.reply(message, response);
});
});
const Botkit = require('botkit');
//Botkit supports both Slack and Facebook Messenger Bots,
//so you need to initalize for a slackbot controller with Botkit.slackbot();
const controller = Botkit.slackbot();
//Start a new process with the Bot Token gotten from Slack
const process = controller.spawn({
token: process.env.SLACK_TOKEN //change this based on the token you get
});
const pinger = require('ping-bot');
pinger(`google.com`, (response) => {
console.log(response);
// or do whatever you like with the bot
});
...
/**
* Processes a users message and gives relevant output
*/
const processRequest = (message, output) => {
if(helloWords.indexOf(message.toLowerCase()) != -1) {
return output(greeting);
}