Automatically forward every post from one Telegram channel to multiple target channels — 24/7, hands-free.
- Node.js v18 or higher
- A Telegram Bot token (from @BotFather)
- Your Telegram User ID (from @userinfobot)
- The bot added as Admin in all channels (source + targets)
git clone https://github.com/yourusername/telegram-autoforward-bot.git
cd telegram-autoforward-botnpm installcp .env.example .envOpen .env and fill in your values:
BOT_TOKEN=your_bot_token_here
OWNER_ID=your_telegram_user_id
SOURCE_CHANNEL=
TARGET_CHANNELS=
How to get channel IDs: Forward any message from the channel to @userinfobot — it will show the channel ID.
- Add the bot to your source channel → make it Admin (needs "Post Messages" permission)
- Add the bot to every target channel → make it Admin (needs "Post Messages" permission)
npm start| Command | Description |
|---|---|
/start |
Welcome message |
/status |
View status, uptime & total forwarded |
/channels |
List all target channels |
/add @channel |
Add a new target channel |
/remove @channel |
Remove a target channel |
/pause |
Pause forwarding |
/resume |
Resume forwarding |
/help |
Show all commands |
Only the bot owner (your
OWNER_ID) can run management commands.
- Create a Node.js egg
- Upload all files
- Set environment variables in the Startup tab
- Click Start
- Push code to GitHub
- Connect repo on railway.app
- Add environment variables
- Deploy
- Import the GitHub repo
- Add
.envvalues in the Secrets tab - Run
npm start
npm install -g pm2
pm2 start index.js --name autoforward-bot
pm2 save
pm2 startuptelegram-autoforward-bot/
├── index.js ← Entry point, starts the bot
├── config.js ← Loads and validates .env
├── forwarder.js ← Core forwarding logic
├── commands.js ← Bot command handlers
├── assets/
│ └── welcome.png ← Image shown on /start
├── .env.example ← Config template
├── .gitignore
└── README.md
MIT — free to use and modify.