Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mentioning users via slack in webhooks

Tags:

python

bots

slack

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.

like image 909
Disciples Avatar asked Nov 25 '17 22:11

Disciples


People also ask

How do I mention someone in Slack API?

Mentioning users in messages The user mentioning syntax <@W123|bronte> is now deprecated and will eventually be removed. Slack will use the "display name" when rendering all mentions. Use the simpler user ID-only form <@W123> instead. Using link_names when posting messages is also deprecated.

What can you do with a Slack webhook?

Message options Incoming webhooks allow you to add context to your messages by attaching helpful content and links. Things like images, websites, or other pieces of data make these messages more useful for your team.

Are Slack webhooks secure?

Webhooks are safe as long as they remain secret since the webhook URL itself is unguessable. We also recommend workspace owners and admins use these best practices for storing credentials safely and that they review this guide to sending messages using incoming webhooks.


1 Answers

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?

like image 155
Achyut Avatar answered Sep 28 '22 12:09

Achyut