How connect Hubot to Slack on CentOS

By   10-03-2017 · 2 minute read · 216 words


In this post we will install Hubot your friendly neighborhood chatbot on CentOS.

First get node installed.

sudo yum -y install nodejs

We then install yeoman + generator-hubot using npm.

sudo npm install -g yo generator-hubot

Create a directory to host the code generated. I’m calling my dir hal but it can be whatever you want. Once you run yeoman, you’ll get prompted for a few inputs from the script.

mkdir hal && cd $_
yo hubot

If you get an warning such as:

npm WARN [email protected] requires a peer of [email protected]^1.12.6 but none was installed.

Add

"coffee-script": "^1.12.6"

to package.json.

Since we will link this to Slack we will need to get the slack adapter installed.

npm install hubot-slack --save

Removing Heroku cruft and unused files.

Next if you aren’t deploying this to Heroku and planning to run locally to test we will uninstall the Heroku keepalive package.

npm uninstall hubot-heroku-keepalive --save

Also remove “hubot-heroku-keepalive” from external-scripts.json

sed -i '/hubot-heroku-keepalive/d' external-scripts.json

Clean up files that hubot will complain about if unused on start.

 rm hubot-scripts.json Procfile

Lastly you need to export some env variables. These are obtained through slack when you add the hubot slack app.

export HUBOT_ADAPTER=slack
export HUBOT_SLACK_TOKEN=<your token>

Then attempt to run hubot using:

./bin/hubot

if you are in the project root.

hubot   chatops  

comments powered by Disqus