Can I use the @ mention function in Slack notifications?

I’m sending a notification to a channel in Slack and I would like to @ mention a user in the message. How can I do this?

You can. Slack outlines it here, but all you just have to use the format <@U024BE7LH> with the user id of the person you want to mention.

Here’s an example passing the user id as a variable

Using Courier Python SDK

from trycourier import Courier
from trycourier.exceptions import CourierAPIException
client = Courier()
recipient = "CHANNEL_SUPPORT"
profile = {
    'slack': {
        'access_token': 'xoxb-xxxxx',
        'channel': 'CLTLZTSV6'
    }
}
data = {
    'slackUser': 'U013YKVA9B4'
}
try:
    resp = client.send(event="SLACK_MENTION",
                       recipient=recipient,
                       profile=profile,
                       data=data)
    print(resp['messageId'])
except CourierAPIException as err:
    print(err.message)

Courier Text Block:

Hey <@{slackUser}>, I'm testing mentions using Courier.