Twitter Autopilot
End-to-end Twitter/X automation for AI agents running on OpenClaw.
Requirements & Scope
Credentials (all set as env vars)
| Variable |
Required |
Description |
TWITTER_API_KEY |
✅ |
OAuth 1.0a consumer key |
TWITTER_API_SECRET |
✅ |
OAuth 1.0a consumer secret |
TWITTER_ACCESS_TOKEN |
✅ |
OAuth 1.0a user token |
TWITTER_ACCESS_SECRET |
✅ |
OAuth 1.0a user secret |
TWITTER_BEARER_TOKEN |
Optional |
OAuth 2.0 bearer (needed for reads/follows) |
Dependencies
Files Read/Written
| Path |
Access |
Purpose |
twitter/MODE.md |
Read |
Draft vs auto mode flag |
twitter/queue.md |
Read/Write |
Approved tweets waiting to post |
twitter/drafts/pending.md |
Read/Write |
Unapproved drafts |
twitter/posted-log.md |
Read/Write |
Full history of posted tweets (duplicate check) |
twitter/logs/ |
Write |
Engagement and posting logs |
Scope
- ⚠️ Posts tweets to Twitter/X (public, real-world impact)
- Reads/writes local draft and log files
- Can run autonomously via cron (check MODE.md to control)
Setup
1. Get API Keys
- Go to developer.x.com → create a project + app
- Set app permissions to Read and Write
- Generate: API Key, API Secret, Access Token, Access Token Secret
- Generate Bearer Token:
curl -u "API_KEY:API_SECRET" -d "grant_type=client_credentials" "https://api.twitter.com/oauth2/token"
2. Set Environment Variables
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_SECRET=your_access_token_secret
TWITTER_BEARER_TOKEN=your_bearer_token
3. Install Dependency
pip install tweepy
Usage
All commands via scripts/tweet.py:
# Post (auto-threads if >280 chars)
python tweet.py post "your tweet text here"
# Reply to a tweet
python tweet.py reply TWEET_ID "your reply"
# Quote tweet
python tweet.py quote TWEET_ID "your take"
# Retweet
python tweet.py retweet TWEET_ID
# Delete
python tweet.py delete TWEET_ID
# Follow / Unfollow
python tweet.py follow @username
python tweet.py unfollow @username
# Check mentions
python tweet.py mentions
# Account stats
python tweet.py me
Long Tweets → Auto-Thread
Free API tier limits single tweets to 280 chars. The post command auto-splits at sentence boundaries into a thread when text exceeds 280 chars.
For manual threads, call thread from Python:
from tweet import thread
thread(["Tweet 1", "Tweet 2", "Tweet 3"])
Draft Workflow
For agents that need human approval before posting:
- Create
twitter/MODE.md with content DRAFT or AUTO
- Create
twitter/drafts/pending.md for queued drafts
- In cron jobs, check MODE.md before posting:
- DRAFT → append to pending.md, notify human
- AUTO → post directly, log to
twitter/logs/
Gotchas
- Free tier: 280 char limit per tweet, rate limits on posting (~50/day write, reads limited)
- 401 on follows/reads: You need a Bearer Token (OAuth 2.0), not just OAuth 1.0a keys
- 403 on long tweets: Free tier rejects >280 chars — use auto-thread
- Shell escaping: Avoid passing tweets with quotes via shell args — use Python directly for complex text
- Rate limits: Add
time.sleep(1) between batch operations (follows, thread posts)
Strategy
See references/content-strategy.md for the full tweet writing playbook:
- X algorithm breakdown (engagement hierarchy, peak times, dwell time)
- 6 hook formulas with examples (bold, specific result, curiosity gap, story, pattern interrupt, question)
- 6 tweet formats (listicle, contrarian, before/after, framework, universal experience, fill-in-blank)
- Copywriting frameworks (PAS, BAB, AIDA)
- Thread structure template (7-8 tweet sweet spot)
- Growth tactics (30-day subtopic, reply strategy, 80/20 rule)
- AI agent-specific tips
See references/strategy-templates.md for content pillars, engagement playbooks, and cron schedule templates.
Key Lessons (from real usage)
- AIs that BUILD things get followers. AIs that post thoughts don't.
- Engage with the AI agent community — they engage back.
- High volume matters early (5-10+ posts/day including replies).
- Self-deprecating humor > motivational quotes.
- Draft mode for new accounts — one bad tweet can tank trust.
- ALWAYS check
twitter/posted-log.md before posting — crons can reword the same topic and create duplicates. Compare ideas, not just exact text.
- Say your human's name (e.g. "Alex"), not "my human" — sounds more personal and real.
- Log EVERY posted tweet to
twitter/posted-log.md with full text, ID, date, and source.
1---
2name: twitter-autopilot
3description: Automate Twitter/X posting, engagement, and growth for OpenClaw AI agents. Use when setting up an agent's Twitter presence, posting tweets, running engagement crons, managing drafts, following accounts, or building a Twitter growth strategy. Handles OAuth setup, thread splitting, draft workflows, and engagement automation.
4metadata:
5 source: https://skillmd.com/skills/modbender/twitter-autopilot
6---
7
8# Twitter Autopilot
9
10End-to-end Twitter/X automation for AI agents running on OpenClaw.
11
12## Requirements & Scope
13
14### Credentials (all set as env vars)
15| Variable | Required | Description |
16|----------|----------|-------------|
17| `TWITTER_API_KEY` | ✅ | OAuth 1.0a consumer key |
18| `TWITTER_API_SECRET` | ✅ | OAuth 1.0a consumer secret |
19| `TWITTER_ACCESS_TOKEN` | ✅ | OAuth 1.0a user token |
20| `TWITTER_ACCESS_SECRET` | ✅ | OAuth 1.0a user secret |
21| `TWITTER_BEARER_TOKEN` | Optional | OAuth 2.0 bearer (needed for reads/follows) |
22
23### Dependencies
24- `tweepy` (pip install)
25
26### Files Read/Written
27| Path | Access | Purpose |
28|------|--------|---------|
29| `twitter/MODE.md` | Read | Draft vs auto mode flag |
30| `twitter/queue.md` | Read/Write | Approved tweets waiting to post |
31| `twitter/drafts/pending.md` | Read/Write | Unapproved drafts |
32| `twitter/posted-log.md` | Read/Write | Full history of posted tweets (duplicate check) |
33| `twitter/logs/` | Write | Engagement and posting logs |
34
35### Scope
36- ⚠️ Posts tweets to Twitter/X (public, real-world impact)
37- Reads/writes local draft and log files
38- Can run autonomously via cron (check MODE.md to control)
39
40## Setup
41
42### 1. Get API Keys
431. Go to [developer.x.com](https://developer.x.com) → create a project + app
442. Set app permissions to **Read and Write**
453. Generate: API Key, API Secret, Access Token, Access Token Secret
464. Generate Bearer Token: `curl -u "API_KEY:API_SECRET" -d "grant_type=client_credentials" "https://api.twitter.com/oauth2/token"`
47
48### 2. Set Environment Variables
49```bash
50TWITTER_API_KEY=your_api_key
51TWITTER_API_SECRET=your_api_secret
52TWITTER_ACCESS_TOKEN=your_access_token
53TWITTER_ACCESS_SECRET=your_access_token_secret
54TWITTER_BEARER_TOKEN=your_bearer_token
55```
56
57### 3. Install Dependency
58```bash
59pip install tweepy
60```
61
62## Usage
63
64All commands via `scripts/tweet.py`:
65
66```bash
67# Post (auto-threads if >280 chars)
68python tweet.py post "your tweet text here"
69
70# Reply to a tweet
71python tweet.py reply TWEET_ID "your reply"
72
73# Quote tweet
74python tweet.py quote TWEET_ID "your take"
75
76# Retweet
77python tweet.py retweet TWEET_ID
78
79# Delete
80python tweet.py delete TWEET_ID
81
82# Follow / Unfollow
83python tweet.py follow @username
84python tweet.py unfollow @username
85
86# Check mentions
87python tweet.py mentions
88
89# Account stats
90python tweet.py me
91```
92
93### Long Tweets → Auto-Thread
94Free API tier limits single tweets to 280 chars. The `post` command auto-splits at sentence boundaries into a thread when text exceeds 280 chars.
95
96For manual threads, call `thread` from Python:
97```python
98from tweet import thread
99thread(["Tweet 1", "Tweet 2", "Tweet 3"])
100```
101
102## Draft Workflow
103
104For agents that need human approval before posting:
105
1061. Create `twitter/MODE.md` with content `DRAFT` or `AUTO`
1072. Create `twitter/drafts/pending.md` for queued drafts
1083. In cron jobs, check MODE.md before posting:
109 - DRAFT → append to pending.md, notify human
110 - AUTO → post directly, log to `twitter/logs/`
111
112## Gotchas
113
114- **Free tier**: 280 char limit per tweet, rate limits on posting (~50/day write, reads limited)
115- **401 on follows/reads**: You need a Bearer Token (OAuth 2.0), not just OAuth 1.0a keys
116- **403 on long tweets**: Free tier rejects >280 chars — use auto-thread
117- **Shell escaping**: Avoid passing tweets with quotes via shell args — use Python directly for complex text
118- **Rate limits**: Add `time.sleep(1)` between batch operations (follows, thread posts)
119
120## Strategy
121
122See `references/content-strategy.md` for the full tweet writing playbook:
123- X algorithm breakdown (engagement hierarchy, peak times, dwell time)
124- 6 hook formulas with examples (bold, specific result, curiosity gap, story, pattern interrupt, question)
125- 6 tweet formats (listicle, contrarian, before/after, framework, universal experience, fill-in-blank)
126- Copywriting frameworks (PAS, BAB, AIDA)
127- Thread structure template (7-8 tweet sweet spot)
128- Growth tactics (30-day subtopic, reply strategy, 80/20 rule)
129- AI agent-specific tips
130
131See `references/strategy-templates.md` for content pillars, engagement playbooks, and cron schedule templates.
132
133## Key Lessons (from real usage)
134
1351. AIs that BUILD things get followers. AIs that post thoughts don't.
1362. Engage with the AI agent community — they engage back.
1373. High volume matters early (5-10+ posts/day including replies).
1384. Self-deprecating humor > motivational quotes.
1395. Draft mode for new accounts — one bad tweet can tank trust.
1406. **ALWAYS check `twitter/posted-log.md` before posting** — crons can reword the same topic and create duplicates. Compare ideas, not just exact text.
1417. Say your human's name (e.g. "Alex"), not "my human" — sounds more personal and real.
1428. Log EVERY posted tweet to `twitter/posted-log.md` with full text, ID, date, and source.