Update: These instructions have been merged in to Github’s repo via Hubot Pull *Request #1095

Why Hubot?

Hubot is great.

From hubot’s website:

Hubot is your company’s robot. Install him in your company to dramatically improve and reduce employee efficiency.

Today’s version of Hubot is open source, written in CoffeeScript on Node.js, and easily deployable. More importantly, Hubot is a standardized way to share scripts between everyone’s robots.

It allows you to have scripts running anywhere you can type - whether that be Slack, or Twitter, or GroupMe, or iMessage, or IRC… (full list here). You can write your own or use one of the hundreds of scripts that are openly available on GitHub.

Official Docs Here

Fun things to do with Hubot

picture time

Let’s get down to business

Prereqs:

  1. Follow the Hubot Getting Started guide 1. Have a Bluemix account 1. Install the Cloud Foundry CLI

The official hubot docs point you to Heroku as a hosting mechanism. Unlike Heroku, the free tier on Bluemix supports 24/7 uptime, so you don’t need to go through the hassle of setting up something like hubot-heroku-keepalive.

First we need to define a manifest.yml file in the root directory (and delete the generated procfile). The contents of the manifest at the bare minimum should look like:

applications:
- buildpack: https://github.com/jthomas/nodejs-v4-buildpack.git
  command: ./bin/hubot --adapter slack
  path: .
  instances: 1
  memory: 256M

In this example, we’re using the slack adapter (as shown by the start command). Of course, the start command can be whatever you need to start your specific hubot. You can optionally set a host, and name, and much more, or you can set those up through the Bluemix GUI in the dashboard. For thorough documentation on what the manifest.yml file does and how it used and how to configure your own, see these docs.

You then need to connect your hubot project to Bluemix:

$ cd your_hubot_project
$ cf api https://api.ng.bluemix.net
$ cf login

This will prompt you with your login credentials. Then to deploy your hubot, all you need to do is:

$ cf push NAME_OF_YOUR_HUBOT_APP

Note: if you do not specify a name and host in your manifest, you will have needed to create a Node.js Cloudfoundry app in the Bluemix dashboard. You then use the name that of that app in your cf push command. For very thorough documentation on deploying a Node.js app to Bluemix, please read here, for very thorough documentation of the command line interface, please read here.

Finally you will need to add the environment variables to the website to make sure it runs properly. You can either do it through the GUI (under your app’s dashboard) or you can use the command line, as follows (example is showing slack as an adapter):

$ cf set-env NAME_OF_YOUR_HUBOT_APP HUBOT_SLACK_TOKEN TOKEN_VALUE

Shameless plug

hey, this wouldn’t be a blog post if I didn’t shamelessly plug my own hubot script - Hubot-Hamilton… it… posts Hamilton lyrics.

Further Reading