Slack chat.postMessage "channel_not_found" error in CI
Slack returns error:"channel_not_found" when the channel argument does not match any conversation visible to the token. A stale ID, a private channel the bot cannot see, or passing a #name where an ID is expected all trigger it.
What this error means
chat.postMessage responds {"ok":false,"error":"channel_not_found"}. The workflow that posted fine yesterday may fail after a channel was renamed or archived.
{"ok":false,"error":"channel_not_found"}Common causes
A private channel the bot is not in
The token cannot resolve a private channel it has not been invited to, so Slack reports the channel as not found rather than forbidden.
A stale or wrong channel identifier
An archived, deleted, or mistyped channel ID (or a #name used where an ID is required) does not resolve.
How to fix it
Resolve the channel ID from the API
- List conversations the token can see and copy the exact ID.
- Use the ID (starting with C, G, or D) rather than a
#namein postMessage. - Invite the bot to private channels so they become visible.
curl -sS "https://slack.com/api/conversations.list?types=public_channel,private_channel" \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" | jq '.channels[] | {id,name}'Store the ID in a secret or variable
Pin the channel ID as a workflow variable so a rename does not break the notify step.
env:
SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}How to prevent it
- Address channels by stable ID, not by name.
- Invite the bot to private channels it must post to.
- Update the stored channel ID when a channel is recreated.