Slack chat.postMessage "not_in_channel" error in CI
The Slack Web API returns ok:false with error:"not_in_channel" when a bot token calls chat.postMessage for a channel the bot has not joined. Posting with a bot token requires the bot to be a member of that channel (public channels included).
What this error means
The notify step calls chat.postMessage and Slack responds HTTP 200 with a JSON body {"ok":false,"error":"not_in_channel"}. No message appears in the channel.
{"ok":false,"error":"not_in_channel"}Common causes
The bot was never invited to the channel
Unlike incoming webhooks, chat.postMessage with a bot token only works in channels the bot has joined. A new channel or a renamed one leaves the bot outside.
The channel ID points to a different channel
A hard-coded channel ID that was archived or recreated no longer matches a channel the bot is in.
How to fix it
Invite the bot to the channel
- Open the target Slack channel.
- Run
/invite @your-bot-nameso the bot becomes a member. - Re-run the notify step; postMessage now succeeds.
/invite @ci-botJoin programmatically for public channels
A bot with channels:join can add itself to a public channel before posting.
curl -sS -X POST https://slack.com/api/conversations.join \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H 'Content-type: application/json; charset=utf-8' \
--data '{"channel":"C0123456789"}'How to prevent it
- Invite the CI bot to every channel it must post to, before wiring the workflow.
- Reference channels by stable ID and keep an eye on archives/recreations.
- Grant
channels:joinif the bot should self-add to public channels.