Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning Total Number of Messages Sent Via Slack API

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.

like image 502
Magnetion Avatar asked Nov 09 '15 15:11

Magnetion


People also ask

How do I count the number of messages in Slack?

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.

Does Slack delete messages after 10000?

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).

What is MPIM in Slack?

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.


1 Answers

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)

like image 87
Régis B. Avatar answered Oct 14 '22 21:10

Régis B.