messageRoom doesn't work #24

lhan opened this Issue Apr 19, 2012 · 10 comments


None yet

8 participants

lhan commented Apr 19, 2012

It should send a message to the room but comes with following stack trace:

2012-04-19T02:02:22+00:00 app[web.1]: Error: Argument error
2012-04-19T02:02:22+00:00 app[web.1]: at new JID (/app/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)
2012-04-19T02:02:22+00:00 app[web.1]: at Bot.message (/app/node_modules/hubot-hipchat/node_modules/wobot/lib/bot.js:344:21)
2012-04-19T02:02:22+00:00 app[web.1]: at Robot.send (/app/node_modules/hubot/src/
2012-04-19T02:02:22+00:00 app[web.1]: at HipChat.send (/app/node_modules/hubot-hipchat/src/
2012-04-19T02:02:22+00:00 app[web.1]: at nextMiddleware (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:175:25)
2012-04-19T02:02:22+00:00 app[web.1]: at Object. (/app/scripts/
2012-04-19T02:02:22+00:00 app[web.1]: at param (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:183:16)
2012-04-19T02:02:22+00:00 app[web.1]: at pass (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:191:10)
2012-04-19T02:02:22+00:00 app[web.1]: at param (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:186:15)
2012-04-19T02:02:22+00:00 app[web.1]: at Object.router as handle

I've tried both room JID & JID@hostname but no luck with that.

Any help please?

Public: A helper send function to message a room that the robot is in

room - String designating the room to message

strings - One or more Strings for each message to send.

messageRoom: (room, strings...) ->
user = @userForId @id, { room: room }
@adapter.send user, strings...


I have exactly the same problem, any solution?

lhan commented Apr 30, 2012

Hooked up hipchat API instead.

# Cloudmailin

http = require('http')
querystring = require('querystring')
auth_token = "supa-secret"

module.exports = (robot) -> '/hubot/cloudmailin/:room', (req, res) ->
                post_data = querystring.stringify({
                                message: "#{req.body.from} - #{req.body.subject}<br>#{req.body.html}",
                                from: "MailMan"
                post_options = {
                                host: '',
                                port: 80,
                                path: '/v1/rooms/message?auth_token='+auth_token,
                                method: 'POST',
                                headers: {
                                        'Content-Type': 'application/x-www-form-urlencoded',
                                        'Content-Length': post_data.length

                post_req = http.request post_options, (res) ->
                        res.on 'data', (chunk) ->
                                console.log('Response: ' + chunk)
                post_req.write post_data
                res.writeHead 200, { 'Content-Length': 0 }

Thanks for sharing !


I'm having the exact same problem, running hubot on heroku. Cannot replicate on my local machine, works fine there.


"name": "hosted-hubot",
"version": "0.2.0",
"author": "GitHub Inc.",
"keywords": "github hubot campfire bot",
"description": "A simple helpful Robot for your Company",
"licenses": [{
"type": "MIT",
"url": ""

"repository" : {
"type" : "git",
"url" : ""

"dependencies": {
"hubot-hipchat": ">= 1.0.4",
"hubot": "2.1.4",
"hubot-scripts": ">=2.0.4",
"optparse": "1.0.3",
"soupselect": "0.2.0",
"htmlparser": "1.7.4",
"wolfram": "0.2.0"

Error: Argument error
at new JID (/app/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)
at Bot.message (/app/node_modules/hubot-hipchat/node_modules/wobot/lib/bot.js:344:21)
at HipChat.send (/app/node_modules/hubot-hipchat/src/
at Robot.messageRoom (/app/node_modules/hubot/src/
at Object. (/app/scripts/
at nextMiddleware (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:175:25)
at param (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:183:16)
at pass (/app/node_modules/hubot/node_modules/connect/lib/middleware/router.js:191:10)
at Object.router as handle
at next (/app/node_modules/hubot/node_modules/connect/lib/http.js:203:15)[dunno d0b8b6c] Dump shoulda

Any idea what I can do to get past this the right way? I will try the above for now.


I too was getting this failure trying to implement a http say style command.

Changing my package.json to reference the following fork allowed me to get this working


"dependencies": {
  "hubot-hipchat": ""

The hubot script then looks like the following

querystring = require('querystring')

module.exports = (robot) ->
  robot.router.get "/hubot/say", (req, res) ->
    query = querystring.parse(req._parsedUrl.query)

    user = {}
    user.reply_to = query.user if query.user     = if
    user.type     = query.type if query.type

    robot.send(user, query.message)

    res.end "Said #{query.message}"
dajobe commented Oct 26, 2012

I found a hacky fix for this in two parts

  1. hand-editing the wobot file


if (parsedJid.domain === this.mucHost) {
packet = new xmpp.Element('message', {
to: targetJid + '/' +,
type: 'groupchat'
} else {


if (parsedJid.domain === "") {
packet = new xmpp.Element('message', {
to: targetJid + '/' +,
type: 'groupchat'
} else {

If I changed HUBOT_HIPCHAT_HOST from '' (which ends up in this.mucHost) other things wouldn't work.

  1. Edit the core hubot-hipchat code

In bot.onMessage()

author.reply_to = channel

author.reply_to = channel.replace('', '')


@powdahound Any hope for an official fix to support robot.messageRoom?

@dajobe I tried your suggested fixes. What are you passing in for room argument? I tried something like this:

robot.messageRoom "", "testing 123"

or just

robot.messageRoom "room-name", "testing 123"
But it throws an exception:

at new JID (.../hubot/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)

Because targetJid seems to be undefined in the creation in bot.js (line 366)



@compressed I don't have time to work on an official fix right now but this is definitely still on my radar.


This is fixed in pull request #60

You can then use robot.messageRoom like so:

robot.messageRoom("", "message");

Published v1.1.4 to npm containing @alexmng's fix above.

@powdahound powdahound closed this Jan 7, 2013
@rileytg rileytg added a commit to rileytg/hubot-hipchat that referenced this issue Sep 7, 2014
@rileytg rileytg Adds robot.messageRoom docs to readme
as per #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment