Search code examples
pythonslackslack-api

How to find workspace name?


How do I find the workspace name from the message using Slack bot for Python? I can find username using the following:

username = message.channel._client.users[message.body['user']]['id']

But I don't know how to find the workspace name.


Solution

  • Actually I was experimenting with the above solution and decided to explore the dictionary that was returned with:

    username = message.channel._client.users[message.body['user']]
    

    It is possible to obtain team id much easier with Slack bot like this (the solution was in plain sight all along):

    username = message.channel._client.users[message.body['user']]['team_id']
    

    But thank you for your assistance, @Erik! :)