Skip to content

Commit 4edd46f

Browse files
docs: add Twitter configuration guide and env example
Co-Authored-By: Leon zhao <leonchiuchikwan@gmail.com>
1 parent 41c657c commit 4edd46f

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

docs/twitter-configuration.md

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Twitter Client Configuration Guide
2+
3+
## Prerequisites
4+
- Twitter Developer Account
5+
- Twitter API Access (User Authentication Tokens)
6+
- Basic understanding of environment variables
7+
8+
## Required Credentials
9+
The following Twitter API credentials are required:
10+
11+
```env
12+
TWITTER_USERNAME=your_twitter_username
13+
TWITTER_PASSWORD=your_twitter_password
14+
TWITTER_EMAIL=your_twitter_email
15+
TWITTER_API_KEY=your_api_key
16+
TWITTER_API_SECRET=your_api_secret
17+
TWITTER_ACCESS_TOKEN=your_access_token
18+
TWITTER_ACCESS_SECRET=your_access_token_secret
19+
TWITTER_BEARER_TOKEN=your_bearer_token
20+
```
21+
22+
## Optional Configuration Settings
23+
Additional settings to customize behavior:
24+
25+
```env
26+
# Tweet Length Configuration
27+
MAX_TWEET_LENGTH=280 # Maximum length for tweets
28+
29+
# Search and Monitoring
30+
TWITTER_SEARCH_ENABLE=true # Enable/disable tweet searching
31+
TWITTER_TARGET_USERS=user1,user2 # Comma-separated list of users to monitor
32+
33+
# Posting Configuration
34+
POST_INTERVAL_MIN=90 # Minimum minutes between posts
35+
POST_INTERVAL_MAX=180 # Maximum minutes between posts
36+
POST_IMMEDIATELY=false # Post immediately on startup
37+
38+
# Action Processing
39+
ENABLE_ACTION_PROCESSING=true # Enable processing of likes/retweets
40+
ACTION_INTERVAL=5 # Minutes between action processing
41+
TWITTER_POLL_INTERVAL=120 # Seconds between checking for new tweets
42+
43+
# Authentication
44+
TWITTER_2FA_SECRET= # If using 2FA
45+
TWITTER_RETRY_LIMIT=5 # Number of login retry attempts
46+
47+
# Testing
48+
TWITTER_DRY_RUN=false # Test mode without actual posting
49+
```
50+
51+
## Character File Configuration
52+
Character files (`.character.json`) should include Twitter-specific settings:
53+
54+
```json
55+
{
56+
"settings": {
57+
"twitter": {
58+
"monitor": {
59+
"keywords": ["keyword1", "keyword2"],
60+
"imageUrls": ["url1", "url2"],
61+
"imageRotationInterval": 3600,
62+
"activeTimeWindows": [
63+
{"start": "09:00", "end": "17:00"}
64+
],
65+
"postInterval": 7200,
66+
"pollInterval": 300
67+
}
68+
}
69+
},
70+
"topics": [
71+
"topic1",
72+
"topic2"
73+
]
74+
}
75+
```
76+
77+
## Setup Instructions
78+
79+
1. **Create Twitter Developer Account**
80+
- Visit developer.twitter.com
81+
- Create a new project and app
82+
- Enable User Authentication
83+
- Generate API keys and tokens
84+
85+
2. **Configure Environment Variables**
86+
- Copy `.env.example` to `.env`
87+
- Fill in all required credentials
88+
- Adjust optional settings as needed
89+
90+
3. **Configure Character File**
91+
- Add Twitter monitoring settings
92+
- Define relevant topics and keywords
93+
- Set appropriate time windows and intervals
94+
95+
4. **Verify Configuration**
96+
- Run with `TWITTER_DRY_RUN=true` initially
97+
- Check logs for proper authentication
98+
- Test basic functionality before enabling full features
99+
100+
## Features
101+
- Photo posting support
102+
- Keyword-based retweeting
103+
- Automated liking based on topics
104+
- User-level authentication
105+
- Configurable posting intervals
106+
- Smart conversation threading
107+
108+
## Troubleshooting
109+
110+
### Common Issues
111+
1. Authentication Failures
112+
- Verify all credentials are correct
113+
- Check if API keys have proper permissions
114+
- Ensure 2FA is properly configured if enabled
115+
116+
2. Rate Limiting
117+
- Adjust intervals to be more conservative
118+
- Monitor Twitter API usage
119+
- Check rate limit headers in responses
120+
121+
3. Content Issues
122+
- Verify MAX_TWEET_LENGTH setting
123+
- Check character file topic configuration
124+
- Ensure media uploads are properly formatted
125+
126+
## Security Notes
127+
- Keep all API credentials secure
128+
- Don't commit `.env` file to version control
129+
- Regularly rotate access tokens
130+
- Use environment variables over hardcoded values

packages/client-twitter/.env.example

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Twitter Authentication
2+
TWITTER_USERNAME=your_twitter_username
3+
TWITTER_PASSWORD=your_twitter_password
4+
TWITTER_EMAIL=your.email@example.com
5+
6+
# Twitter API Credentials
7+
TWITTER_API_KEY=your_api_key_here
8+
TWITTER_API_SECRET=your_api_secret_here
9+
TWITTER_ACCESS_TOKEN=your_access_token_here
10+
TWITTER_ACCESS_SECRET=your_access_token_secret_here
11+
TWITTER_BEARER_TOKEN=your_bearer_token_here
12+
13+
# Tweet Configuration
14+
MAX_TWEET_LENGTH=280
15+
TWITTER_DRY_RUN=false
16+
17+
# Search and Monitoring
18+
TWITTER_SEARCH_ENABLE=false
19+
TWITTER_TARGET_USERS=user1,user2
20+
TWITTER_POLL_INTERVAL=120
21+
22+
# Authentication Settings
23+
TWITTER_2FA_SECRET=your_2fa_secret_if_enabled
24+
TWITTER_RETRY_LIMIT=5
25+
26+
# Posting Configuration
27+
POST_INTERVAL_MIN=90
28+
POST_INTERVAL_MAX=180
29+
POST_IMMEDIATELY=false
30+
31+
# Action Processing
32+
ENABLE_ACTION_PROCESSING=true
33+
ACTION_INTERVAL=5
34+
35+
# Additional Features
36+
TWITTER_SPACES_ENABLE=false

0 commit comments

Comments
 (0)