Ruby developer, API Integration and Scraping Expert
An entrepreneur, developer, photographer and a perfectionist.
"I am from Jaipur, India. I am a part of the Springboards Programme, 2012, whence I love to code little devils in Ruby."
Meet the Amazing Hubot
Recently, I came across Hubot – the amazing bot
from Github, which lets me do nearly anything while
talking to it. Some of the examples being querying my site for availability,
tracking down how many visitors I had in last 24 hours, updating my twitter
status, grabbing tasks from my basecamp projects, and so on.
Currently, I am using Hubot on HipChat and GTalk, but as
my team frequently uses Skype, I will be enabling a Skype adapter for it,
pretty soon (the Skype adapter, in particular, can not be installed on
Heroku). The Hubot instance runs as Edwin Jarvis, as
I always wanted to have something close to the esteemed J.A.R.V.I.S. from the
Here is a brief overview for anyone wanting to get started with Hubot:
git clone http://github.com/github/hubot jarvis
This should start the Hubot in your Shell. If, instead, this gives an error
saying redis was not found or something similar, make sure to remove
redis-brain.coffee from hubot-scripts.json file, and try running again!
Using Multiple Adapters
Ok, so running Hubot locally is good – we can see what it does, we can test
out our code/scripts, etc., but the real power of hubot lies in running it
over a chat server, so that it acts like ChatOps – you can virtually do
anything online by simply talking to the Hubot (think: deploying your code).
Since, Hipchat now provides a free plan for upto
5 users, it stands ideally as a Chat server for our needs (we are a small
team). Additionally, GTalk serves as a quick access to our bot, since it is
always open via either the GMail browser tab, or via some chat client.
However, there is a sligh problem. Hubot doesn’t currently support multiple
adapters, i.e. we can’t tell hubot to run on both Hipchat and Gtalk,
simultaneously, while using the same source code. But, why use the same
source? Why not make another hubot to run on GTalk? Well, I use a lot of
scripts – some are custom – and it is a pain to update two sources to make the
two hubots use the same set of scripts. Therefore, I implemented the following
procedure to let the two hubots use the same source:
First, create new dedicated accounts for our hubot on both Hipchat and
Add hubot-hipchat and hubot-gtalk as dependencies in package.json.
It should look like:
Set our environment variables for the HipChat bot. Settings marked with
@@ can be obtained by visiting your bot’s XMPP/Jabber account
settings, after logging in HipChat
with your bot’s account:
heroku config:add --app="<name-for-our-hipchat-bot>"\HUBOT_ADAPTER_NAME="hipchat"\HUBOT_ADAPTER_USER="<@@room name>"\HEROKU_URL="http://<name-for-our-hipchat-bot>.herokuapp.com"\HUBOT_HIPCHAT_JID="<@@username>@chat.hipchat.com"\HUBOT_HIPCHAT_PASSWORD="<hipchat.com password for your bot>"
Run our heroku process:
heroku ps:scale web=1
Your HipChat bot should now be live. Try logging in as a normal hipchat
user, and talking to the bot (hint: @jarvis help, where my bot’s mention
name was @jarvis)