45

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?

fontebot tried tagging cristopher.bello but the tag didn't work

Dave Fontenot
  • 621
  • 2
  • 7
  • 10

2 Answers2

58

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.

Matthieu
  • 1,149
  • 7
  • 11
7

Can you try adding "parse"="full" and "link_names"=1 to parameters? For a quick test, you can use their tester chat.postMessage

hussachai
  • 4,322
  • 2
  • 16
  • 17
  • When using the tester you recommended, it tagged the user even without "link_names=1". When I used "parse"="full" it didn't tag the user and left the ID. This leads me to believe it's something to do with the [node wrapper](https://github.com/slackhq/node-slack-client) I'm using. – Dave Fontenot Sep 06 '15 at 04:37