How do you tag people with a slack bot?

The correct format is <@userID>

You will simply get the user ID from the event (in your screenshot, the channel_join event)

{
    "type": "message",
    "subtype": "channel_join",
    "ts": "1358877458.000011",
    "user": "U2147483828",
    "text": "<@U2147483828|cal> has joined the channel"
}

Update:
(I have not checked the solution proposed in the edit)

In the new Bolt SDK you can tag user by using the brackets around the @NameOfUser. So the example above could also be:

{
    "type": "message",
    "subtype": "channel_join",
    "ts": "1358877458.000011",
    "user": "U214####",
    "text": "<@NameOfUser> has joined the channel"
}

You would need to parse the @Name out of the message of course.

Leave a Comment