Hubot on Grove

Posted by Jori Lallo on 5 December 2011

Hubot is an awesome and extendable bot created by the cool folks at GitHub. While Hubot was originally created for Campfire, there's now adapters for different platforms including IRC, so it works nicely with Grove. The easiest way to deploy Hubot for Grove is to use Heroku for hosting.

To get started you'll need to sign up a new user to your organization. Register an account with the username you want your Hubot to be called. I went with simply grovebot. Here's how you can deploy the bot manually but if you want you can use Tom Bell's Hubot Factory which will do most of the heavy lifting for you.

Setup

To install Hubot, you'll first need to have CoffeeScript and npm installed. The web is full of instructions for installing both so we won't cover them here. Start the installation by cloning Hubot and creating a new instance.

git clone https://github.com/github/hubot.git
cd hubot
npm install

# Create new Hubot and switch directories
bin/hubot --create ../grovebot
cd ../grovebot

# Setup git repo
git init .
git add .
git commit -m "initial commit"

Now you need to add hubot-irc in the dependencies by editing the package.json file.

"dependencies": {
"hubot-irc": ">= 0.0.1",
"hubot": ">= 2.0.0",
...
}

Next modify the Procfile to match the following (remember to replace grovebot with your bot's name).

app: bin/hubot -a irc -n grovebot

Save both files and commit changes. Now it's time to deploy the app to Heroku (again, change grovebot to match your bot's name).

# Create Heroku app
heroku create grovebot --stack cedar
git push heroku master

# Some hubot extensions require Redis (RedisToGo needs to be active)
heroku addons:add redistogo:nano

Next configure your Hubot to work with Grove's IRC interface. Use your organization's and bot's information.

heroku config:add HUBOT_IRC_NICK="grovebot"
heroku config:add HUBOT_IRC_ROOMS="#channel-name"
heroku config:add HUBOT_IRC_SERVER="organization-name.irc.grove.io"
heroku config:add HUBOT_IRC_PASSWORD="organization-name"
heroku config:add HUBOT_IRC_NICKSERV_PASSWORD="password for the bot goes here"
# To use SSL but you can leave these out
heroku config:add HUBOT_IRC_PORT=6697
heroku config:add HUBOT_IRC_USESSL="true"

Once you're done, fire up your Hubot.

heroku ps:scale app=1

Now you should see the newly created Hubot join your chat rooms. Your Hubot should reply to you if you call it by name.

grovebot help

If it doesn't reply, something is wrong and you can get more information with commands.

heroku logs
heroku ps

Resources

To read more about deploying Hubot, check out these guides:

Deploying Hubot to Heroku like a boss - martinciu's dev blog
Deploying Hubot onto Heroku - Hubot Wiki
Adapter: IRC - Hubot Wiki

Big thanks to Tom Bell who has contributed to Hubot by creating Hubot Factory and maintaining its Wiki. He also helped with this guide.

Image credit: GitHub

2 Comments

caleywoods Dec 14, 2011

Adding scripts is as simple as cloning down github/hubot-scripts and moving the script you want to use into your grovebot /scripts directory, commiting to git and then pushing to heroku.

I've not seen this issue on Grove yet but on regular IRC you need to watch out when adding a lot of scripts and calling "help", your bot may be kicked for flooding (posting too much text at once).

leah (Grove team) Dec 14, 2011

@caleywoods Thanks for adding the tip about scripts.

Grove won't ban anyone one for flooding. Organization owners control who has access to the server, so banning for flooding doesn't seem necessary (or hasn't been necessary yet at least).