PGT
PGT

Reputation: 2019

Slack API - Don't notify user when parsing user id

In this message formatting doc: https://api.slack.com/docs/message-formatting, you can use special control sequence characters < and > to perform server-side parsing (server-side as in Slack API's server-side).

So using <@U024BE7LH> in your chat.postMessage() call will get parsed to something like @bob or whatever the username associated with that ID is, in the actual text that shows up in slack.

Unfortunately, this will cause a notification for the person you're referring to. How do I make it so that it doesn't notify the person? I've tried to enclose in a code block, i.e.:

`<@U024BE7LH>`

or

```
<@U024BE7LH>
```

But it still pings. I'm thinking the only way is to get a list of users and parse the name from the ID.

Upvotes: 2

Views: 570

Answers (1)

Andrew
Andrew

Reputation: 6860

According to this, backticks should work but empirically it hasn't for me. The Slack employee says to just convert the user ID to their name and use that without the templating.

https://forums.slackcommunity.com/s/question/0D73a000005n0OXCAY/detail?language=en_US&fromEmail=1&s1oid=00Dj0000001q028&s1nid=0DB3a000000fxl3&s1uid=0053a00000Ry9cX&s1ext=0&emkind=chatterCommentNotification&emtm=1667894666436&emvtk=fH.W2M01lq9W1cf31RSROPwB7LYs.och8RgbVTqoNlg%3D&t=1667931570045

Upvotes: 2

Related Questions