'Slack bot cannot post message to private channel
I follow Slack bot post message documents
it works perfectly when post to public channel, but get error [error] => channel_not_found when post to private channel, I even change channel_name to channel ID (ex: G1HCG4BQ9)
I already authorized with both chat:write:user and chat:write:bot permissions
Solution 1:[1]
Did you invite the bot to the channel? A bot can't post in a private channel if it's not a member - you need to invite it to the channel like you would a person.
@YourBotsName will do it!
Solution 2:[2]
I ran into this same issue and was able to solve it by using chat.postEphemeral with the OAuth Access Token available in the OAuth & Permissions page of your app configuration, which should be accessible at https://api.slack.com/apps/APP-ID-GOES-HERE/oauth
Note that there are two different token types, the OAuth Access Token and Bot User OAuth Access Token. When I tried using the Bot User OAuth Access Token to send an ephemeral message to a user while they were in a private chat with another user, I received the same error message as you: channel_not_found, however, it worked properly when using the OAuth Access Token.
See here for details regarding the different token types.
Solution 3:[3]
I had the same issue. You need to add your bot manually in the private channel with the slack command invite
/invite @yourBotName
Don't forgot to add OAuthS Scope chat:write from Features/OAuth & Permissions
Solution 4:[4]
i had the same issue. for getting a message in private channel you just need to manually add your app there 
Solution 5:[5]
Sam Mullin answer is correct, it's the first point you need to look at.
But for me even that didn't work out. I didn't consider incoming webhook(https://api.slack.com/messaging/webhooks), because that's also an option, but not in my case.
The thing that got me progressing is that slack has "Tester" tab for testing requests in its api method f.e. https://api.slack.com/methods/chat.postMessage/test. When you fill out the data and submit, the request you see in url also consists "token" and "pretty" arguments. I've added token argument only to authorization header, which didn't work for me, so I've added it also as param. For pretty argument I set same as text message.
I'm not sure about security issues, when passing token directly,somebody could correct me on that. But that's a variant that worked out for me.
Solution 6:[6]
I had the same problem today, you have to add the app to the desired private channel manually.
Solution 7:[7]
Try setting explicitly as_user: false and using the team access token instead of the bot user's one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sam Mullin |
| Solution 2 | adamc |
| Solution 3 | Demont Zhang |
| Solution 4 | prashant isotiya |
| Solution 5 | Oleksandr Verhun |
| Solution 6 | Kévin Berthommier |
| Solution 7 | Alex Ramirez |
