Slack: Where / How to get Slack Channel ID
The simplest way to get Slack Channel ID
Intro
To post message to Slack, the one of preferred and simplest ways might be “Incoming Webhooks”.
When posting a message to Slack Channel by “Incoming Webhooks”, all you need is “webhook URL”. The each webhook URL is already tied to a specific channel for the “Incoming Webhooks”
Three ways of posting message to Slack Channel
- Incoming Webhooks without a Slack App
- Incoming Webhooks in a Slack App
- Slack App ( chat.PostMessage API )
You can find ways to setup “Incoming Webhooks” below.
chat.PostMessage API requires Channel ID
First of all, chat.PostMessage doesn’t use “webhook URL”. Instead, chat.PostMessage uses these two token types.
- BOT token
- User token
One benefit of using chat.PostMessage is that it can post message any JOINED channels. This is one of big difference from “Incoming Webhooks”.
When posting message to Slack channel with “chat.PostMessage”, the channel ID is required.
How / Where to find Slack Channel ID
- Go to Channel > View Channel Details
- At the bottom of “About” tab, you can find Channel ID.
UPDATE: 2022–07–26
It seems the channel name can be also used as well, for example “#general”
If you’re looking for Channel ID because Slack doc says it is required, then please trey with the channel name as well.