An AI-powered Twitter/X bot that generates engaging tweets based on your mood or topic, finds relevant images from Unsplash, and posts them to your X account.
- AI Tweet Generation - Uses Google Gemini to create engaging, human-like tweets
- Smart Image Matching - Analyzes tweets to find relevant images via Unsplash API
- Media Upload - Automatically downloads and attaches images to tweets
- Interactive CLI - Preview tweets before posting
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables in
.env:# X API credentials (from developer.twitter.com) X_API_KEY=your_x_api_key X_API_SECRET=your_x_api_secret X_ACCESS_TOKEN=your_access_token X_ACCESS_TOKEN_SECRET=your_access_token_secret # Google Gemini API key (from aistudio.google.com) GEMINI_API_KEY=your_gemini_api_key # Unsplash API key (from unsplash.com/developers) UNSPLASH_ACCESS_KEY=your_unsplash_access_key -
Run the bot:
python main.py
- Enter your mood or topic when prompted
- Review the AI-generated tweet
- Confirm or cancel the image attachment
- Approve posting to X
| File | Description |
|---|---|
main.py |
Main CLI entry point, handles tweet posting via Tweepy |
gemini.py |
Gemini API integration for tweet generation and image query analysis |
image.py |
Unsplash API integration for fetching relevant images |
requirements.txt |
Python dependencies |
- Python 3.8+
- X Developer Account (for API keys)
- Google AI Studio Account (for Gemini API)
- Unsplash Developer Account (for image API)