-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to make a slackbot only respond to DM with itself through the app.message method? #2323
Comments
Hi @lincoln19922, thanks for asking the question.
This situation usually doesn't occur, so it might be something specific to your app. If you're managing a few apps and their bot users communicate with one another (meaning the DMs you mentioned are 1:1 DMs among the bots, with no human interactions), it's possible that both Bot A and Bot B could receive 1:1 DM message events. In this scenario, there's no way to ensure that only one of them (for example, only Bot B) receives the message. If this isn't the case, please provide more details about your apps and how they are operated. |
Hi @seratch , thanks for your answer This is not the case =/ The communications are between a regular user and a bot, but another bot is also able to receive them. This problem may occur due to some access that my bots have that they shouldn't (To test some features I granted excessive permissions). See the permissions section of my app manifest below. "scopes": {
"user": [
"admin.teams:read",
"admin.users:read",
"im:history",
"reactions:read",
"team.billing:read",
"team.preferences:read",
"team:read",
"usergroups:read",
"users.profile:read",
"users:read",
"users:read.email",
"chat:write",
"mpim:read",
"im:read",
"im:write",
"channels:history",
"mpim:history"
],
"bot": [
"app_mentions:read",
"bookmarks:write",
"calls:read",
"calls:write",
"channels:history",
"channels:join",
"channels:manage",
"channels:read",
"chat:write",
"chat:write.customize",
"chat:write.public",
"files:read",
"files:write",
"groups:history",
"groups:read",
"groups:write",
"im:history",
"im:read",
"im:write",
"incoming-webhook",
"links:read",
"links:write",
"mpim:history",
"mpim:read",
"mpim:write",
"pins:read",
"pins:write",
"reactions:read",
"reactions:write",
"reminders:read",
"reminders:write",
"team.billing:read",
"team:read",
"usergroups:read",
"usergroups:write",
"users.profile:read",
"users:read",
"users:read.email",
"users:write",
"workflow.steps:execute",
"conversations.connect:read",
"commands"
]
}
},
"settings": {
"event_subscriptions": {
"user_events": [
"message.channels",
"message.im",
"message.mpim"
],
"bot_events": [
"app_home_opened",
"app_mention",
"message.groups",
"message.im"
]
}, Regarding the applications, each one has its own code and its own bolt object, but both run on the same VM instance. The code to capture the message from both bots is exactly the same as the one I published in the first message. |
@lincoln19922 OK, I figured out the cause. The "message.im" event in "settings.event_subscriptions.user_events" is likely the reason for your situation. Please remove the event subscription from all of your apps. Subscribing to user events means that those apps receive message events for your human account (because you've granted the apps to subscribe to your own message events). This is why you notice that a few apps receive the same message events, even when some of them are not involved in the DM with you. |
Description
I'm having a problem and I don't know how to deal with it.
I have several bots connected to my Slack that perform different actions. However, what these bots have in common is that people should be able to send messages to them via DM (Open a conversation with the bot), and through these messages each bot should be able to perform something.
Today, to read these messages, I have the following code:
The problem I'm facing is that many times the message sent to Bot A is received by Bot B, the message sent to Bot C is received by Bot A, and this way the bot is not able to respond to the message.
My question is, how can I make a bot listen to events of messages received only from its DM, without having to use any words or anything like that. Do you have any ideas?
Reproducible in:
@slack/bolt": "^3.22.0",
node version: v20.13.1
OS version(s): MACOS 14.6.1 (23G93)
Thank you!
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
The text was updated successfully, but these errors were encountered: