1

Typing in my custom slack bot command to add johndoe to a group

"/myslashcommand add @johndoe"

translates in my terminal to the following when printing the request.form['txt']:

add @john.doe

From this how do I get the user ID of johndoe? Or how do I get the user ID of someone in general when someone runs the command to add the display name of a user?

From this Slack post, it seems like the format should be:

/myslashcommand add <@UAZERRANR|john.doe>

How do I get the User ID when someone mentions them in the chat for my slack bot?

Adil B
  • 14,635
  • 11
  • 60
  • 78
MMM
  • 315
  • 1
  • 6
  • 19

1 Answers1

0

From the same blog post: call the users.list method to map user display names to User IDs. You'll need to consume the entire list, so you'll want to cache the mappings somewhere for your app to read and update.

Adil B
  • 14,635
  • 11
  • 60
  • 78