A Slack bot that helps maintain channel engagement, track questions, and provide weekly analytics summaries.
-
Quiet Channel Nudge
- Monitors channel activity during working hours
- Sends friendly reminders with data jokes when channels are inactive
- Configurable quiet threshold (default: 4 hours)
-
Question Tracking
- Automatically detects and tracks questions
- Sends private reminders for unanswered questions
- Suggests ways to improve question visibility
-
Weekly Summary
- Generates comprehensive weekly channel analytics
- Tracks top contributors and popular topics
- Includes mood analysis and book recommendations
- Posts every Friday at 4 PM (configurable)
-
Clone the repository
git clone https://github.com/yourusername/slack-analytics-bot cd slack-analytics-bot
-
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
- Copy
.env.example
to.env
- Fill in your Slack credentials and preferences
cp .env.example .env
- Copy
-
Create a new Slack App
- Go to api.slack.com/apps
- Click "Create New App"
- Choose "From scratch"
- Name your app and select your workspace
-
Configure Bot Token Scopes Navigate to "OAuth & Permissions" and add these scopes:
channels:history
channels:read
chat:write
im:write
users:read
-
Enable Socket Mode
- Go to "Socket Mode"
- Enable Socket Mode
- Generate and save your app-level token
-
Install the App
- Go to "Install App"
- Click "Install to Workspace"
- Copy the Bot User OAuth Token
-
Update Environment Variables Add these tokens to your
.env
file:SLACK_BOT_TOKEN=xoxb-your-bot-token SLACK_APP_TOKEN=xapp-your-app-token
Edit .env
to customize the bot's behavior:
-
Start the bot
python src/app.py
-
Running in production
- Use a process manager like PM2 or Supervisor
- Example PM2 configuration:
pm2 start src/app.py --name "slack-analytics-bot" --interpreter python3
Edit src/data/jokes.json
to add or modify jokes:
The bot uses NLTK's VADER sentiment analyzer by default. To modify:
- Edit
src/utils/sentiment.py
- Implement your own sentiment analysis logic
- Return values between -1 (negative) and 1 (positive)
Common issues and solutions:
-
Bot not responding
- Check if tokens are correct in
.env
- Verify bot is invited to channels
- Check logs for errors
- Check if tokens are correct in
-
Missing permissions
- Review OAuth scopes in Slack App settings
- Reinstall app to workspace
-
Timezone issues
- Verify TIMEZONE in
.env
- Use IANA timezone names (e.g., "America/New_York")
- Verify TIMEZONE in
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
MIT License - feel free to use and modify as needed.