Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 of 9 tasks
deathau opened this issue Sep 16, 2018 · 2 comments
Closed
4 of 9 tasks

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

deathau opened this issue Sep 16, 2018 · 2 comments
Labels
question M-T: User needs support to use the project

Comments

@deathau
Copy link

deathau commented Sep 16, 2018

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)
  • question
  • documentation related
  • testing related
  • discussion

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

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • 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?

@aoberoi
Copy link
Contributor

aoberoi commented Oct 1, 2018

@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 😄

@aoberoi aoberoi added question M-T: User needs support to use the project needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info labels Oct 1, 2018
@deathau
Copy link
Author

deathau commented Oct 1, 2018

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

@deathau deathau closed this as completed Oct 1, 2018
@aoberoi aoberoi removed the needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info label Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants