user22028978
user22028978

Reputation: 11

Slack App not able to post DM messages to user even after calling conversations.open

I am hoping I'll get some help/pointers on the Slack App related issue I am facing.

I am working on a Slack app that introduces slash commands to start different workflows. It has been working fine in my own workspace but when I installed it into another workspace, bot is not able to postMessage to user as a DM. I have tried calling conversations.open to get the channel id and then call postMessage but I keep getting "channel_not_found" error.

Bot and User Scopes for my app are:

user:

One simple test I reproduce this error is-- App introduces slash command which is suppose to spit out help information about available commands. When the bot tries to post that information back to the user, it fails. For this specific use case I can use response_url to reply back but I have other slack commands where I need to have a back and forth with the user.

For testing purposes, I tried using user token instead of bot token while calling postMessage. it works but it is not practical because it looks like user is talking to themselves because every message shows up as if user posted it.

I have seen other apps (for example: geekbot) successfully implementing similar workflow but I am not able to figure out what I am missing.

Has anybody come across this issue?

Upvotes: 1

Views: 738

Answers (1)

Taylor Singletary
Taylor Singletary

Reputation: 2296

Based on the information you've provided, it sounds like you are maybe using the token for Workspace A when calling APIs impacting Workspace B. At installation time for the second workspace, you were returned a unique bot token. When your app receives a slash command execution from each workspace, you need to reflect on which token to select for any following API calls. When the workspace is workspace B, select that token instead when calling chat.postMessage.

You can also skip the conversations.open step and just use the user's ID for the channel value in the message you're posting. This only works for posting the message and not for any subsequent updates.

Upvotes: 0

Related Questions