An automated X (Twitter) bot that posts news, tips, opinions, and engages with people — all on autopilot. No server needed. Runs free on GitHub.
Runs on a schedule and does four things:
- Posts news — finds fresh articles and tweets about them
- Posts your own content — tips, opinions, and takes based on real articles (nothing invented)
- Posts memes & polls — funny or engaging tech posts
- Engages with people — likes, comments, and reposts relevant posts from others
Go to the top of this page and click Fork. This creates your own copy.
The bot needs a way to post as you. You have two options:
Option A — Username & Password (easiest, works on any device)
Just add your username and password in Step 4. The bot will log in automatically. Done.
If X ever blocks the login, switch to Option B.
Option B — Session cookies (more reliable, requires a laptop/desktop)
Cookies are a saved login session — they're harder for X to block than a password login.
- Open x.com in Chrome or Firefox on your laptop or desktop and make sure you're logged in
- Install the Cookie-Editor extension: cookie-editor.com
- Click the Cookie-Editor icon in your browser toolbar
- Click Export → Export as JSON
- Copy everything — that's your cookies. You'll paste it in Step 4.
If you only have a phone, use Option A and skip the cookies.
The bot uses free AI services to write tweets. Get keys from:
- Gemini (primary): aistudio.google.com/app/apikey — sign in with Google, click "Create API key", copy it
- OpenRouter (backup): openrouter.ai/keys — sign up free, create a key, copy it
In your forked repo: Settings → Secrets and variables → Actions → New repository secret
Add each of these:
| Name | What to put in it |
|---|---|
TWITTER_USERNAME |
Your X username (no @ symbol) |
TWITTER_PASSWORD |
Your X password |
TWITTER_COOKIES |
The cookie JSON from Step 2 Option B — skip if using Option A |
GEMINI_API_KEY |
Your Gemini key from Step 3 |
OPENROUTER_API_KEY |
Your OpenRouter key from Step 3 |
Each account gets its own workflow file. Duplicate any of the post_*.yml files under .github/workflows/ and give it a name that matches the account, e.g. post_mySecondAccount.yml.
In that file, set the env: block to use its own set of secrets:
env:
TWITTER_USERNAME: ${{ secrets.MY_SECOND_ACCOUNT_TWITTER_USERNAME }}
TWITTER_PASSWORD: ${{ secrets.MY_SECOND_ACCOUNT_TWITTER_PASSWORD }}
TWITTER_COOKIES: ${{ secrets.MY_SECOND_ACCOUNT_TWITTER_COOKIES }}Then add those three secrets in GitHub (same place as Step 4) with the matching names. Each workflow runs independently on its own schedule — no other changes needed.
In your forked repo: Settings → Secrets and variables → Actions → Variables tab → New repository variable
| Name | Value | What it means |
|---|---|---|
POST_MODE |
mixed |
Rotates between news, tips, memes, and engagement |
MAX_ARTICLE_AGE_HOURS |
7 |
Only post articles from the last 7 hours |
MAX_TWEETS_PER_RUN |
5 |
Post up to 5 tweets per run |
You can also set
POST_MODEtonews,creator,meme, orengageif you only want one type.
Go to Settings → Actions → General, scroll to Workflow permissions, select Read and write permissions, and click Save.
This lets the bot remember which articles it already posted so it doesn't repeat itself.
Go to the Actions tab in your repo. If you see a banner saying workflows are disabled, click Enable.
The bot will now run automatically:
- Every 6 hours to post content
- Every 30 minutes to engage with other people's posts
To test it right now: Actions → pick a workflow → click Run workflow
Cookies expire after 30–90 days. When the bot stops working, just:
- Go to x.com, log in
- Export cookies again with Cookie-Editor
- Go to your repo → Settings → Secrets → TWITTER_COOKIES → click Update → paste new cookies
Bot says "session invalid" — If you're using cookies (Option B), they expired. Follow the "Updating Your Cookies" steps above. If you're using username/password (Option A), X may have temporarily blocked automated logins — wait a few hours and try again, or switch to cookies.
Bot isn't posting anything — Check the Actions tab, click on a recent run, and look at the logs. The most common cause is missing secrets or cookies that need refreshing.
Posts keep repeating — Make sure Step 6 (workflow permissions) is done. Without it the bot can't save which articles it already used.
I only want news posts / only want engagement — Change the POST_MODE variable (Step 5) to news or engage.