building-a-bot.md
.md file structure of building a simple reply bot on twitter.
Twitter Reply Bot Overview Node.js/TypeScript bot that monitors Twitter accounts for new tweets, generates authentic replies using Claude API, and sends them via Telegram for approval before posting. Accounts are managed dynamically via Telegram bot commands. Tech Stack Runtime: Node.js + TypeScript (tsx) Twitter Reading: RapidAPI twitter241 () Twitter Posting: Official X API v2 () with OAuth 1.0a AI: Claude API (, model: ) Messaging: Telegram Bot API () Database: SQLite via Scheduler: Project Structure Key APIs Reading (RapidAPI twitter241) — resolve username to numeric user ID — fetch user's tweets (requires numeric user ID) Host: Auth: header Posting (Official X API v2) — post tweet/reply Reply format: Auth: OAuth 1.0a (consumer key/secret + access token/secret) Rate limit: 17 tweets per 24 hours (free tier) Database Tables trackedaccounts: , , , pendingreplies: , , , , , , , , , Status values: , , , , , Commands — run with hot reload — run production — type check with tsc — build and run in Docker — stop the container — tail container logs Telegram Commands — show all available commands — start automatic polling — stop automatic polling — run a one-off poll immediately (works even when polling is stopped) — track a new account — stop tracking — show all tracked accounts — show bot stats (polling state, tracked accounts, pending/posted replies, last poll) — fetch a user's latest tweet and generate a reply Reply Approval (plain text — only these patterns are accepted, anything else returns "command not understood") — approve latest pending reply — approve specific reply — reject latest pending reply — reject specific reply — post custom reply for specific ID Regenerate Replies — regenerate latest pending reply or — regenerate specific reply — regenerate latest with instructions — regenerate specific with
~/info