Suhas
Suhas

Reputation: 8438

How do I receive only the messages that are direct messages to my bot user?

I have successfully setup my slack bot app, have enabled events etc. I want to receive any direct messages that the members of my slack team send to my bot. For this, I have only enabled Bot Events and No Team Events like below

enter image description here

However, I do not get any event on my webhook on this setting.

If I enable message.im event under Team Events, then I start getting events. But then, I get every message that the user (who has installed the app) sends to any other user in the team.

How do I get only the messages that are sent to my bot user?

Update 1

Based on this SO question I created a private channel with the bot user. Even then, the messages in the private channel do not arrive in my webhook with the above event subscriptions.

Update 2

After reinstalling the app, it seems to be working fine. I have only used it for few minutes after the reinstall so far. I will keep posting here how it goes. It would still be interesting to know what went wrong where.

Upvotes: 1

Views: 1142

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32698

It is normal behavior that your script receives all messages (for every channel your bot is a member of), not only the messages sent directly to your bot. At this time you can not filter further in the event configuration. So you need to filter out any unwanted message in your script handling the event.

See also this answer.

Upvotes: 1

Related Questions