slack-joke-agent


Nameslack-joke-agent JSON
Version 1.1.5 PyPI version JSON
download
home_pageNone
SummaryDaily Slack agent that sends jokes and trivia with MCP
upload_time2025-07-20 22:47:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords slack mcp automation jokes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Slack Joke Agent

An agent that sends jokes and trivia to your Slack channel daily.
![jokes](https://github.com/wangjing0/slack-joke-agent/raw/main/jokes.png)

## Features

- 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

## Setup

1. Configure environment variables:
   ```bash
   cp .env.example .env
   # Edit .env with your Slack bot tokens
   ```
   Create a Slack app at https://api.slack.com/apps to get the bot token.

2. Install dependencies:
   ```bash
   pip install -e .
   ```

3. Or use the startup script:
   ```bash
   ./start-agent.sh
   ```

## Usage

### Start the daily agent:
```bash
python slack_agent.py
```

### Start with custom time:
```bash
python slack_agent.py --time 12:00  # Daily at noon
```

### Test with immediate message:
```bash
python slack_agent.py --test
python slack_agent.py --test-ai
```

### Use custom channel:
```bash
python slack_agent.py --channel C1234567890
```

### Enable verbose logging:
```bash
python slack_agent.py --verbose
```


## How it Works

1. Scheduling: Uses Python `schedule` library to trigger daily at 9:00 AM
2. AI Generation: Uses Anthropic's Claude AI to generate fresh content
3. Content Selection: Randomly selects between jokes and trivia (60%/40% split)
4. Fallback System: Uses predefined content if AI generation fails
5. MCP Integration: Spawns the MCP Slack server process
6. Channel: Posts to #random channel by default
7. Logging: Logs to both console and `slack_agent.log` file

## Configuration

Environment variables in `.env` file:

**Required:**
- `SLACK_BOT_TOKEN` - Your Slack bot token (xoxb-...)
- `SLACK_TEAM_ID` - Your Slack team/workspace ID
- `DEFAULT_CHANNEL_ID` - Default channel to post
- `ANTHROPIC_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 `.env` file (excluded from git)
- No hardcoded API keys or tokens in source code
- Environment variable validation on startup
- Graceful handling of missing AI credentials

**AI Features:**
- Dynamic content freshly generated by Claude AI
- Workplace appropriate prompts ensure clean content
- Automatic fallback to predefined content if AI generation fails
- Smart logging tracks AI generation success/failure

## Command Line Options

- `--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

## Logs

The agent creates comprehensive logs:
- Console output: Real-time status and messages
- File logging: `slack_agent.log` with detailed information
- Timestamps: All log entries include precise timestamps
- Error tracking: Failed attempts are logged with details

## Customization

### Add more jokes/trivia:
Edit the `jokes` and `trivia` lists in `slack_agent.py`

### Change schedule:
Modify the schedule configuration:
```python
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 Monday
```

### Change channel:
Update the `channel_id` property or use `--channel` argument

### Update Slack tokens:
Edit the `.env` file with your new tokens

## Installation

### From PyPI (Recommended):
```bash
pip install slack-joke-agent
slack-agent --help
```

### From Source:
```bash
git clone <repository>
cd slack-joke-agent
pip install -e .
```

### Quick Development Setup:
```bash
git clone https://github.com/wangjing0/slack-joke-agent.git
cd slack-joke-agent
./start-agent.sh
```

### Running Tests:
```bash
python test_slack_agent.py
```

## Contributing

Contributions are welcome! Please feel free to submit a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "slack-joke-agent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "slack, mcp, automation, jokes",
    "author": null,
    "author_email": "Jing Wang <jingwang.physics@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bf/0f/0fb7cb3bcade6e7933cfad89f40e56593e205077722ae4ae794c6a703a10/slack_joke_agent-1.1.5.tar.gz",
    "platform": null,
    "description": "# Slack Joke Agent\n\nAn agent that sends jokes and trivia to your Slack channel daily.\n![jokes](https://github.com/wangjing0/slack-joke-agent/raw/main/jokes.png)\n\n## Features\n\n- AI-Generated Content - Fresh jokes and trivia powered by Claude AI\n- Science/tech jokes (60% of messages) and history trivia facts (40% of messages)\n- Automated posting at 9:00 AM daily (configurable)\n- Uses MCP Slack server integration\n- Target channel configurable\n\n## Setup\n\n1. Configure environment variables:\n   ```bash\n   cp .env.example .env\n   # Edit .env with your Slack bot tokens\n   ```\n   Create a Slack app at https://api.slack.com/apps to get the bot token.\n\n2. Install dependencies:\n   ```bash\n   pip install -e .\n   ```\n\n3. Or use the startup script:\n   ```bash\n   ./start-agent.sh\n   ```\n\n## Usage\n\n### Start the daily agent:\n```bash\npython slack_agent.py\n```\n\n### Start with custom time:\n```bash\npython slack_agent.py --time 12:00  # Daily at noon\n```\n\n### Test with immediate message:\n```bash\npython slack_agent.py --test\npython slack_agent.py --test-ai\n```\n\n### Use custom channel:\n```bash\npython slack_agent.py --channel C1234567890\n```\n\n### Enable verbose logging:\n```bash\npython slack_agent.py --verbose\n```\n\n\n## How it Works\n\n1. Scheduling: Uses Python `schedule` library to trigger daily at 9:00 AM\n2. AI Generation: Uses Anthropic's Claude AI to generate fresh content\n3. Content Selection: Randomly selects between jokes and trivia (60%/40% split)\n4. Fallback System: Uses predefined content if AI generation fails\n5. MCP Integration: Spawns the MCP Slack server process\n6. Channel: Posts to #random channel by default\n7. Logging: Logs to both console and `slack_agent.log` file\n\n## Configuration\n\nEnvironment variables in `.env` file:\n\n**Required:**\n- `SLACK_BOT_TOKEN` - Your Slack bot token (xoxb-...)\n- `SLACK_TEAM_ID` - Your Slack team/workspace ID\n- `DEFAULT_CHANNEL_ID` - Default channel to post\n- `ANTHROPIC_API_KEY` - Your Anthropic API key for Claude AI (sk-ant-...)\n\n**Optional:**\n- `SLACK_CHANNEL_IDS` - Comma-separated list of allowed channels\n\n**Security:**\n- All secrets loaded from `.env` file (excluded from git)\n- No hardcoded API keys or tokens in source code\n- Environment variable validation on startup\n- Graceful handling of missing AI credentials\n\n**AI Features:**\n- Dynamic content freshly generated by Claude AI\n- Workplace appropriate prompts ensure clean content\n- Automatic fallback to predefined content if AI generation fails\n- Smart logging tracks AI generation success/failure\n\n## Command Line Options\n\n- `--test`: Send a test message immediately\n- `--test-ai`: Test AI generation without sending to Slack\n- `--channel CHANNEL_ID`: Override the default channel\n- `--time HH:MM`: Set daily schedule time (default: 09:00)\n- `--verbose, -v`: Enable verbose debug logging\n\n## Logs\n\nThe agent creates comprehensive logs:\n- Console output: Real-time status and messages\n- File logging: `slack_agent.log` with detailed information\n- Timestamps: All log entries include precise timestamps\n- Error tracking: Failed attempts are logged with details\n\n## Customization\n\n### Add more jokes/trivia:\nEdit the `jokes` and `trivia` lists in `slack_agent.py`\n\n### Change schedule:\nModify the schedule configuration:\n```python\nschedule.every().day.at(\"09:00\").do(self.send_daily_message)  # Daily at 9 AM (current)\nschedule.every().day.at(\"12:00\").do(self.send_daily_message)  # Daily at noon\nschedule.every().hour.at(\":00\").do(self.send_daily_message)   # Every hour\nschedule.every().monday.at(\"09:00\").do(self.send_daily_message)  # Weekly on Monday\n```\n\n### Change channel:\nUpdate the `channel_id` property or use `--channel` argument\n\n### Update Slack tokens:\nEdit the `.env` file with your new tokens\n\n## Installation\n\n### From PyPI (Recommended):\n```bash\npip install slack-joke-agent\nslack-agent --help\n```\n\n### From Source:\n```bash\ngit clone <repository>\ncd slack-joke-agent\npip install -e .\n```\n\n### Quick Development Setup:\n```bash\ngit clone https://github.com/wangjing0/slack-joke-agent.git\ncd slack-joke-agent\n./start-agent.sh\n```\n\n### Running Tests:\n```bash\npython test_slack_agent.py\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Daily Slack agent that sends jokes and trivia with MCP",
    "version": "1.1.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/wangjing0/slack-joke-agent/issues",
        "Documentation": "https://github.com/wangjing0/slack-joke-agent#readme",
        "Homepage": "https://github.com/wangjing0/slack-joke-agent",
        "Repository": "https://github.com/wangjing0/slack-joke-agent.git"
    },
    "split_keywords": [
        "slack",
        " mcp",
        " automation",
        " jokes"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2d2fc62c11eaa0b3c65681d1ce2167217f49744b18a2c424ebf3b6b36b3c2f5b",
                "md5": "4bceaa68672f13468f3f966271a4c043",
                "sha256": "d9ce508aaf57c9f9755b887cc633a61fa1d296e728c7bdd35a7fa657f87e506f"
            },
            "downloads": -1,
            "filename": "slack_joke_agent-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4bceaa68672f13468f3f966271a4c043",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8785,
            "upload_time": "2025-07-20T22:47:47",
            "upload_time_iso_8601": "2025-07-20T22:47:47.387423Z",
            "url": "https://files.pythonhosted.org/packages/2d/2f/c62c11eaa0b3c65681d1ce2167217f49744b18a2c424ebf3b6b36b3c2f5b/slack_joke_agent-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bf0f0fb7cb3bcade6e7933cfad89f40e56593e205077722ae4ae794c6a703a10",
                "md5": "e00576bb652d4fb5c97b7f9584d75cd3",
                "sha256": "e746487149641d5273062ef292515a6046327c35c9b9cdc60e3e3bee713809c6"
            },
            "downloads": -1,
            "filename": "slack_joke_agent-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e00576bb652d4fb5c97b7f9584d75cd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14450,
            "upload_time": "2025-07-20T22:47:48",
            "upload_time_iso_8601": "2025-07-20T22:47:48.728381Z",
            "url": "https://files.pythonhosted.org/packages/bf/0f/0fb7cb3bcade6e7933cfad89f40e56593e205077722ae4ae794c6a703a10/slack_joke_agent-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-20 22:47:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wangjing0",
    "github_project": "slack-joke-agent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "slack-joke-agent"
}
        
Elapsed time: 0.55683s