Hubot-slack: What is the correct way to add a reaction to a heard message?

Created on 17 Sep 2018  路  2Comments  路  Source: slackapi/hubot-slack

Description

What is the correct way to add a reaction to a heard message?

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [x] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Question

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

hubot-slack version: 4.5.4

node version: 8.11.3

Question

I was attempting to follow the example in the documentation here: https://slackapi.github.io/hubot-slack/basic_usage#message-reactions which seems to use the WebClient to add a reaction. Rather than responding to a reaction like that example does, I'm trying to respond to a message.
Here is the code I have so far:

{WebClient} = require "@slack/client"

module.exports = (robot) ->
    if robot.adapter.options && robot.adapter.options.token
        web = new WebClient robot.adapter.options.token

        robot.hear /Monitor is DOWN/i, (msg) ->
            robot.logger.info "attempting to react. name:'serverdown', channel: #{msg.message.rawMessage.channel}, timestamp: #{msg.message.rawMessage.ts}"
            web.reactions.add
                name: 'serverdown',
                channel: "#{msg.message.rawMessage.channel}",
                timestamp: "#{msg.message.rawMessage.ts}"

But I keep getting errors like the following:

error: Response not OK:  invalid_array_arg
Unhandled rejection Error: invalid_array_arg

Am I doing something wrong, or is there a bug here?

question

Most helpful comment

@deathau: the code you're using looks correct to me, but there's one gotcha that's actually noted in this section: https://slackapi.github.io/hubot-slack/basic_usage#using-the-slack-web-api. that is, you should npm install @slack/client in your app in order to get this to work. the problem is that there's an older version of @slack/client available to node since hubot-slack depends on it, but the latest version is what you want to use. let me know if that fixes the issue 馃槃

All 2 comments

@deathau: the code you're using looks correct to me, but there's one gotcha that's actually noted in this section: https://slackapi.github.io/hubot-slack/basic_usage#using-the-slack-web-api. that is, you should npm install @slack/client in your app in order to get this to work. the problem is that there's an older version of @slack/client available to node since hubot-slack depends on it, but the latest version is what you want to use. let me know if that fixes the issue 馃槃

Awesome, must have missed that in the docs. Thanks for not just providing the solution, but explaining why

Was this page helpful?
0 / 5 - 0 ratings