Stylized Alex Ward logo

Tagged “hubot”

Techlahoma Chat Bot

Today while I was talking in #techlahoma, the topic of chatbots came up. Being something of a chat bot connoisseur, I (with @amandaharlin's blessing) have set out to tell you how to get your very own hubot up and running on IRC.

First, let's talk briefly about my chat bot history. I've written a Python chat bot from scratch to connect with an XMPP server. His name was kittenbot, and he was awesome. As a result, I got very familiar with XMPP's XEP-0045, which is the specification for multi user chat. Fortunately, the good folks over at @github have given us a lot more to work with than I did in the Kittenbot days.

Awesome. So let's get cracking.

First thing you should do is go grab an ice-cold beer. I've gone with Prarie Wine Barrel Noir. It's particularly delicious and well suited to making hubots.

The second thing you need to do is install the latest version of node. I've built it from source on ubuntu, which is an amazingly simple process. Instructions can be found over at Joyent.

You need then to get the required npm packages for hubot:

npm install -g hubot coffee-script

After you have that installed, you'll need to create your new hubot. This is done simply with:

hubot --create techlahoma-bot

This will create a new techlahoma-bot directory in whatever root directory you specified. I'll be putting this code up at
Next step is to install the new hubot's brain! This runs on redis by default, which is fine. I'm not going to be super picky and just install the redis-server package provided by my host. Once that's installed, it is running on the proper port by default, so that's all we need to do.

After that, we need to make some minor modifications to the Package.json file. For some reason, the one generated by hubot --create does not include the correct version for hubot-scripts. We need to change the line:

'hubot-scripts': '>= 3.5.0 < 3.0.0',


'hubot-scripts': '2.5.14',

Great! Now hubot is able to actually run. Now we need to pick and choose some awesome things from the Hubot Script Catalog to have our bot be capable of by editing hubot-scripts.json:


We are close now! The only thing left to do is set 3 environment variables, and install the irc adapter!

npm install hubot-irc --save
export HUBOT_IRC_NICK='amandaharlin_v2'
export HUBOT_IRC_ROOMS='#techlahoma'

Cool! Everything is good to go, just need to fire it up with:

bin/hubot -n amandaharlin_v2 --adapter irc

WE NOW HAVE BOT. ALL GLORY TO amandaharlin_v2!

I did most of this work from a Microsoft Surface. It's a really solid tablet, and I'm actually pretty impressed by it.

Techlahoma Chat Bot take 2

So it has been a while since I first talked about creating amandaharlin_v2, and I figured it was time for an update.I originally spun up _v2 on Digital Ocean (which is what is hosting this blog), and everything worked out pretty well.

However, this left some things to be desired, as I was the only one in control of the server, and since I wasn't using any kind of node process manager. If irc would disconnect for extended periods of time, or the node process would die for any reason, I'd have to manually go restart the bot. Additionally, there wasn't an easy way to give access to the administrators of #techlahoma.

This is why I receently moved amandaharlin_v2 over to Heroku. The instructions for this are actually very well documented, and the process is not all that difficult.

The very first thing that you need to do is create the heroku app, which can be done with the heroku command line:

cd techlahoma-bot
heroku create

This automatically adds the heroku git repo url to the git repository within which the command was run.

After that, it's just a matter of using heroku:set to create the appropriate environment variables:

heroku config:set HUBOT_IRC_NICK=&quot;amandaharlin_v2&quot;
heroku config:set HUBOT_IRC_ROOMS=&quot;#techlahoma&quot;
heroku config:set HUBOT_IRC_SERVER=&quot;;
heroku config:set HEROKU_URL=

That last one is used to ensure the application pings itself at the appropriate interval to ensure that it doesn't timeout when inactive.

Finally, the only last thing you need to do when pushing the bot is to update the Procfile in order to actually start the app:

web: bin/hubot -a irc -n amandaharlin_v2

After that, we're done! Huzzah.

The added bonus here is that I can also grant access to the various #techlahoma leadership to adminster the app directly instead of having to create ssh accounts for them.