Maxwell
Maxwell

Reputation: 13

How do I use send/topic from within a robot.router.post block in hubot

I've been hacking away with hubot for a few weeks now and loving it but have been stuck for a couple of days on the code snippet below. I have a listener that is receiving events via webhooks from our ticket system. That's working great! The problem I'm having is how do I then send some of this data to a room and update the topic?

Normally this is done via the msg.send or msg.topic callback that is sent with functions such as robot.respond but when using robot.router.post, I'm not clear on what object I should be referencing to send the message. Basically, how/where do I get msg defined within robot.router.post?

Apologies for newbness, I'm pretty new to all things javascript/coffeescript. Thanks!

module.exports = (robot) ->

  robot.router.post "/hubot/ticket_change", (req, res) ->
    ticket_info = req.body.issue.name + ": " + req.body.issue.summary
    robot.send ticket_info
    robot.topic ticket_info

Upvotes: 1

Views: 579

Answers (1)

Mez
Mez

Reputation: 24953

room = <room id>
robot.messageRoom room, ticket_info

Upvotes: 2

Related Questions