Skip to content

shhalaka/x-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Account X (Twitter) Automation Bot

This project is a Node.js + TypeScript based automation system for managing multiple X (Twitter) accounts from a single codebase. It is designed to safely automate posting and engagement actions while respecting X API limits and account isolation.

The system was built as part of an internship task to demonstrate real-world API integration, multi-account handling, scheduling, and reliability.

Features

  • Multi-account support (Marketing, Community Manager, Founder)
  • Independent API credentials per account
  • X API v2 integration
  • Supported actions:
    • Post tweets
    • Retweet / Quote tweet
    • Reply to tweets
    • Like tweets (with error handling for API restrictions)
  • CLI-based manual execution
  • Cron-based scheduling
  • Config-driven behavior
  • JSON-based logging
  • Rate-limit awareness and guardrails

Overview

The system is designed with clear separation of concerns:

  • Accounts: Each X account has its own API keys, tokens, schedules, and guardrails.
  • Actions: Posting, replying, liking, and retweeting are implemented as separate executors.
  • Scheduler: Cron jobs trigger actions independently for each account.
  • CLI: Used for manual testing and controlled execution of actions.
  • Config Layer: Accounts, schedules, and rules are defined using JSON configuration files.
  • Logging: Every action is logged with timestamp, account, action type, and status.

This design ensures that failures or rate limits affecting one account do not impact others.

Project Structure

  • src/actions/ – Tweet, reply, like, retweet executors
  • src/services/ – X API client and helpers
  • src/scheduler/ – Cron-based scheduling logic
  • src/cli.ts – CLI entry point
  • src/utils/ – Logging, guardrails, helpers
  • config/ – Account and action configuration files
  • .env – API keys and secrets (not committed)

Configuration

Environment Variables

All sensitive credentials are stored in a .env file:

* API Key
* API Secret
* Access Token
* Access Token Secret

Each account uses its own set of credentials to ensure proper isolation.

Account Configuration

Accounts, schedules, actions, and guardrails are defined via JSON config files. This allows non-code changes to behavior and makes the system easy to extend.

Running the Project

Install dependencies

npm install

Run CLI commands

npm run cli --

The CLI can be used to manually trigger actions and test account behavior safely.

Scheduler

The scheduler runs cron jobs based on the configuration and executes actions automatically for each account.

Rate Limits & Guardrails

  • Built-in spacing between actions
  • No aggressive retries on failure
  • Graceful handling of API errors
  • Prevents spam-like behavior

Some actions (such as likes) may return 403 due to X API policy restrictions. These cases are handled safely and logged without breaking the system.

Logging

All actions are logged in JSON format, including:

  • Timestamp
  • Account name
  • Role
  • Action type
  • Status (success/failure)
  • Tweet ID or error message

This helps with debugging, auditing, and monitoring execution.

Known Limitations

  • Like actions may be restricted by X API permissions and can return 403 errors.
  • Content generation is manual or config-driven; AI-based generation is not included.

Future Enhancements (Optional)

  • AI-based tweet generation
  • Web dashboard
  • Analytics and engagement tracking
  • News or trend-based auto posting
  • Multi-language support

Status

The project meets the task requirements and is stable for multi-account automation using real X API v2 integration.

About

Multi-account X (Twitter) automation bot built with Node.js & TypeScript for scheduled posts, replies, likes, and retweets.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors