Scott Walsh is a software developer living in London.

Setting up the hubot-xmpp adapter

24 Apr 2014

Hubot is an open source chat bot which is written in CoffeeScript and runs on node.js.

After recently getting hubot up and running, I ran into some trouble setting up the hubot-xmpp adapter to allow me to communicate with hubot using the XMPP protocol.

There appeared to be a problem while bootstrapping, it didn't manage to connect to the Openfire server and the output was minimal even with debug logging turned on. It reached the following point before stopping, not logging any other information:

> Cannot load StringPrep-0.1.0 bindings. You may need to `npm install node-stringprep'
> [Sun Apr 20 2014 10:02:15 GMT (BST)] INFO { username: 'scott.walsh@company.com',
  password: '********',
  host: 'im.company.com',
  port: '5222',
  rooms: [ { jid: 'hubot@conference.server', password: false } ],
  keepaliveInterval: 30000,
  legacySSL: '0',
  preferredSaslMechanism: undefined,
  disallowTLS: undefined }

After trying a number of things including multiple combinations of environment variables, turning off TLS in Openfire server configuration, and scratching my head. I eventually managed to get it to work by setting the following environment variables and no other XMPP related variables (using the same credentials as I use to log in using pidgin).

export HUBOT_XMPP_USERNAME=scott.walsh@company.com
export HUBOT_XMPP_PASSWORD=password
export HUBOT_XMPP_ROOMS=hubot@conference.server
export HUBOT_XMPP_HOST=im.company.net
export HUBOT_XMPP_LEGACYSSL=1

...and making sure all of the dependencies were added to the package.json

"dependencies": {
    "hubot": ">= 2.6.0 < 3.0.0",
    "hubot-scripts": ">= 2.5.0 < 3.0.0",
    "optparse": "1.0.3",
    "node-xmpp": "0.3.2",
    "hubot-xmpp": "0.1.0",
    "htmlparser": "1.7.6",
    "soupselect": "0.2.0",
    "underscore": "1.3.3",
    "underscore.string": "2.2.0rc"
  }

The following bash script ensures the environment variables are set and I now use this to start hubot:

#! /bin/bash
export HUBOT_XMPP_USERNAME=scott.walsh@company.com
export HUBOT_XMPP_PASSWORD=password
export HUBOT_XMPP_ROOMS=hubot@conference.server
export HUBOT_XMPP_HOST=im.company.net
export HUBOT_XMPP_LEGACYSSL=1
export HUBOT_LOG_LEVEL="debug"
./bin/hubot --name hubot --adapter xmpp