Prerequisites
Before installing the Telegram Subscription Manager, ensure you have the following:Node.js 18 or higher
Node.js 18 or higher
The bot requires Node.js 18+ for modern JavaScript features and Next.js 16 compatibility.Check your version:Install/Update Node.js:
- Download from nodejs.org
- Or use nvm for version management
MongoDB Atlas Account
MongoDB Atlas Account
MongoDB is used to store subscriptions, user data, and MT5 configurations.Setup Steps:
- Create free account at mongodb.com/cloud/atlas
- Create a new cluster (M0 free tier is sufficient for most use cases)
- Create a database user with read/write permissions
- Whitelist IP address
0.0.0.0/0(allows connections from Vercel) - Get your connection string (format:
mongodb+srv://username:[email protected]/database)
Paystack Account
Paystack Account
Paystack processes payments from Nigerian users.Setup Steps:
- Sign up at paystack.com
- Complete business verification (required for live mode)
- Go to Settings → API Keys
- Copy your Secret Key (starts with
sk_live_orsk_test_)
Start with test mode (
sk_test_) during development. Switch to live mode (sk_live_) when ready for production.Telegram Account
Telegram Account
You’ll need a Telegram account to create and manage your bot.What you’ll do:
- Create a bot via @BotFather
- Create a private channel for VIP members
- Configure bot commands and permissions
MetaCopier Account (Optional)
MetaCopier Account (Optional)
Required only if you plan to offer Premium plan with MT5 Auto Copier.Setup Steps:
- Sign up at metacopier.com
- Get your API credentials
- Configure master trading account
- Add credentials to environment variables
The bot works perfectly without MetaCopier for Basic, Bi-Weekly, and Monthly plans. Premium features require MetaCopier integration.
Installation Steps
1. Telegram Bot Setup
Create Bot with BotFather
Open Telegram and search for @BotFather:
- Send
/newbotcommand - Provide a display name (e.g., “VIP Signals Bot”)
- Provide a username ending in “bot” (e.g., “vipsignals_bot”)
- Save the bot token provided (format:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
Configure Bot Commands
Tell BotFather about your bot’s commands. Send This enables auto-complete when users type
/setcommands to BotFather, select your bot, then paste:/ in the chat.Create Private Channel
Create a private Telegram channel for your VIP members:
- Open Telegram and create a new channel
- Set it to Private
- Name it (e.g., “VIP Signals Channel”)
- Add some initial content
Get Channel ID
You need the numeric ID of your channel:
- Forward any message from your channel to @userinfobot
- The bot will reply with details including the channel ID
- Copy the ID (format:
-100xxxxxxxxxx)
Channel IDs always start with
-100 for supergroups and channels.Add Bot as Channel Admin
Your bot needs admin permissions to manage the channel:
- Open your private channel
- Go to channel settings → Administrators
- Click “Add Administrator”
- Search for your bot by username
- Grant these permissions:
- ✅ Invite users via link (required for sending invite links)
- ✅ Restrict members (required for banning expired users)
- Save changes
2. Project Setup
Install Dependencies
Install all required npm packages:This installs:
- Next.js 16 (framework)
- Prisma (database ORM)
- React 19 (UI library)
- TypeScript (type safety)
Configure Environment Variables
Create a
.env.local file in the project root:.env.local
How to generate CRON_SECRET
How to generate CRON_SECRET
Generate a secure random string using one of these methods:Using OpenSSL (Mac/Linux):Using Node.js:Using online generator:
Visit random.org and generate a 64-character string.
Initialize Database
Setup your MongoDB database with Prisma:This creates the following collections in MongoDB:
Subscription- Stores all user subscriptionsUser- Tracks all bot usersMt5Setup- Stores MT5 account configurations (Premium)ConversationState- Manages multi-step user flowsPromoCode- Manages promotional codes
MongoDB uses
db push instead of migrations. Changes to prisma/schema.prisma can be applied with npx prisma db push.3. Configure Subscription Plans
Customize plans to match your business model by editingsrc/lib/config.ts:
src/lib/config.ts
Paystack amounts are in kobo (smallest currency unit). ₦1,000 = 100,000 kobo.
4. Configure Bank Details (Optional)
If you want to display bank account information in messages:src/lib/config.ts
5. Set Admin User ID
Set your Telegram user ID to access admin commands:src/lib/config.ts
/broadcast- Send message to all users/broadcast_active- Send to active subscribers only/broadcast_premium- Send to premium users only/broadcast_promo- Send promo offer with payment button/botstats- View bot statistics/checkuser <id|username>- Look up specific user
Development Setup
Local Testing with ngrok
For local development, use ngrok to expose your localhost to the internet:Database Management
Use Prisma Studio to view and edit your database:http://localhost:5555 where you can:
- View all subscriptions
- Manually edit user data
- Delete test records
- Check MT5 configurations
Troubleshooting
Error: Cannot find module 'prisma'
Error: Cannot find module 'prisma'
Solution:
MongoDB connection timeout
MongoDB connection timeout
Possible causes:
- Database URL is incorrect
- IP address not whitelisted
- Database user doesn’t have permissions
- Check your connection string format
- Add
0.0.0.0/0to MongoDB Atlas Network Access - Verify database user has read/write permissions
Bot not responding to commands
Bot not responding to commands
Possible causes:
- Webhook not set
- Server not running
- Bot token invalid
- Check webhook status:
- Verify server is running:
npm run dev - Check server logs for errors
- Confirm
TELEGRAM_BOT_TOKENis correct
Invite links return 'error creating invite link'
Invite links return 'error creating invite link'
Possible causes:
- Bot is not an admin in the channel
- Bot lacks required permissions
- Channel ID is incorrect
- Verify bot is an administrator in the channel
- Check bot has “Invite users via link” permission
- Confirm channel ID starts with
-100 - Test manually creating invite link in Telegram
Payment verification always fails
Payment verification always fails
Possible causes:
- Paystack secret key is wrong
- Using test key in production or vice versa
- Reference format is invalid
- Verify
PAYSTACK_SECRET_KEYis correct - Check you’re using the right key for your environment (test vs live)
- Test with Paystack test cards in test mode
- Check Paystack dashboard for transaction status
TypeScript errors during build
TypeScript errors during build
Solution:
Next Steps
Now that installation is complete:Quick Start
Follow the quick start guide to deploy
Deployment Guide
Deploy to production with Vercel
API Reference
Explore all webhook endpoints
Configuration
Configure environment variables and settings