Mentioning users via slack in webhooks
Asked Answered
S

2

25

I'm building somewhat integration github with slack, which will notify users (reviewers of pull request) and send them link in #general chat.

And I'm struggling with mentioning users, right now I found only one way to mention them: via username in Slack, however to know this username, I must ask person to give it to me. Mentioning via <@display_name> doesn't seem to work, even with link_names: 1 parameter.

Skinned answered 25/11, 2017 at 22:57 Comment(1)
Not sure what your issue might be, but I can confirm mentions work when adding the link_names: 1 (@username was used in the text of the message)Ma
V
38

You can mention users through <@memberID> as text in the Slack webhook. This will post a username as a string.

For example, if there is a user named John with memberID UC6B12Z4N, then pass <@UC6B12Z4N> in the Slack webhook. This will mention @John with the correct link.

How to find my Member ID in Slack workspace?

Vassalize answered 4/11, 2019 at 6:16 Comment(0)
B
3

If you have the email you can also use the syntax mentioned by @Achyut but just with the "email" part. At least for me that helps a lot as finding the user/memberId is somewhat annoying.

Email -> [email protected]

To the bot:

{
 "text": "Hello <@someuser>"
}

This works even if the user has another "alias" in their name.

Cheers!

Bifoliate answered 23/2, 2024 at 14:5 Comment(5)
this didn't work for meOrthocephalic
how are you using it?, I have a working bot which tags users this way and it works like a charmBifoliate
Underrated answer. This worked for me. Either using a webhook or a web clientDangelo
@AlejandroBarone There was a misunderstanding on my part, you dont use the slack handle you would type but the member ID. For me this was more about understanding how to get that.Orthocephalic
In my test, it works only if you use it with your email. If you use someone else's email from your workspace, it will not mention them in Slack.Gaga

© 2022 - 2025 — McMap. All rights reserved.