Search code examples
slackslack-api

Slack App API - Can I subscribe to and monitor all @username mentions for the current user?


When someone mentions a specific username by their handle in Slack, the user typically gets notified about that mention by Slack. I would like to make a Slack app that subscribes to those notifications for the current user. Any time a user gets notified that they were directly mentioned, I'd like to be informed of that in my app, along with the contents of that message.

I've looked through the API docs for quite a while and I can't seem to find support for this functionality. Am I missing something? Can this be done?


Solution

  • There is no event in the Slack Event API that handles mentions of users (although if you create a slack bot you can handle mentions of the slack bot's user with the app_mention event).

    You can still listen for the message event and manually look through the text for any @UserMentions and handle them there. Note that this will only work for channels that the Slackbot has been granted access to.