Hi all,
This might sound like an odd request but we’re running in to a bit of trouble getting Rocket.Chat to send a message in its entirety via a webhook to Slack.
Just a little background on the logic behind this and without going in to too much detail:
- We have a script that collects the status of servers that are running in an air gapped manner (no access to the internet)
- The idea is to have the big important messages in the
text
including server status and important issues with the smaller/more numerous issues grouped in thefields
since it is more flexible with formatting
- The idea is to have the big important messages in the
- The script creates a message with the status and sends it to one of our Rocket.Chat instances via a webhook to a channel for notifications
- Rocket.chat then sends the messages that arrive in that notification channel to Slack via an outgoing webhook
Script generates this json which is sent to Rocket.Chat:
{
"username": "Morning Message Update",
"attachments": [
{
"fields": [
{
"value": "Server 1, server 2",
"title": "These hosts are down"
}
],
"text": "**1** critical messages.",
"fallback": "There are 1 critical messages. You may need to have embeds turned on to view them",
"mrkdwn_in": [
"text"
],
"color": "#d03ae8",
"title": "In house applications"
}
],
"icon_emoji": ":sunrise:",
"text": "Hello!"
}
Screenshot of what appears in Slack, first from Rocket.Chat then me manually sending the above json file (as a sanity check):
Looking through the logs I can see that the message is received alright (albeit with the fields
section truncated):
I20220304-15:33:55.416(0) server.js:204 Integrations ➔ Incoming WebHook.debug @bodyParams: { username: 'Morning Message Update', attachments: [ { fields: [Array], text: '**1** critical messages.', fallback: 'There are 1 critical messages. You may need to have embeds turned on to view them', mrkdwn_in: [Array], color: '#d03ae8', title: 'In house applications' } ], icon_emoji: ':sunrise:', text: 'Hello!' }
Then when the outgoing webhook process is started (some identifying information removed):
I20220304-15:33:55.438(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Got the event arguments for the event: sendMessage { event: 'sendMessage', message: { alias: 'Morning Message Update', msg: 'Hello!', attachments: [ [Object] ], parseUrls: false, bot: { i: '!removed!' }, groupable: false, tmid: undefined, emoji: ':sunrise:', ts: 2022-03-04T15:33:55.421Z, u: { _id: 'rocket.cat', username: 'rocket.cat', name: 'Rocket.Cat' }, rid: '!removed!', mentions: [], channels: [], md: [ [Object] ], _updatedAt: 2022-03-04T15:33:55.430Z, _id: '!removed!' }, room: { _id: '!removed!', fname: '!removed!', customFields: {}, description: '', broadcast: false, encrypted: false, name: '!removed!', t: 'p', msgs: -192, usersCount: 4, u: { _id: '!removed!', username: '!removed!' }, ts: 2022-03-04T11:02:14.417Z, ro: false, _updatedAt: 2022-03-04T15:04:09.451Z, lm: 2022-03-04T15:04:09.437Z, lastMessage: { alias: 'Morning Message Update', msg: 'Hello!', attachments: [Array], parseUrls: false, bot: [Object], groupable: false, emoji: ':sunrise:', ts: 2022-03-04T15:04:09.437Z, u: [Object], rid: '!removed!', mentions: [], channels: [], md: [Array], _updatedAt: 2022-03-04T15:04:09.447Z, _id: '!removed!' } } }
The only thing I can see that’s different is has been changed to truncated down to simply attachments: [Array]
but I’m assuming it’s still containing the full message text for now. But then it seems to strip the message of all its attachments
except text
:
I20220304-15:33:55.439(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: !removed!
I20220304-15:33:55.439(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Found 1 to iterate over and see if the match the event.
I20220304-15:33:55.440(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Is "!removed!" enabled, true, and what is the event? sendMessage
I20220304-15:33:55.440(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Starting to execute trigger: !removed! (!removed!)
I20220304-15:33:55.443(0) server.js:204 Callbacks ➔ debug Executing callback with id emojione-shortnameToUnicode for hook beforeSendMessageNotifications
I20220304-15:33:55.448(0) server.js:204 Integrations ➔ Outgoing WebHook.info Will be executing the Integration "!removed!" to the url: https://hooks.slack.com/services/!removed!
I20220304-15:33:55.449(0) server.js:204 Integrations ➔ Outgoing WebHook.debug { token: '!removed!', bot: { i: '!removed!' }, channel_id: '!removed!', channel_name: '!removed!', message_id: '!removed!', timestamp: 2022-03-04T15:33:55.421Z, user_id: 'rocket.cat', user_name: 'rocket.cat', text: 'Hello!', siteUrl: '!removed!', alias: 'Morning Message Update' }
I20220304-15:33:55.452(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.454(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.455(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.455(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.599(0) server.js:204 Integrations ➔ Outgoing WebHook.info Status code for the Integration platform-testing-2 to https://hooks.slack.com/services/!removed! is 200
So my understanding is that Rocket.Chat is sending just the body of the message rather than the body and the attachment. My question is what is the best way to prevent this from happening and to allow the full message with attachments through the Rocket.Chat webhook to Slack
Thank you and all the best!
Server Setup Information
- Version of Rocket.Chat Server: 3.18.2
- Operating System: Redhat Linux
- Deployment Method: docker
- Number of Running Instances:
- DB Replicaset Oplog:
- NodeJS Version: v12.22.1
- MongoDB Version: 4.0.2
- Proxy:
- Firewalls involved: Yes