Search code examples
slackslack-api

Retrieving Slack messages where a specific group is tagged


I'm looking to retrieve messages in any public channel in my org's Slack where a given user group was tagged. Is there a way to do this without retrieving every message ever?

The main reason I need this is because I'm looking to record statistics on how often my user group is tagged on questions to determine our support load.

Thanks!

Sources: https://api.slack.com/messaging/retrieving


Solution

  • What about using https://api.slack.com/methods/search.messages to search for messages that contain mentions of the usergroup?

    You can set query as follows:

    query='@your_usergroup_name'