Day 6: ThreadJarvis

A Telegram bot that writes and posts Twitter threads

NoteProduct: ThreadJarvis

Date: March 7, 2026 Repo: venkatesh3007/threadjarvis Status: ✅ Complete — Telegram bot + Twitter posting, running 24/7

What We Built

ThreadJarvis is a Telegram bot. You send it an idea, it generates a Twitter thread using Claude, and you post the whole thread to X with one tap. No copy-pasting tweets one by one. No manually replying to yourself to build a chain.

The first commit hit at 1:32 PM UTC. By 2:31 PM — about an hour later — v1.0 was done with a landing page.

2,300 lines of JavaScript across 8 files:

index.js    — 948 lines, the bot itself (grammY, commands, inline buttons)
ai.js       — 364 lines, Claude integration (thread generation, hooks, analysis)
scorer.js   — 379 lines, virality scoring engine
viral-knowledge.js — 252 lines, hook templates and algorithm patterns
db.js       — 128 lines, SQLite for prompts, drafts, history
twitter.js  —  63 lines, Twitter API posting (reply chains)

How It Works

You message the bot:

The shift from writing code to architecting systems

The bot sends your idea to Claude with a system prompt you control. Claude returns an array of tweets. The bot displays them with inline buttons: 🚀 Post to Twitter, 🔄 Regenerate, ❌ Cancel.

Hit Post, and the bot calls the Twitter API. It posts the first tweet, gets the ID back, posts the second as a reply to the first, gets that ID, posts the third as a reply to the second. Proper reply chain. One tap.

The System Prompt

The most important file in the bot is the prompt. Not the code — the prompt. You set it with /setprompt and it controls everything about how threads get written.

I set mine to write like me — (venkatesh3007?). Short sentences. First person. Real numbers. No hashtags. No emoji spam. Arguments, not stories.

The prompt is stored in SQLite. Change it anytime. The bot remembers.

The Virality Scorer

Every generated thread gets a score. The scorer checks five dimensions:

  • Hook (30% weight) — Does the first tweet stop the scroll?
  • Structure (25%) — Does momentum build across tweets?
  • Engagement triggers (25%) — Curiosity gaps, pattern interrupts, social proof?
  • Readability (10%) — Short sentences, clear language?
  • CTA (10%) — Does the last tweet drive action?

The viral-knowledge.js file has the cheat sheet — hook templates (contrarian, story, stat, question, bold claim), algorithm factors, engagement patterns. All baked into the scoring engine so you know before you post whether a thread has a chance.

The Commands

Command What it does
Send any message Bot generates a thread from your idea
/thread [idea] Same thing, explicit
/tweet [idea] Single tweet, not a thread
/edit 3 new text Replace tweet #3 in the draft
/post Post the latest draft to Twitter
/regenerate New version of the same idea
/prompt View current system prompt
/setprompt [text] Change the prompt
/hook [idea] Generate 5 hook options
/structure [idea] Outline before writing
/analyze [thread] Score an existing thread
/rewrite [text] Turn any text into a thread

Private by Default

First person to message the bot becomes the owner. Everyone else gets “🔒 This bot is private.” No config needed. Just start the bot and send a message.

There’s also a nudge system — if you haven’t sent anything in 90 minutes, the bot pings you asking if you have any ideas. Configurable via NUDGE_INTERVAL_MINUTES in .env.

What Went Wrong

Twitter API.

The bot generates threads fine. Editing works. Scoring works. The Telegram side is solid. But when you hit Post, you get a 403 from Twitter.

The problem: the Twitter/X API requires your app to be attached to a Project on console.x.com. Not just created — attached to a Project. And the API is pay-per-usage now. No free tier. You load credits into your developer account before any posting works.

We regenerated consumer keys. Regenerated access tokens. Set permissions to “Read and write.” Still 403. The missing piece was the Project attachment, and the console.x.com UI is login-walled — I couldn’t fix it from the server side.

So Day 6 shipped a thread bot that generates and scores threads but couldn’t post them yet. The Telegram-to-Claude pipeline worked. The Twitter pipeline was blocked on a console configuration that needed a human with a browser.

I fixed the Project attachment the next day. Once the app was properly attached to a Project on console.x.com and the access tokens were regenerated with Read+Write permissions, posting worked immediately. The 63 lines of Twitter code didn’t need a single change. The problem was never the code.

The Stack

Node.js, grammY (Telegram), twitter-api-v2, Anthropic Claude API, better-sqlite3. Running as a systemd service on the same $24/month DigitalOcean droplet. Thread generation costs about $0.01-0.05 per thread with Claude Opus.

What I Learned

The API is never the hard part. The API setup is. Writing the Twitter integration was 63 lines. Getting the credentials, permissions, project attachment, and billing right — that took longer than building the entire bot. This is true for every third-party API. The code is trivial. The console is where you lose hours.

System prompts are products. The difference between a generic thread bot and a useful one is entirely in the prompt. Same code, different prompt, completely different output. The prompt is the product. The code is plumbing.

Ship what works, fix the rest tomorrow. The bot generated, scored, edited, and drafted threads on Day 6. Twitter posting was broken. Rather than debug the console for hours, I shipped what worked and fixed the API setup the next morning. It took five minutes once I knew what was wrong. The bot has been fully operational since — generating and posting threads to (venkatesh3007?).