How to Fix the Issue Where @username Mentions Don't Notify in Slack API
I’ll introduce how to solve the issue where @username mentions don’t notify when using the Slack API.
The background of the issue where Slack @username doesn’t notify was due to a Slack API specification change.
When evaluating messages to determine if your user or bot user is mentioned, look for a user ID, not a username.
Due to the Slack API specification change, you should use @userID instead of @username.
You can check a list of @userID and @username from https://api.slack.com/methods/users.list/test.
slack.com/api/users.list response excerpt
{
"ok": true,
"members": [
{
"id": "UH3FW2ELW",
"team_id": "T3491U6E5",
"name": "youremail",
"deleted": false,
"color": "e7392d",
"real_name": "Firstname Lastname",
"tz": "Asia\\/Tokyo",
"tz_label": "Japan Standard Time",
"tz_offset": 32400,
"profile": {
"title": "",
"phone": "",
"skype": "",
"real_name": "Firstname Lastname",
"real_name_normalized": "Firstname Lastname",
"display_name": "changedname",
"display_name_normalized": "changedname",
"status_text": "",
“id”: “UH3FW2ELW” is the value corresponding to @userID. It’s automatically generated.
“name”: “youremail” is the value corresponding to @username. The value specified as Display Name during invitation is used. If no Display Name is set, the part before @ in the Email Address is used. It cannot be changed after registration.
Since @userID has poor visibility in source code, I personally choose to use @username. In the example above, @userID is @UH3FW2ELW and @username is @youremail.
Like “id”, the “name” part also won’t change after initial registration.
Even if you change the display name after registration, only “display_name” and “display_name_normalized” change, while “name” remains the same.
That’s all from the Gemba on wanting to improve productivity by making @username mentions work via Slack API.