Search code examples
botsslackslack-api

How do I know Slack bot's user_id?


I'm making a slack bot (A) that responses to a message from another slack bot (incoming-webhook) (B). I'd like to know the user_id of B so that its message will be a trigger for A, where I have some problem getting it.

I tried users.list method (https://slack.com/api/users.list?token=blabla) but the B didn't appear in a result. Do you have an idea about what method to take to know the user_id of B?


Solution

  • Incoming webhooks appear as apps, not as bot users on Slack. So you won't find a bot user ID in the user list as you would for normal bot users.

    Apps have a bot ID, but unfortunately there is no official API method to get the list of bots / apps in a workspace. But if you have control over a workspace and can generate a legacy token you can use the unofficial API method bots.list.

    There also is the official bots.info method, if you already have the bot ID and just want to know which app it belongs to.

    To create a legacy token for your workspace make sure you are logged in and then go to this page.