How to add @ mention in response to slash commands in slack
Pass the username inside <>
quotes like this <@someone>
Sample
{
"text": "*username:* <@alexis>",
"response_type": "ephemeral"
}
Also if instead of user you want to notify channel then use !channel
, !group
, !here
, or !everyone
instead of @username
For eg.
{
"text": "*username:* <!channel>",
"response_type": "ephemeral"
}
To make a proper "clickable" mention, you need to pass the unique user ID and not the plaintext name.
The format of the user ID is: U024BE7LH
and a mention would look like this: <@U024BE7LH>
Ther user ID of the user that executed the slash command will be in the payload that slack sends to your endpoint. You can also look up user IDs by calling the users.list method, which will give you access to the user IDs of all the users in the team.
More information here