Cannot post message to DM or private group
See original GitHub issueDescription
When I call app.client.chat.postMessage
with the channel id of a direct message or private group, I get the error channel_not_found
. I’m confused because my bot is able to post in channels fine. I’ve read through the api for postMessage multiple times but still don’t understand what my problem is. Thanks!
What type of issue is this? (place an x
in one of the [ ]
)
- bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:20 (9 by maintainers)
Top Results From Across the Web
Slack bot cannot post message to private 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...
Read more >Unable to send messages on Facebook | Facebook Help Center
If you see an error message saying “You can't reply to this conversation,” it might be because: A message or something you shared...
Read more >chat.postMessage method - Slack API
This method posts a message to a public channel, private channel, or direct message/IM channel. Consider reviewing our message guidelines, especially if ...
Read more >Why isn't my DM going through? - Discord Support
If your direct message was unable to be sent, you will receive an error message from Clyde that looks something like this:.
Read more >How to Direct Message (DM) on Twitter - Twitter Help Center
Direct Messages are the private side of Twitter. You can use Direct Messages to have private conversations with people about Tweets and other...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey folks I think I can provide some help here.
In the case of slash commands, neither a bot token nor a user token are necessary. From a security point of view, a user invoking a slash command is considered an implicit temporary grant for the app to post a message back to that conversation.
So if your app just wants to send a message to the conversation where the slash command was invoked, there’s no reason to try and get
app.client.chat.postMessage()
to work with the right token. Instead, use therespond()
function, which is passed as an argument to your listener function. Therespond()
function have be used up to 5 times within 30 minutes after the slash command was invoked. Under the hood, it uses theresponse_url
, which is described here: https://api.slack.com/interactivity/handling#message_responses. It’s also alluded to in the Bolt for JS docs , but maybe a complete example would be more helpful:For completeness, I should probably also mention that if you can come up with a response immediately (without calling some other async operation) then you should just use that as the argument for
await ack()
, as I’ve done above with “One moment please…”.@securisec unfortunately it seems that this action isn’t possible anymore with the new apps. with a legacy slack app this was possible, but as of a few months ago you have to use version 2 of slack’s oauth. it’s sort of unbelievable that the new version of slack apps leave this function out :–(