What is the correct way to add a reaction to a heard message?
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
hubot-slack version: 4.5.4
node version: 8.11.3
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?
@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
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/clientin your app in order to get this to work. the problem is that there's an older version of@slack/clientavailable to node sincehubot-slackdepends on it, but the latest version is what you want to use. let me know if that fixes the issue 馃槃