An agent that sends jokes and trivia to your Slack channel daily.

- AI-Generated Content - Fresh jokes and trivia powered by Claude AI
- Science/tech jokes (60% of messages) and history trivia facts (40% of messages)
- Automated posting at 9:00 AM daily (configurable)
- Uses MCP Slack server integration
- Target channel configurable
-
Configure environment variables:
cp .env.example .env # Edit .env with your Slack bot tokensCreate a Slack app at https://api.slack.com/apps to get the bot token.
-
Install dependencies:
pip install -e . -
Or use the startup script:
./start-agent.sh
python slack_agent.pypython slack_agent.py --time 12:00 # Daily at noonpython slack_agent.py --test
python slack_agent.py --test-aipython slack_agent.py --channel C1234567890python slack_agent.py --verbose- Scheduling: Uses Python
schedulelibrary to trigger daily at 9:00 AM - AI Generation: Uses Anthropic's Claude AI to generate fresh content
- Content Selection: Randomly selects between jokes and trivia (60%/40% split)
- Fallback System: Uses predefined content if AI generation fails
- MCP Integration: Spawns the MCP Slack server process
- Channel: Posts to #random channel by default
- Logging: Logs to both console and
slack_agent.logfile
Environment variables in .env file:
Required:
SLACK_BOT_TOKEN- Your Slack bot token (xoxb-...)SLACK_TEAM_ID- Your Slack team/workspace IDDEFAULT_CHANNEL_ID- Default channel to postANTHROPIC_API_KEY- Your Anthropic API key for Claude AI (sk-ant-...)
Optional:
SLACK_CHANNEL_IDS- Comma-separated list of allowed channels
Security:
- All secrets loaded from
.envfile (excluded from git) - No hardcoded API keys or tokens in source code
- Environment variable validation on startup
- Graceful handling of missing AI credentials
--test: Send a test message immediately--test-ai: Test AI generation without sending to Slack--channel CHANNEL_ID: Override the default channel--time HH:MM: Set daily schedule time (default: 09:00)--verbose, -v: Enable verbose debug logging
The agent creates comprehensive logs:
- Console output: Real-time status and messages
- File logging:
slack_agent.logwith detailed information - Timestamps: All log entries include precise timestamps
- Error tracking: Failed attempts are logged with details
Edit the jokes and trivia lists in slack_agent.py
Modify the schedule configuration:
schedule.every().day.at("09:00").do(self.send_daily_message) # Daily at 9 AM (current)
schedule.every().day.at("12:00").do(self.send_daily_message) # Daily at noon
schedule.every().hour.at(":00").do(self.send_daily_message) # Every hour
schedule.every().monday.at("09:00").do(self.send_daily_message) # Weekly on MondayUpdate the channel_id property or use --channel argument
pip install slack-joke-agent
slack-agent --helpgit clone https://github.com/wangjing0/slack-joke-agent.git
cd slack-joke-agent
pip install -e .git clone https://github.com/wangjing0/slack-joke-agent.git
cd slack-joke-agent
./start-agent.shpython test_slack_agent.pyContributions are welcome! Please feel free to submit a pull request. ❤️
This project is licensed under the MIT License - see the LICENSE file for details.