This repository contains Python scripts that use the Slack API to count specific reactions in a Slack workspace, and then display the top 30 users with the most reactions.
-
count_reactions.py
- Fetches messages with specific reactions, counts reactions per user, and saves the data to a CSV file calledreaction_counts.csv
. -
summarize_and_display_top_users.py
- Reads the reaction counts from thereaction_counts.csv
file, summarizes the counts by user, sorts the users by count, and displays the top 30 users with their user names and total counts.
- Python 3.6 or higher
- slack-sdk Python package
- python-dotenv Python package
-
Create a virtual environment and activate it:
source venv/bin/activate (Linux/Mac) venv\Scripts\activate (Windows)
-
Install the required packages:
pip install -r requirement.txt
-
Create a
.env
file in the project directory and add your Slack API token:SLACK_API_TOKEN=your_slack_api_token
Replace your_slack_api_token
with your actual Slack API token.
-
Run the
count_reactions.py
script to fetch messages with specific reactions and save the reaction counts to thereaction_counts.csv
file:python count_reactions.py
-
Run the
get_top_users_name.py
script to read the reaction counts from thereaction_counts.csv
file, summarize the counts by user, and display the top 30 users with their user names and total counts:python get_top_users_name.py
- To count different specific reactions, modify the
specific_reactions
list in thecount_reactions.py
script. - To change the number of top users displayed, modify the slice in the
for
loop in theget_top_users_name.py
script.