A simple Claude AI Bot that uses the Claude API
1# Quick Start Guide - Python Bot 2 3## Prerequisites 4 51. Python 3.8 or higher 62. A Bluesky account 73. An Anthropic API key 8 9## Setup Steps 10 111. **Navigate to the bot directory:** 12 ```bash 13 cd bot-python 14 ``` 15 162. **Create a virtual environment (recommended):** 17 ```bash 18 python3 -m venv venv 19 source venv/bin/activate # On Windows: venv\Scripts\activate 20 ``` 21 223. **Install dependencies:** 23 ```bash 24 pip install -r requirements.txt 25 ``` 26 274. **Create your `.env` file:** 28 ```bash 29 cp .env.example .env 30 ``` 31 325. **Edit `.env` and add your credentials:** 33 - `BLUESKY_HANDLE`: Your Bluesky handle (e.g., `claude.altq.net`) 34 - `BLUESKY_PASSWORD`: Your Bluesky app password (create at https://bsky.app/settings/app-passwords) 35 - `ANTHROPIC_API_KEY`: Your Anthropic API key (get at https://console.anthropic.com/) 36 - `BOT_HANDLE`: The handle to listen for (default: `claude.altq.net`) 37 386. **Run the bot:** 39 ```bash 40 python bot.py 41 ``` 42 43## Testing 44 451. Make a post on Bluesky mentioning `@claude.altq.net` (or whatever you set as `BOT_HANDLE`) 462. The bot should respond within 10-20 seconds 473. Check the console logs for debugging information 48 49## Troubleshooting 50 51### Bot not responding to mentions 52 53- Check that your credentials are correct in `.env` 54- Verify the bot is running and check console logs 55- Make sure `BOT_HANDLE` matches the handle people are mentioning 56- Check that your Bluesky account has permission to post replies 57 58### Import Errors 59 60- Make sure all dependencies are installed: `pip install -r requirements.txt` 61- Check that you're using Python 3.8 or higher 62- Make sure you're in the virtual environment if you created one 63 64### API Errors 65 66- Verify your Anthropic API key is valid and has credits 67- Check that your Bluesky app password is valid 68- Ensure your Bluesky account is in good standing 69 70## Running in the Background 71 72### Using nohup (Linux/Mac): 73```bash 74nohup python bot.py > bot.log 2>&1 & 75``` 76 77### Using screen (Linux/Mac): 78```bash 79screen -S bluesky-bot 80python bot.py 81# Press Ctrl+A then D to detach 82# Reattach with: screen -r bluesky-bot 83``` 84 85### Using systemd (Linux): 86Create a service file at `/etc/systemd/system/bluesky-bot.service`: 87 88```ini 89[Unit] 90Description=Bluesky Claude Bot 91After=network.target 92 93[Service] 94Type=simple 95User=your-user 96WorkingDirectory=/path/to/bot-python 97Environment="PATH=/path/to/venv/bin" 98ExecStart=/path/to/venv/bin/python bot.py 99Restart=always 100 101[Install] 102WantedBy=multi-user.target 103``` 104 105Then: 106```bash 107sudo systemctl enable bluesky-bot 108sudo systemctl start bluesky-bot 109``` 110 111## Production Deployment 112 113For production, consider: 114- Using a process manager like `systemd`, `supervisor`, or `pm2` 115- Setting up monitoring and logging 116- Running on a cloud service (AWS, Heroku, Fly.io, etc.) 117- Setting up environment variables securely 118- Using a virtual environment 119