Search code examples
javascripthubothipchat

Make Hubot send a direct message in HipChat


How do I tell Hubot to send a direct message using the HipChat adapter? I've tried many different options without success.

module.exports = function (robot) {
  robot.respond(/hi/i, function (msg) {
    msg.send(msg.message.user.room, 'hi'); // outputs to current room
    msg.send(msg.message.user.id, 'hi'); // outputs to current room
    msg.send(msg.message.user, 'hi'); // outputs to current room
    msg.reply('hi'); // @mentions the user in the current room
    msg.reply_to('hi') // no reply_to method though I thought I saw this somewhere
  });
};

Solution

  • It took me awhile to find it, but it turns out this works:

    module.exports = function (robot) {
      robot.respond(/hi/i, function (msg) {
        robot.send({
          user: msg.message.user.jid
        }, 'hi');
      });
    };