RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.09k stars 10.35k forks source link

Can I use a script to use slack webhooks with rocketchat? #2725

Closed JakeDEvans closed 8 years ago

JakeDEvans commented 8 years ago

Is there a script to take webhooks written for slack (like the one for graylog) and allow them to be used with rocketchat?

out of box doesn't send the message contents. (body missing, but title and icon show up correctly)

Your Rocket.Chat version: 0.24.0

engelgabriel commented 8 years ago

They are design to work out of the box, all that we tested do. Can you see any error on the logs?

JakeDEvans commented 8 years ago

I'm not sure if it's related, but there are a lot of lines with this in the log:

I20160331-16:15:48.996(-4) Exception from sub filteredUsers id NmzMFFXMPfSNXy4pq SyntaxError: Invalid regular expression: /all)/: Unmatched ')'     at new RegExp (<anonymous>)     at [object Object].<anonymous> (server/publications/filteredUsers.coffee:8:12)     at [object Object].<anonymous> (server/lib/debug.js:44:15)     at packages/matb33_collection-hooks/collection-hooks.js:275:1     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)     at [object Object]._handler (packages/matb33_collection-hooks/collection-hooks.js:274:1)     at maybeAuditArgumentChecks (livedata_server.js:1698:12)     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12) 
I20160331-16:15:49.039(-4) Exception from sub filteredUsers id tfSjn2DNZuYQxkd2X SyntaxError: Invalid regular expression: /all)/: Unmatched ')'     at new RegExp (<anonymous>)     at [object Object].<anonymous> (server/publications/filteredUsers.coffee:8:12)     at [object Object].<anonymous> (server/lib/debug.js:44:15)     at packages/matb33_collection-hooks/collection-hooks.js:275:1     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)     at [object Object]._handler (packages/matb33_collection-hooks/collection-hooks.js:274:1)     at maybeAuditArgumentChecks (livedata_server.js:1698:12)     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
engelgabriel commented 8 years ago

Can you change the log level to DEBUG on the admin panel? And can you check if the happen when the web hook is called? What integration are you trying to use so I can test here?

JakeDEvans commented 8 years ago

Sure can, https://github.com/Graylog2/graylog-plugin-slack

JakeDEvans commented 8 years ago

We used ansible to deploy, do you know where those logs are written to file?

JakeDEvans commented 8 years ago

Here you go:

I20160331-18:03:17.697(-4) rocketchat_integrations api.coffee:116 Integrations ➔ Incoming WebHook.debug @bodyParams { '{"link_names":"0","icon_emoji":":space_invader:","channel":"#webops-alerts","text":"*New message in Graylog stream <https://graylog.example.com/streams/streamid/messages?q': '*',   rangetype: 'relative',   relative: '3600|RocketChat Alerts>*:\<br>> this is a test ","parse":"none","username":"Graylog"}' } 
engelgabriel commented 8 years ago

The

*New message in Graylog stream <https://graylog.example.com/streams/streamid/messages?q': '*',  rangetype: 'relative', relative: '3600|RocketChat Alerts>*:\<br>> this is a test 

looks odd. Did you create this content?

JakeDEvans commented 8 years ago

yes and no, I generated the log entry but the plugin created the notification,

Plugins settings:

icon_url: <empty>
graylog2_url: https://graylog.example.com
notify_channel: false
link_names: false
add_attachment: false
webhook_url: https://rocketchat.example.com/hooks/LONGHASHSTRING
color: #00008B
short_mode: false
icon_emoji: :space_invader:
user_name: Graylog
channel: #webops-alerts
JakeDEvans commented 8 years ago

Any ideas?

engelgabriel commented 8 years ago

It looks like the payload is invalid. Does your config works with Slack? Can you hardcode a safe message like "TEST" just to check if the problem is indeed the parsing of the text property of the payload?

engelgabriel commented 8 years ago

@JakeDEvans did you manage to make it work or test with a simpler text? Please reopen if the problem persists.

joschi commented 8 years ago

@engelgabriel I think the parsing of the message payload is broken. The message itself is using valid Slack syntax (and is working with Slack and Mattermost): https://api.slack.com/docs/message-formatting#linking_to_urls

JakeDEvans commented 7 years ago

@joschi we noticed it's working without any changes to the graylog plugin.