Looking for a way to return the total number of messages sent by a team via the Slack API. Browsing the documentation I have not come across a method to do this. Was curious if anyone has a found a way to do something similar.
To view the channel analytics, switch to the “Channels” tab. Free tier workspaces can see a list of all public channels in the workspace, the date the channel was created, the date of the last activity in the channel, the total number of members in the channel, and the total number of messages posted in the channel.
Under its current terms, free Slack workspaces are limited to 10,000 messages and 5GB of file storage. From 1 September that will change to a flat 90-day archive, meaning any messages or files older than three months will be expunged from the service (unless the customer decides to convert to a paid subscription).
Slack has message events for message. group , message.im and message. mpim . As I understand it, im means it's a private message to one person, and mpim is a private messaging conversation with multiple people. A group is described as a private channel.
You probably have to iterate over all channels, groups and users. For a given channel, the search.messages
endoint contains the info you need. For instance, using the python Slacker package, we can count the number of messages in @general
:
>>> import slacker
>>> token = "yourtoken"
>>> api = slacker.BaseAPI(token)
>>> api.get("search.messages", params={"query": "in:general"}).body["messages"]["total"]
19601
(I leave it to you to iterate over all channels and groups)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With