Get Started in Minutes
This guide will walk you through setting up and deploying your Telegram Subscription Manager bot as quickly as possible.Prerequisites: Make sure you have Node.js 18+, a Telegram account, MongoDB Atlas account, and Paystack account ready.
Setup Process
Create Your Telegram Bot
Open Telegram and message @BotFather:
- Send
/newbotcommand - Choose a name for your bot (e.g., “VIP Subscription Bot”)
- Choose a username (must end in “bot”, e.g., “myvipchannel_bot”)
- Copy the bot token (format:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
Get Your Channel ID
You need to get the ID of your private Telegram channel:
- Forward any message from your channel to @userinfobot
- The bot will reply with channel details
- Copy the channel ID (format:
-100xxxxxxxxxx) - Add your bot as an administrator to the channel
- Grant these permissions:
- ✅ Invite users via link
- ✅ Restrict members (ban/unban)
Configure Environment Variables
Create a
.env.local file in the project root:.env.local
Where to get these values
Where to get these values
- TELEGRAM_BOT_TOKEN: From BotFather (Step 1)
- TELEGRAM_CHANNEL_ID: From userinfobot (Step 3)
- PAYSTACK_SECRET_KEY: From Paystack Dashboard → Settings → API Keys
- DATABASE_URL: From MongoDB Atlas → Database → Connect → Application
- CRON_SECRET: Generate a random string (e.g., use
openssl rand -hex 32in terminal)
Setup MongoDB Database
Initialize your database schema:
MongoDB doesn’t use migrations like SQL databases. The
db push command creates or updates collections based on your schema.Setup Webhook (Development)
For local testing, use ngrok to create a public URL:Copy the HTTPS URL (e.g., Or visit this URL in your browser:You should see:
https://abc123.ngrok.io) and set the webhook:Test Your Bot
Open Telegram and message your bot:
- Send
/start- You should see the welcome message with plan details - Send
/pay- Provide an email and receive payment buttons - Click a payment button - Complete a test transaction on Paystack
- Send
/verify_basic <reference>- The bot should verify and send an invite link
Deploy to Production
- Vercel
- Other Platforms
Deploy to Vercel (Recommended)
Import to Vercel
- Go to vercel.com and sign in
- Click “Add New” → “Project”
- Import your GitHub repository
- Click “Deploy”
Add Environment Variables
In Vercel dashboard:
- Go to your project → Settings → Environment Variables
- Add all variables from your
.env.localfile - Update
NEXT_PUBLIC_APP_URLto your Vercel domain (e.g.,https://your-bot.vercel.app) - Redeploy the project
Configure Cron Job
Create This runs the expiry check every hour at minute 0.
vercel.json in your project root:vercel.json
Vercel automatically handles SSL certificates, so your webhook URL will be HTTPS (required by Telegram).
Verification Checklist
Before going live, verify everything works:Bot Functionality
Bot Functionality
-
/startshows welcome message with all plans -
/paycollects email and shows payment buttons - Payment links open correctly in browser
- Test payments are processed by Paystack
-
/verify_basicverifies payment and sends invite link - Invite links allow joining the channel
-
/statusshows correct subscription details -
/helpdisplays help information
Admin Features
Admin Features
- Set your admin user ID in
src/lib/config.ts(line 52) - Test
/broadcastsends messages to all users - Test
/botstatsshows user statistics - Test
/checkuserlooks up user subscriptions
Security
Security
- Environment variables are not committed to git
-
.env.localis in.gitignore - Paystack webhook signature verification is enabled
- Cron endpoint is protected with
CRON_SECRET - Bot token is kept secret
Subscription Expiry
Subscription Expiry
- Cron job is configured to run hourly
- Test that expired subscriptions are detected
- Users are removed from channel when expired
- Expiry notifications are sent to users
Common Issues
Bot doesn't respond to commands
Bot doesn't respond to commands
Possible causes:
- Webhook URL is incorrect or not set
- Server is not running or unreachable
- Bot token is invalid
- Environment variables not loaded
- Check webhook status:
curl https://api.telegram.org/bot<TOKEN>/getWebhookInfo - Verify server is running and accessible
- Check server logs for errors
- Confirm environment variables are set correctly
Invite links don't work
Invite links don't work
Possible causes:
- Bot is not an admin in the channel
- Bot lacks “Invite users” permission
- User is banned from the channel
- Verify bot is admin with correct permissions
- Try unbanning the user manually first
- Check channel ID is correct (must start with
-100)
Payment verification fails
Payment verification fails
Possible causes:
- Paystack secret key is incorrect
- Transaction reference is invalid
- Payment status is not “success”
- Payment amount doesn’t match plan
- Verify Paystack secret key is correct
- Check payment status in Paystack dashboard
- Ensure reference is copied correctly
- Check payment amount matches expected plan amount
Cron job not running
Cron job not running
Possible causes:
- Cron not configured on hosting platform
CRON_SECRETmismatch- Endpoint returns error
- Verify
vercel.jsoncron configuration - Check Vercel cron logs in dashboard
- Manually test endpoint:
curl -H "Authorization: Bearer <CRON_SECRET>" https://your-bot.vercel.app/api/cron/remove-expired
Next Steps
Customize Plans
Learn how to modify pricing and features
Setup Premium Features
Configure the MT5 Auto Copier integration
API Reference
Explore webhook endpoints and integrations
Troubleshooting
Detailed solutions for common problems