Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Deploying Hubot on DigitalOcean (with Slack integration)

Deploying Hubot on DigitalOcean

By Thomas Darr (@trdarr), with love.

“How has no one yet written a tutorial for deploying Hubot on @digitalocean? cc @beyroutey

— Miles Grimshaw (@milesgrimshaw), 10 Dec 2013

How indeed!

In this tutorial, I'll deploy to a DigitalOcean droplet that runs Arch, so I'm using the pacman package manager and the systemctl service manager. The hubot I'll deploy will live in /srv/com.trdarr.hubot, will be accessible at, and will integrate with Slack. If you're following along, you'll need to adjust the commands and configurations accordingly.

Install the dependencies

You need Nginx, Node.js, and Redis.

Nginx is highly configurable. Fortunately, ArchWiki has good documentation for Arch, as has DigitalOcean for Arch and other platforms, so I'll leave that up to them.

Installing Node.js and Redis is simple:

sudo pacman -S nodejs redis
sudo systemctl enable redis
sudo systemctl start redis

Configure Nginx

My hubot will live in /srv/com.trdarr.hubot and will be accessible at Because I host many different services on one droplet, I like to keep the nginx.conf files near the services themselves. To that end, I added this line to the http block of my /etc/nginx/nginx.conf:

include /srv/com.trdarr.hubot/nginx.conf

And here's the contents of /srv/com.trdarr.hubot/nginx.conf:

upstream hubot_trdarr_com {
  server fail_timeout=0;

server {
  root /srv/com.trdarr.hubot;

  location / {
    index index.htm;

  location /hubot {
    try_files $uri @hubot_trdarr_com;

  location @hubot_trdarr_com {
    proxy_pass http://hubot_trdarr_com;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Let's break this down:

  • When Nginx gets a request for /, it responds with index.htm.
  • When Nginx gets a request for /hubot, it forwards the request to my hubot, which will be listening on port 48268 because that's how you spell HUBOT on a telephone.

Restart Nginx after making these changes:

sudo systemctl restart nginx

It's totally possible that Nginx won't restart because you've introduced a syntax error in one of the two nginx.conf files you've edited. In that case, you can ask systemctl for some useful (and highly googleable) error messages:

sudo systemctl status -l nginx

Once Nginx has restarted, you can test your configuration: will respond with index.htm and will respond with a 502 Bad Gateway.

Create a hubot

Install Hubot with Node Package Maid:

npm install -g hubot

cd to your soon-to-exist hubot's home and create it:

cd /srv/com.trdarr.hubot
hubot --create hubot

Integrate your hubot

If you're using a subdomain à la, go to the DigitalOcean DNS manager and add an A record to your domain that maps hostname hubot that to the IP address of your droplet.

Hubots listen to 8080 unless $PORT is defined, so define it:

export PORT=48268

Install the hubot-slack adapter:

npm install --save hubot-slack

Create a new Hubot integration for your team with hubot URL Slack will give you a token that you'll need to export with some other environment variables according to Slack's Hubot integration page.

export HUBOT_SLACK_TOKEN=wowsuchtoken
export HUBOT_SLACK_TEAM=trdarr
export HUBOT_SLACK_NAME=slackbot

Run your hubot

cd hubot
bin/hubot --adapter slack

Send “slackbot ping” to any channel and your hubot will respond with an emphatic “PONG”.

I don't have any advice for troubleshooting, but I've done this once before. If you're having trouble, you can send a tweet to @trdarr and I'll give it my level best. Or you can shrug, say “computer”, and try again in a little while. The power is yours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment