Search code examples
slackslack-api

Slack: Count number of messages per day/week


TL;DR; How to summarize the number of messages in a slack channel every day with a regex/user.

I am using slack and love it! One of the most important channels in my team is the alert channel. We post alerts from our services/3rd parties to the channel and that keeps us updated if anything goes wrong.

We were wondering if there is a way to post a summary of all messages with a regex every day/week/month.


Solution

  • Here is one approach that works.

    • You need a Slack app that runs once a day to query your channel and post the message with the summary.
    • Use the API method conversations.history in your app to retrieve all message from a channel and count them to create the summary. You can specify a timeframe for that method, so you only need to retrieve the messages from one day.
    • Use the API method chat.postMessage to post the summary to the Slack channel.