Home > Blockchain >  Can I use a Slack bot to count how many times each user has posted a message in multiple channels wi
Can I use a Slack bot to count how many times each user has posted a message in multiple channels wi

Time:02-24

I want to use the Slack API to aggregate how many times each user in Slack has posted a message in a specific period of time. The conditions are as follows.

  • Multiple channels are covered
  • Both public and private channels are covered

So here's what I'd like to ask you;

  • I've read the official Slack API documentation, and apparently there are no direct API methods suitable for the above kind of aggregation, is that correct?
  • If the above is correct, I think the only way is to parse the text from the text property, which is the return value of the conversation.history method, and aggregate it, is that correct?

CodePudding user response:

Unfortunately, there is no out-of-the-box method that will enable you to get that exact data. A bot needs to be in a channel if it's going to call conversations.history. You'd need to identify the id of the user[s] and filter through the response payload to get the aggregate number of messages for that user. However, moving forward you can use the Events API with the [messages][2] event type. This way your app will be notified of all messages in a channel in real time.

  • Related