Github’s Hubot on Joyent’s no.de Smart Machines
I had an exciting adventure hacking away at Github’s chat bot, Hubot. Hubot uses node.js as the webserver, redis for database and coffeescript for programming language. In this tutorial we will hook Hubot into a Campfire chatroom running on a free node.js server from http://No.de.
Incase you have no idea what Hubot is, and you are genuinely interested, you can read Github developers talk about him here and here.
Have you deployed to no.de before? Familiar enough with Hubot? Skip this tutorial and see exactly what you need from my gist.
1.) Before we start
- Create an account on no.de
- Fire up a node.js smartmachine.
- Add ssh config options to your ~/.ssh/config file. Instructions on your machine’s dashboard.
- Add you public ssh key to your account. Instructions here.
Make sure you can ssh into your node machine.
ssh useraccount.no.de
2.) Adding environment variables
A hubot adapter is basically the type of chat environment you want Hubot to connect to: Campfire, IRC, Gtalk, Email, XMPP, hipchat, etc. Every adapter has it’s own environment variables that need to be added to your server.
You can see some examples on Hubot’s Wiki on adapters. Here is the page for Campfire’s Adapter.
The user that will be running node.js applications on your no.de server is “node-service”. In order to add environment variables for this user we must ssh into your machine with the admin account.
ssh admin@username.no.de
Once you have logged in, you need to edit the following file: /home/node/node-service/profile and paste in your environment variables.
sudo vim /home/node/node-service/profile
In the vim editor, press “i” to insert. Type in (or paste on Mac) your environment variables. When finished press “esc”, “:w!”+enter to save and finally “:q”.
# Hubot stuff export HUBOT_CAMPFIRE_TOKEN="token here" export HUBOT_CAMPFIRE_ROOMS="roomID,roomID,roomID" export HUBOT_CAMPFIRE_ACCOUNT="campfire subdomain"
3.) Download Hubot
You can get the latest version of Hubot from the repo’s download page. Unzip the package.
4.) Prepare Hubot for No.de
No.de looks for a file named server.js that will kick start your app upon a git push. Hubot has no such file and is written in coffeescript rather than plain Javascript. We must add a line to package.json that will tell No.de how to launch our application. Also, we need to add a file called config.json that will tell No.de which nodejs version to use.
Create config.json
It only need to contain the following.
{"version": "v0.4.11"}
Edit package.json
Add the following line to the bottom of the file. This will launch Hubot’s Campfire adapter.
,"scripts": { "start": "./bin/hubot --adapter campfire" }
5.) Push Hubot to No.de
You need to step into that folder to create a new git repo, create a git remote for no.de and finally push your repo to No.de.
git init git remote add no.de username.no.de:repo git push no.de master ... lots of output should end with: win!
That’s it.
Now go to your Campfire chatroom and mess with Hubot.
-
http://www.arlocarreon.com Arlo Carreon
-
http://twitter.com/gotoplanb Dave Stanton
-
Guillaume BINET