Bert the bot, and automating some of our release process
At FreshBooks, we do releases every other week. In the time between, we sometimes need to push small hotfixes out. We use jabber to communicate changes between our operations team and the developers. Tickets or issues that need to be deployed go into a “Hotfix Queue”. In the past we’ve manually managed that queue both in our heads and as the topic of the group chat. As we’ve grown managing this queue mentally and manually in the groupchat title has become a bit tedious. This seemed like a perfect place to implement some better tooling.
I figured it would be pretty simple to whip up a chat bot in Node.js using Within an afternoon, I was able to crank out a passable prototype that assisted in managing the outgoing issue queue. Since then, the bot has been enhanced and improved to the point of being a useful, easy to extend, entertaining utility. Its current feature set includes getting weather information, managing our release issue queue, and I’m planning on adding when the next bus will arrive at the office, as soon as the TTC opens that data set up.
Design of the bot
The bot is designed around having a number of tasks that respond to different commands. Commands can be any set of characters, and calling a command is done by starting a message to the group chat or directly to the bot starting with those characters. For example the Weather task has two commands
!forecast. Any message starting with either of those values will be parsed by the bot and the text that follows will be sent to the task.
I think this gives you a pretty flexible and powerful way to make command based bot tasks. The commands can easily interact with any HTTP or socket based interface thanks to node’s great built in socket support. The bot also provides a simple promise implementation for building bot commands that require asynchronous work.
Installing the bot
I’ve put the bot up on and installing it is pretty simple. You’ll need Node.js 0.4.6 or greater, and npm 1.0. After cloning the repository, or downloading a tar file, you can install all the dependencies with npm
This will download all the dependencies into the
node_modules, afterwards you should copy the
config.json and add in your connection information and task configuration. After the configuration file is in place you can start the bot with
node bot.js. Your bot should join the configured rooms, and respond to direct messages.
While the bot works, and does what it does reasonably well, I can see a few areas of improvement. Currently its impossible to make logging or non-command based tasks. It’d be useful to be able to make message listeners that could respond to conversation as it happens. The bot could also benefit from a few more general purpose tasks, like reminders and leaving notes for other people. Hopefully, if you’re on a jabber network all day, you’ll find this bot useful, and be able to help automate some part of your day.