7

I have the following code which returns me the following error. The error says channel not found, howerver I am following the docs for a private channel to either use the name of the channel or to use the string that is in the url with a G at the beginning. I have given the correct chat write permissions to the bot for the channel and am using the correct bot api generated toekn, I was able to post via webhook before but I want to use the web-api.

This is the docs I am referring to https://api.slack.com/methods/chat.postMessage#channels

const { WebClient } = require('@slack/web-api');
const token = process.env.SLACK_BOT_TOKEN;
const web = new WebClient(token);

const conversationId = 'private-channel-name'; & tried this instead 'GCV2FGELX'

    const result = await web.chat.postMessage({
        text: 'Hello world!',
        channel: conversationId,
    });

This is the error response I am getting

{
  code: 'slack_webapi_platform_error',
  data: {
    ok: false,
    error: 'channel_not_found',
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  }
}

I'm not quite sure what I am doing wrong, but doing a little digging, even when I try to use the tester get request for groups.list here https://api.slack.com/methods/groups.list/test with a auth token with the correct permissions I just get a empty response back, vs a list of groups. Not sure here.

I did note that it said this Post into any channel it has access to for what the bot can do how do I know what channel's the bot has access to. I have given it write permissions to my whole orginization?

any help would be appreciated

Anders Kitson
  • 1,413
  • 6
  • 38
  • 98
  • 1
    Did you trying adding the BOT to the private channel as an APP (You find this under the Channel Details >> More >> Add Apps. Hope that will solve your issue. – Anumoy Sutradhar May 06 '20 at 13:58

2 Answers2

26

I too had faced the same issue.

Did you trying adding the BOT/APP to the private channel (You find this under the Channel Details >> More >> Add Apps.

Slack Channel Detail Screen Shot

Once you have added your BOT/APP to the channel. Your messages will be getting posted into the channel.

Hope this will solve your issue.

Anumoy Sutradhar
  • 523
  • 5
  • 11
7

Still ran into this in 2022 with slack bolt.

The error slack_webapi_platform_error with error channel_not_found seems to mean that there is no ACCESS to this channel because app needs to be specifically added to this private channel. Thanks @Anumoy Sutradhar

Here a newer screenshot (not possible to add in comments): enter image description here

The modal opens when you click on the channel name.

CodingYourLife
  • 7,172
  • 5
  • 55
  • 69