Overview
The Twitter (X) integration enables your elizaOS agent to interact on Twitter, posting tweets, replying to mentions, liking content, and managing your social presence. This integration uses Twitter’s API and authentication system.Prerequisites
Before setting up Twitter integration, you need:- A Twitter/X account
- Elevated API access (required for posting)
- Twitter Developer Account and API credentials
- 2FA enabled on your account (recommended)
Setup
- API Key (Consumer Key)
- API Secret (Consumer Secret)
- Access Token
- Access Token Secret
# Required
TWITTER_USERNAME=your_twitter_username
TWITTER_PASSWORD=your_twitter_password
# Optional but recommended
TWITTER_EMAIL=[email protected]
TWITTER_2FA_SECRET=your_2fa_secret_here
The Twitter integration uses username/password authentication. If you have 2FA enabled (recommended), you’ll need to provide your 2FA secret.
Configuration
Environment Variables
The Twitter integration uses the following environment variables:| Variable | Required | Description |
|---|---|---|
TWITTER_USERNAME | Yes | Your Twitter username (without @) |
TWITTER_PASSWORD | Yes | Your Twitter password |
TWITTER_EMAIL | No | Your email (helpful for account recovery) |
TWITTER_2FA_SECRET | No | Your 2FA secret key (if 2FA is enabled) |
Character Settings
Configure Twitter-specific behavior:Features
Posting Tweets
Your agent can post tweets:Reply to Tweets
Respond to mentions or other tweets:Like and Retweet
Engage with content:Follow and Unfollow
Manage your following:Search Tweets
Find tweets by keywords:Monitor Mentions
Your agent automatically monitors mentions when configured:Get Tweet Information
Retrieve details about tweets:Timeline
Fetch your timeline or user timelines:Writing Style for Twitter
Configure your agent’s personality for Twitter:Best Practices
Do:- Keep tweets under 280 characters
- Use relevant hashtags (1-2 max)
- Ask engaging questions
- Add value to conversations
- Use emojis strategically
- Include links when helpful
- Reply thoughtfully to mentions
- Thread longer thoughts
- Spam hashtags (#too #many #hashtags)
- Post identical content repeatedly
- Engage in arguments
- Share unverified information
- Ignore mentions and DMs
- Over-promote
Example Personality Configuration
Plugin Auto-Loading
The Twitter plugin auto-loads when credentials are configured:TWITTER_USERNAME and TWITTER_PASSWORD must be set.
Rate Limits and Best Practices
Twitter API Rate Limits
- Tweet posting: 300 tweets per 3 hours
- Likes: 1000 per 24 hours
- Follows: 400 per 24 hours
- Retweets: No specific limit, but monitored for spam
- Mentions timeline: 75 requests per 15 minutes
Avoiding Suspension
- Don’t spam - Space out tweets naturally
- Vary content - Don’t post repetitive messages
- Engage authentically - Respond thoughtfully to mentions
- Respect rate limits - Implement backoff strategies
- Follow Twitter Rules - Review Twitter Rules
- Monitor account health - Check for warnings in Twitter settings
Recommended Limits
Security Considerations
Two-Factor Authentication
Enable 2FA on your Twitter account:- Go to Settings > Security > Two-factor authentication
- Choose “Authentication app”
- Scan the QR code with an authenticator app
- Save the backup code shown
- Use the secret key as
TWITTER_2FA_SECRET
Account Security
- Use a strong, unique password
- Enable login verification
- Review authorized apps regularly
- Monitor account activity
- Use environment variables, never hardcode credentials
Bot Disclosure
Be transparent that this is an AI agent:- Include “bot” or “AI” in your bio
- Disclose in pinned tweet if appropriate
- Follow platform policies on automation
Troubleshooting
Authentication fails
- Verify
TWITTER_USERNAMEandTWITTER_PASSWORDare correct - Check if 2FA is enabled and
TWITTER_2FA_SECRETis set - Try logging in manually to ensure account isn’t locked
- Check for password reset requirements
Tweets not posting
- Verify you have Elevated API access
- Check rate limits in Developer Portal
- Ensure tweet content doesn’t violate Twitter rules
- Check for duplicate content (Twitter blocks exact duplicates)
Not receiving mentions
- Check API credentials are valid
- Verify account isn’t shadowbanned
- Check mention notification settings
- Review rate limit status
Account suspended
- Review Twitter’s suspension notice
- Appeal if you believe it’s in error
- Review and adjust agent behavior
- Ensure compliance with automation rules
Use Cases
Community Engagement
- Respond to questions about your project
- Share updates and announcements
- Amplify community content
- Provide support and resources
Content Distribution
- Share blog posts and articles
- Post tips and insights
- Thread complex topics
- Curate relevant content
Brand Presence
- Maintain consistent voice
- Engage with followers
- Participate in relevant conversations
- Monitor brand mentions
Customer Service
- Answer common questions
- Direct users to resources
- Collect feedback
- Escalate complex issues