Download Β· Clip Β· Summarize Β· Study Β· Chat β all from Telegram.
Features β’ Quick Start β’ Configuration β’ Architecture β’ Commands β’ Troubleshooting β’ Contributing
RaiX is a self-hosted, button-driven Telegram bot that turns any video link into actionable content β downloads, clips, AI summaries, interactive quizzes, flashcards, and more. It is designed to run 24/7 on a Raspberry Pi or any Linux VPS with zero maintenance.
No commands to memorize. Paste a link β pick an action β done.
Two services, one folder. The Express API backend (
backend.js) handles yt-dlp, ffmpeg, and AI. The Telegram bot (bot/) presents it all through inline buttons. Both run under PM2 and share a single.env.
|
|
|
|
|
|
| Requirement | Minimum | Notes |
|---|---|---|
| OS | Debian 11+ / Ubuntu 20.04+ / Raspberry Pi OS | Any Linux with apt |
| Node.js | v18+ | Installed automatically by setup.sh |
| RAM | 1 GB | 2 GB+ recommended for concurrent clips |
git clone https://github.com/raimohan/raixyt.git
cd raixyt
chmod +x setup.sh
./setup.shThe setup script automatically installs:
| Component | Purpose |
|---|---|
| Node.js 20 | Runtime for backend + bot |
| yt-dlp | Video extraction (private virtualenv) |
| ffmpeg | Audio/video muxing & clip re-encoding |
| Deno | YouTube n-challenge solver |
| PM2 | Process manager β keeps everything alive 24/7 |
After setup, edit .env with your tokens:
# Required
BOT_TOKEN=your-token-from-botfather
OWNER_ID=your-telegram-numeric-id
# AI (free tier is enough)
GROQ_API_KEY_1=your-groq-api-keyThen start:
./setup.sh --startπ‘ Tip: Send
/idto your bot (or to @userinfobot) to find your numeric Telegram ID.
./setup.sh # Full install + start
./setup.sh --no-start # Install only, configure later
./setup.sh --start # Skip install, just (re)start services
./setup.sh --update # Update yt-dlp + npm deps + restart
./setup.sh --skip-apt # Skip apt packages (re-runs)All configuration lives in a single .env file. Copy from the template:
cp .env.example .envπ Full Environment Variable Reference
| Variable | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
β | β | Token from @BotFather |
OWNER_ID |
β | β | Your numeric Telegram ID |
ADMIN_IDS |
β | Comma-separated admin IDs | |
OPEN_ACCESS |
false |
Set true to allow anyone |
|
BOT_NAME |
RaiX Studio |
Shown in the welcome screen |
| Variable | Required | Default | Description |
|---|---|---|---|
PORT |
3000 |
API server port | |
API_BASE |
http://127.0.0.1:3000 |
Bot β backend URL | |
ADMIN_TOKEN |
β | Token for /api/admin/* routes |
| Variable | Default | Description |
|---|---|---|
GROQ_API_KEY_1 β¦ _10 |
β | Up to 10 Groq keys (auto-rotate) |
GROQ_MODEL |
llama-3.3-70b-versatile |
Primary model |
GROQ_MODEL_FALLBACKS |
llama-3.3-70b-versatile,llama-3.1-8b-instant |
Fallback chain |
AI_PROVIDER |
auto-detect | Force groq or openrouter |
OPENROUTER_API_KEY_1 β¦ _5 |
β | Up to 5 OpenRouter keys |
| Variable | Default | Description |
|---|---|---|
MAX_UPLOAD_MB |
49 |
Telegram's 50 MB bot upload limit |
MAX_CONCURRENT_JOBS |
2 |
Simultaneous heavy jobs |
THROTTLE_MAX |
4 |
Rate limit per window |
THROTTLE_WINDOW_MS |
1000 |
Rate limit window |
API_TIMEOUT_MS |
180000 |
API call timeout |
DOWNLOAD_IDLE_TIMEOUT_MS |
240000 |
Stalled transfer timeout |
raixyt/
β
βββ backend.js # Express API server (yt-dlp + AI + clips)
βββ ecosystem.config.js # PM2 process definitions
βββ setup.sh # One-shot installer
βββ package.json
βββ .env.example # Configuration template
β
βββ bot/ # Telegram bot (Telegraf)
βββ index.js # Entry point, middleware, graceful shutdown
βββ config.js # Environment parsing & validation
β
βββ api/
β βββ client.js # Typed HTTP wrapper over backend.js
β
βββ core/
β βββ router.js # Callback/text/document dispatch + error boundary
β βββ flow.js # Shared "send me a link / text" prompts
β βββ cache.js # Token store for oversized callback payloads
β βββ session.js # Per-user state & chat history
β βββ queue.js # Concurrency limiter for heavy jobs
β
βββ middleware/
β βββ auth.js # Access gate (owner β admin β user)
β βββ throttle.js # Per-user rate limiter
β
βββ services/
β βββ users.js # User registry & persistence
β βββ prefs.js # Per-user preferences
β βββ stats.js # Usage counters
β βββ downloads.js # Streaming download pipeline
β
βββ ui/
β βββ render.js # Message renderer & progress bars
β βββ keyboards.js # Inline keyboard builder
β βββ text.js # Shared copy & formatting
β
βββ features/ # Self-registering feature modules
βββ home.js # Main menu & welcome screen
βββ video.js # π¬ Video search & download
βββ music.js # π΅ Music search & download
βββ downloader.js # β¬οΈ Universal link downloader
βββ clip.js # βοΈ Clip Studio (trim + reframe)
βββ subtitles.js # π Subtitle extraction
βββ ai.js # π§ AI Studio (summarize, tags, titles, descriptions)
βββ study.js # π Study tools (quiz, flashcards, notes, plan)
βββ chat.js # π¬ Video Chat (conversational Q&A)
βββ analytics.js # π Channel & video insights
βββ course.js # π Course discovery
βββ settings.js # βοΈ User preferences
βββ admin.js # π Owner Panel (users, cookies, services)
ββββββββββββββββ HTTP/JSON ββββββββββββββββββββ
β β ββββββββββββββββββββΊ β β
β Telegram β β backend.js β
β Bot (bot/) β β (Express API) β
β β β β
β β’ Telegraf β β β’ yt-dlp β
β β’ Buttons β β β’ ffmpeg β
β β’ Sessions β β β’ Groq/OpenRouterβ
β β’ Progress β β β’ Cron jobs β
β β β β
ββββββββ¬ββββββββ ββββββββββ¬ββββββββββ
β β
β Telegram Bot API β Spawns
βΌ βΌ
ββββββββββββ βββββββββββββββ
β Telegram β β yt-dlp β
β Servers β β ffmpeg β
ββββββββββββ β deno/node β
βββββββββββββββ
Adding a feature = one file in
bot/features/, register routes withrouter.onMany({...}), add a button to the home menu. Nothing else changes.
| Command | Description |
|---|---|
/start |
Open the main menu |
/menu |
Back to the main menu |
/id |
Show your Telegram ID |
/cancel |
Cancel the current action |
pm2 logs raix-bot # Follow bot logs
pm2 logs raix-api # Follow API logs
pm2 restart raix-bot # Restart the bot
pm2 restart raix-api # Restart the API
pm2 monit # Live CPU/RAM dashboard
pm2 status # Process overviewπ‘ Pro tip: The Owner Panel can restart either service directly from your phone β no SSH needed.
The backend uses Netscape-format cookie files for authenticated downloads.
| File | Platforms |
|---|---|
youtube.txt |
YouTube, Twitter/X, TikTok, Facebook, Vimeo, Pinterest, Snapchat |
instagram.txt |
- Install a "Get cookies.txt LOCALLY" browser extension
- Log in to the platform and export cookies
- Upload via Telegram: Owner Panel β πͺ Cookies β Upload
The file is validated, written with 0600 permissions, and picked up immediately β no restart needed.
β οΈ Warning: An empty cookie file is worse than none β yt-dlp aborts on a rejected jar instead of falling back to anonymous access. Delete empty cookie files.
| Platform | Download | Cookies Needed |
|---|---|---|
| YouTube | β | Recommended |
| β | Required | |
| Twitter / X | β | Recommended |
| TikTok | β | Optional |
| β | Optional | |
| Vimeo | β | Optional |
| β | Optional | |
| Snapchat | β | Optional |
Powered by yt-dlp β any site yt-dlp supports will work.
Bot starts then exits immediately
BOT_TOKEN or OWNER_ID is missing or invalid.
pm2 logs raix-bot --lines 20Check .env for empty values. Get a fresh token from @BotFather.
"The backend is not reachable"
The API server isn't running.
pm2 start raix-api
curl http://localhost:3000/healthEvery YouTube download fails
Usually means no JavaScript runtime for the YouTube n challenge solver.
./deno --version # Should print deno version
./setup.sh --update # Re-install if missingCheck logs for: "n challenge solving failed" β this confirms the runtime is missing.
"Sign in to confirm you're not a bot"
Cookies are stale. Re-export from your browser and upload via Owner Panel β Cookies.
Downloads are slow
Expected on a Raspberry Pi for 1080p β yt-dlp downloads video + audio separately, then ffmpeg muxes them. 720p is ~3Γ faster.
Out-of-memory restarts
Lower the concurrency in .env:
MAX_CONCURRENT_JOBS=1Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Check all files for syntax errors
npm run check
# Start the backend only
npm start
# Start the bot only
npm run botThis project is open source. See the LICENSE file for details.
![]() @raimohan |
If you found this useful, consider giving it a β
