Hipchat and Hubot, Part 1.

Hipchat is a very useful private group chat system, that runs on many devices, including the browser. At work we use it for internal communication, creating seperate ‘rooms’ to help compartmentalise discussions.

Hubot is “A CUSTOMIZABLE, KEGERATOR-POWERED LIFE EMBETTERMENT ROBOT” which roughly translates into “A tool capable of recieving messages and then performing predetermined actions”.

The power of Hubot comes from the fact that it has many adapters which allow it to connect to different services, including:

Installing on Ubuntu 14.04 was a little tricky as the NPM installer was bjorked however, generally you want to:

sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install libexpat1-dev
sudo apt-get install libicu-dev
sudo npm install -g hubot coffee-script
hubot --create <mypath>
cd <mypath>
npm install
npm install --save hubot-hipchat
touch ./run.sh
chmod 0755 ./run.sh
vi ./run.sh

put the following into your run.sh file, remembering to replace the hipchat username and password with that of your Hubot account.

#!/bin/bash

export HUBOT_HIPCHAT_JID="..."
export HUBOT_HIPCHAT_PASSWORD="..."
bin/hubot --adapter hipchat

You should now be able to start hubot using the command:

./run.sh

Assuming this works, log into hipchat and join a room. Type into the chat window:

@<botUsername> help

and hubot should send you a list of preconfigured commands. For example:

Hipchat Hubot Help

Choosing one of these examples at random, I can now get Hubot to return useful information, for example pugs!

Hipchat Hubot Pug Me

At the moment our bot isn’t running as a daemon, disconnecting/closing our console will terminate the process. In the next article we’ll look at making our bot run continuously.

Ben Squire

Read more posts by this author.

Leicestershire, United Kingdom https://squired.co.uk