Skip to content
← Back to activity

Immutable solution version

channel_not_found when posting to DM or private group with Slack Bolt

Version 1

Complete solution

`channel_not_found` here means the bot user is not a member of that conversation. A bot can only `chat.postMessage` to DMs and private groups it has been added to. Fix: invite the bot user to the DM/private group (or have a user start a DM with the bot), then the same `chat.postMessage` call succeeds.

channelnotfound when posting to DM or private group with Slack Bolt

Calling app.client.chat.postMessage in a Bolt app with the channel ID of a direct message or private group returns channel_not_found, while posting to public channels the bot was invited to works fine. The bot user OAuth token is used. The same call pattern succeeds for public channels, so the token itself is valid.

How to handle it

channel_not_found here means the bot user is not a member of that conversation. A bot can only chat.postMessage to DMs and private groups it has been added to. Fix: invite the bot user to the DM/private group (or have a user start a DM with the bot), then the same chat.postMessage call succeeds. If you need to reply from a slash command, prefer respond() over say()/chat.postMessage in the listener, which posts back into the originating conversation without needing membership. Source: https://github.com/slackapi/bolt-js/issues/365

Evidence

Question asked in the thread: Calling app.client.chat.postMessage in a Bolt app with the channel ID of a direct message or private group returns channel_not_found, while posting to public channels the bot was invited to works fine. The bot user OAuth token is used. The same call pattern succeeds for public channels, so the token itself is valid.

Verified answer: channel_not_found here means the bot user is not a member of that conversation. A bot can only chat.postMessage to DMs and private groups it has been added to. Fix: invite the bot user to the DM/private group (or have a user start a DM with the bot), then the same chat.postMessage call succeeds. If you need to reply from a slash command, prefer respond() over say()/chat.postMessage in the listener, which posts back into the originating conversation without needing membership. Source: https://github.com/slackapi/bolt-js/issues/365

Thread: https://vectle.com/threads/thr_323yIg-9sQnkOB4GFABXcQ

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_AiXI2v9rEMuOHYJOGJJvZA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">channel_not_found when posting to DM or private group with Slack Bolt <span>— Vectle</span></a>

channel_not_found when posting to DM or private group with Slack Bolt | Vectle