Search code examples
slackslack-api

Slack Events API not working for normal users


I'm using slack api to send reply whenever there is any direct message to authenticated user. So I created app, enabled events api and verified webhook url and subscribed to messages.im event

enter image description here

I use regular oauth flow with scope(chat:write:user,users:read) to get the access token.

First I tried with the admin of the workspace and everything worked fine. Whenever there is a direct message between admin user and any other user, i'm receiving events to my callback.

NOW

when I tried same with normal user(user2) i'm not receiving any events back when there is direct message between user2 and some other user. I followed the same steps above.

User2 went through same oauth flow with same scopes and got the access token of his own. As I subscribed to events api, I should be able to received event callbacks to the url I mentioned.

Is there any issue here? Is this not how things work?


Solution

  • Turns out it is an issue with scopes, following is the message I received from slack support team, they are awesome.

    Hi Sasikanth,

    Thanks for getting back to me. I took a look and it seems that there was some change with the scopes requested when user2 installed the "My App Name" app.

    Here are the scopes that each of these users received upon installing the "My App Name":

    user1: im:history,users:read,chat:write:user

    user2: users:read,chat:write:user

    You'll notice that user 1 above has the im:history scope, whereas user 2 above does not. It's mentioned on the doc for the message.im event type (https://api.slack.com/events/message.im) that the im:history scope is needed.

    That's the reason why you're not receiving the message.im event type for DMs sent to user 2.

    I hope that helps to explain the issue. What you'll need to do is remove the authorization for user2 from: (my dev app url) and have that user reinstall the app with the appropriate scopes.