I built a bot for slack. It reads the message when a new user joins and I intend for it to post a message welcoming them: "Welcome @user! What are you building!?"
When it posts @user it doesn't seem as though the actual "tag" is working. Do I need to tag their user ID when I tag people with a bot instead of just using @user?
Use @channel to let everyone in a channel know about timely, relevant information. This will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.
Mention teammates The member(s) will be notified. The member(s) won't be notified, but you'll have the option to invite them to the channel or do nothing. The member(s) won't be notified or allowed to join the conversation.
@everyone notifies every person in the #general channel, @channel notifies all members of a channel, and @here notifies only the active members of a channel. These mentions won't notify people when their notifications are paused, or when they're used in threads.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With