This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pinger = require('ping-bot'); | |
pinger(`google.com`, (response) => { | |
console.log(response); | |
// or do whatever you like with the bot | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
/** | |
* Processes a users message and gives relevant output | |
*/ | |
const processRequest = (message, output) => { | |
if(helloWords.indexOf(message.toLowerCase()) != -1) { | |
return output(greeting); | |
} |
NewerOlder