What is the simplest way to find a slack team ID and a channel ID?

后端 未结 9 827
时光取名叫无心
时光取名叫无心 2020-12-07 10:46

We are trying to setup deep linking into slack, as described here:

https://api.slack.com/docs/deep-linking

The document states that to open a specific team,

相关标签:
9条回答
  • 2020-12-07 11:07

    Team ID

    The easiest way to get your team ID is to use the Slack API method auth.test with your access token.

    Channel ID

    Depends on if you want a public or private channel you can call the respective Slack API method to get a list of all channels incl. their IDs.

    • Public channel: channels.list
    • Private channel: groups.list

    Note that you can only see private channels in which the user/bot that belongs to your access token has been invited into.

    Accesss Token

    To get the access token you can either request a "test token" on the Slack API page under "Test Token" (only recommended for testing purposes by Slack). Or you can create a Slack app and install that app for your Slack team using Oath which will also generate an app specific access token.

    0 讨论(0)
  • 2020-12-07 11:08

    Here is the easiest way to manually find the slack IDs

    1. Any channel ID

    Open the slack webpage (http://yourteam.slack.com) and then simply open the channel. The channel ID is displayed in the browser URL:


    2. Any user ID

    To find a user ID you need to open your browser dev-tools console and inspect the user-link in the sidebar. The user ID can be found in the HTML attribute "data-member-id":

    Or in slack: (1) Click on the users name and choose (2) "Show Profile". Then open the "..." menu and you see the option (3) "Copy Member-ID ..." - to get your own user ID via the UI, you have to click the Team-Logo in top-left corner and then choose "Profile & Account" (this is not included in the screenshot)


    3. Team ID

    Simply open the dev-tools of your browser, switch to the "Console" tab and enter the text boot_data.team_id into the console. This will display your team ID:

    0 讨论(0)
  • 2020-12-07 11:10

    The answer marked correct here does not work for me, but I may have found an even easier way with test tokens.

    1. Create a test token: https://api.slack.com/docs/oauth-test-tokens

    2. Scroll down to the "try it now!" button. You land on auth.test: https://api.slack.com/methods/auth.test/test

    3. Choose the team you want to test and click Test Method. You can find your team_id (and user_id) there.

    4. Do the same for channels.list. You can click "View Another Method" and search or go to: https://api.slack.com/methods/channels.list/test

    5. Choose the team again and Test Method. Cmd+F through the channels object looking for whatever channel_ids you need.

    0 讨论(0)
  • 2020-12-07 11:11

    If you are using the Slack app you can simply right click on the channel name in the left menu and click Copy link, paste it somewhere and you will see the channel id.

    0 讨论(0)
  • 2020-12-07 11:12

    As of 2017, it looks like slack made it easier to find.

    Here is the easiest way to manually find the Team IDs.

    Visit your slack room via a web browser. Right Click > "View Source"

    And search for Team_id:

    0 讨论(0)
  • 2020-12-07 11:16

    Slightly different answer to the existing ones.

    Whenever I wanted to just find out quickly what the relevant ids are for a specific team, I just opened the Slack web client and inspected the relevant elements. (Using Chrome Dev Tools)

    https://my.slack.com/messages

    The <a> tag that links to a user tends to include a data-member-id attribute, the content of which is the user id.

    The same holds true for channels. If you inspect any of the channels in the sidebar, you can see they are ordered as <li> list elements each containing the channel id in the class name.

    For the team id, you can open the entire source of the slack web client and CTRL-F for your team_domain (e.g. myslack55 for myslack55.slack.com) and that should find you the team id.

    Basically, it's all hidden in plain sight. You just need to know where to look ;)

    0 讨论(0)
提交回复
热议问题