Using @-mention in integration message

Hi,

I am using a sentry integration to receive log messages from a custom application in a separate channel. Now I wanted to use the rocket chat notification system to be notified if there is a critical issue with this app. So I simply added an @all-mention to the message text if the logged error is marked as ciritical. Unfortunately the mention mechanism doesn’t seem to work in integration messages. My tests showed:

  • mention in message text: no message is printed to the channel

  • mention in attachment title: message is generated, mention is not highlighted, mention is not respected (no notification is sent to users)

  • mention in attachment text: message is generated, mention ist highlighted but mention is still not trigger any notifications

As I am a new user, I can’t post the an screenshot of this (only one image per post), but you can imagine how this might look.

Maybe somebody had the same issue but I couldn’t find a related topic in this forum. So any help is appreciated.

Best regards,

Michael

I can confirm. I’ve seen same from messages from grafana.

We don’t parse all sections for mentions I believe just the message text. If it’s as attachment we ignore.

Partly because we use attachments in replys and message quoting too

That is interesting. I tried to use @all in the message text property but it didn’t render then. Could you please post the code of the grafana-integration?

Grafana uses the slack compatible webhook.

If you can show the payload you are sending to the webhook I can see a bit better what’s happening.

I thought the rendering of the message in the rocket.chat channel only depends on the message object returned by the integration and therefore only indirectly on the object sent via the webhook. The current code of the message object is:

    return {
    content: {
      attachments: [
		{
  		"title": request.content.message,
  		"title_link": request.content.url,
  		"text": message,
  		"color": message_color
		}
	  ]
   }
};

I already described the behaviour if “title” or “text” contain a mention. I also tried to place a mention in the “text”-property of the message itself (outside the “attachments” object), but then no message is printed at all.

Just wanted to confirm I understood what you were doing. But yes. If inside attachments at all… it will not capture the mention. Its ignored.

You would need to do something like:

return {
    content: {
      text: "hey @-User!  Something broke!",
      attachments: [
		{
  		"title": request.content.message,
  		"title_link": request.content.url,
  		"text": "Details of what actually broke",
  		"color": message_color
		}
	  ]
   }
};

What @aaron.ogle said is correct, mentions do not work when inside of the attachments property of a message. However using what Aaron showed will work.

Nope, not working, as described in the first point of my first post. A simple example:

Working:

return {
  content: {
    text: "Without any  mention",
    attachments: [
      {
        "title": "title",
        "title_link": "www.google.de",
        "text": "Details of what actually broke",
        "color": "#b30000"
      }
    ]
  }
};

NOT Working (meaning no message is rendered at all):

return {
      content: {
        text: "hey @username! Something broke! @all @here @channel",
        attachments: [
          {
            "title": "title",
            "title_link": "www.google.de",
            "text": "Details of what actually broke",
            "color": "#b30000"
          }
        ]
      }
	};

Can you check your logs and see if there is an error? Usually if it is considered broke, there is an error in the logs associated with it not working…

Unfortunately there are no log-entries with the exception of the incoming message object, which is currently ignored.

And you’re using an incoming or outgoing integration?

it’s an incoming integration. But the problem is totally independent of the incoming message, you should be able to reproduce the issue with the following script inside an incoming webhook integration:

class Script {
  process_incoming_request({ request }) {
    return {
      content: {
        text: "hey @username! Something broke! @all @here @channel",
        attachments: [{
          "title": "title",
          "title_link": "www.google.de",
          "text": "Details of what actually broke",
          "color": "#b30000"
        }]
      }
    };
  }
}

Okay. Yes, I just wanted to know if it was an incoming or outgoing type so I could try to reproduce it in an attempt to fix it.

I was having this exact issue. Turns out that the user I was using for my integration didn’t have permission to @ mention the @all group. Once I granted my user the @mention privilege it worked just fine. Not sure if that’s your issue, but it solved it for me :slight_smile:

2 Likes