Skip to content

Instantly share code, notes, and snippets.

Last active June 12, 2019 18:45
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Set Hue light to red for 2 seconds when certain words are mentioned in Slack
var Botkit = require('botkit');
var unirest = require('unirest');
var botToken = 'SLACK_BOT_TOKEN';
var hueBridge = 'IP_OF_HUE_BRIDGE';
var hueUser = 'HUE_USER_ID_FROM_BRIDGE';
var controller = Botkit.slackbot({
debug: false
token: botToken
}).startRTM(function(err) {
if (err) {
throw new Error(err);
controller.hears(['Jon', 'Jonathan', 'John'], ['ambient'], function(bot, message) {
// Sets light to Red
unirest.put('http://' + hueBridge + '/api/' + hueUser + '/lights/1/state').send('{"hue":65280}').end();
setTimeout(backToGreen, 2000);
function backToGreen(){
// Sets light to Green
unirest.put('http://' + hueBridge + '/api/' + hueUser + '/lights/1/state').send('{"hue":25500}').end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment