A flexible system for Twitter interaction, built on gptme. This system enables AI agents to:
- Monitor Twitter timeline and lists
- Generate contextually appropriate responses
- Maintain high-quality engagement through LLM-assisted review
- Schedule and manage tweet posting
Basic Twitter operations:
- Post tweets and threads
- Read timeline and lists
- Monitor mentions and replies
- Check engagement metrics
Manages the tweet lifecycle:
- Timeline monitoring
- Draft creation and storage
- Review process
- Scheduled posting
Handles AI-powered operations:
- Tweet evaluation
- Response generation
- Draft review and verification
- Quality control
Defines interaction parameters:
- Topics of interest
- Evaluation criteria
- Response templates
- Rate limits and blacklists
Unified interface for all Twitter operations.
tweets/
├── new/ - New tweet drafts
├── review/ - Tweets pending review
├── approved/ - Approved tweets ready to post
├── posted/ - Archive of posted tweets
└── rejected/ - Rejected tweet drafts- Configure Twitter credentials in
.env:
# OAuth 2.0 (Recommended)
TWITTER_CLIENT_ID=your_client_id
TWITTER_CLIENT_SECRET=your_client_secret
TWITTER_BEARER_TOKEN=your_bearer_token
# OAuth 1.0a (Legacy)
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_SECRET=your_access_secret- Configure interaction parameters in
config/config.yml
# Post a tweet
./twitter.py post "Hello world!"
# Read timeline
./twitter.py timeline
# Monitor for content to respond to
./workflow.py monitor
# Review drafts
./workflow.py review
# Post approved tweets
./workflow.py post-
Monitor and respond to tweets:
./workflow.py monitor --interval 900
-
Review and approve drafts:
./workflow.py review
-
Post approved tweets:
./workflow.py post
-
Auto workflow (monitor, review, post):
./workflow.py auto --auto-approve --post-approved
Instead of built-in cron setup, you can use various methods to automate the Twitter workflow:
Add entries to your crontab:
# Monitor timeline every 15 minutes
*/15 * * * * cd /path/to/project && ./workflow.py monitor --dry-run
# Review notification at 9am, 1pm, and 5pm
0 9,13,17 * * * notify-send "Twitter Review" "Time to review tweet drafts!"
# Post approved tweets every 30 minutes
*/30 * * * * cd /path/to/project && ./workflow.py postUse crontab -e to edit your crontab.
Create a service file /etc/systemd/system/twitter-monitor.service:
[Unit]
Description=Twitter Monitoring Service
After=network.target
[Service]
Type=oneshot
ExecStart=/path/to/./workflow.py monitor
WorkingDirectory=/path/to/project
User=yourusername
[Install]
WantedBy=multi-user.targetCreate a timer file /etc/systemd/system/twitter-monitor.timer:
[Unit]
Description=Run Twitter Monitor every 15 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=15min
[Install]
WantedBy=timers.targetEnable and start the timer:
sudo systemctl enable twitter-monitor.timer
sudo systemctl start twitter-monitor.timerUse Windows Task Scheduler to create scheduled tasks for:
- Monitoring (
workflow monitor) - Reviewing (
workflow review) - Posting (
workflow post)
Run in a Docker container with scheduled execution:
FROM python:3.10-slim
WORKDIR /app
COPY . .
RUN pip install -e .
# Run workflow monitor every 15 minutes
CMD ["bash", "-c", "while true; do ./workflow.py monitor; sleep 900; done"]- Keep tweets concise and focused
- Use 1-2 emojis maximum
- Put links in follow-up tweets
- Maintain professional tone
- Stay within configured topics
- LLM performs initial review
- Human review for final approval
- Consider suggested improvements
- Check context when relevant
- Verify thread coherence
- Check review notifications
- Monitor engagement metrics
- Adjust configuration as needed
- Review rejected tweets for patterns
-
Authentication Errors
- Verify credentials in
.env - Check token expiration
- Ensure proper OAuth flow
- Verify credentials in
-
Rate Limiting
- Check configured limits
- Monitor Twitter API usage
- Adjust intervals if needed
-
Draft Processing
- Verify LLM availability
- Check file permissions
- Monitor disk space
Logs are stored in:
twitter.log- Basic operationstwitter_error.log- Error detailstwitter_llm.log- LLM interactions