A Twitter reply agent that uses AI to generate and post replies to tweets from your home timeline, matching your style, interests, and tone.
- Fetches tweets from your home timeline
- Uses OpenAI (fine-tuned) to generate original, on-brand replies
- Interactive feedback loop for refining replies
- Avoids duplicate or near-duplicate tweets
- Logs all attempts and accepted replies for future optimization
- Only core data files are tracked in version control
- Clone the repository
- Create and activate a Python virtual environment (
python3 -m venv venv && source venv/bin/activate
) - Install dependencies:
pip install -r twitter_agent/requirements.txt
- Copy
twitter_agent/config/.env.example
to.env
and fill in your API keys - Run the main script:
python3 -m twitter_agent.scripts.reply_to_tweet --count 5 --batch-size 30
- The script will fetch tweets, display them with engagement and links, and let you select one to reply to.
- The AI will generate a reply, and you can accept, reject, or provide feedback for a new attempt.
- Retweets are clearly labeled, and each tweet includes a direct link.
- Only essential data files are tracked:
data/attempted_replies.jsonl
and your main tweet history jsonl. - All other data (timelines, web corpus, etc.) are ignored by
.gitignore
.
- All documentation (including this README and the agent's internal README) should be kept up to date with code and workflow changes.
- See
.cursorrules
for documentation and code quality requirements.
Specify your license here.
All scripts should be run as modules from the project root to ensure imports work correctly.
Fetch tweets from your home timeline and interactively generate replies:
python3 -m twitter_agent.scripts.reply_to_tweet --batch-size 30
- Use
--batch-size
to control how many tweets are fetched for reply selection. - Follow the interactive prompts to select a tweet and generate/post a reply.
Generate a tweet about a specific topic (with approval and regenerate options):
python3 -m twitter_agent.scripts.tweet_about_topic --topic "the record high gold price"
- You will be shown a generated tweet and prompted to approve, abort, or regenerate.
- If you approve, the tweet will be posted with a disclaimer.
Note:
- Always run scripts with
python3 -m ...
from the project root for reliable import behavior. - If you encounter import errors, ensure you are in the project root and using the
-m
flag.