⚡ Quick Start - 5 Minutes to Running Bot
1️⃣ Create Telegram Bot (2 min)
- Open Telegram → Search "BotFather"
- Type
/newbot - Give it a name and username
- Copy the API Token (save this!)
Example token: 123456789:ABCDefGhijKlmnoPqrsTuvWxyz-1A2B3C4D
2️⃣ Local Testing (2 min)
- Create
.env.localfile in project root:
TELEGRAM_BOT_TOKEN=your_token_here CRON_SECRET=test-secret-key
- Install dependencies:
npm install - Run locally:
npm run dev
Your bot is now running at: http://localhost:3000
3️⃣ Use ngrok to Expose Locally (1 min)
To test with actual Telegram (not just locally):
- Download ngrok
- Run:
ngrok http 3000 - Copy the HTTPS URL (e.g.,
https://abc123.ngrok.io)
4️⃣ Connect Bot to Your Webhook
Message BotFather on Telegram:
/setwebhook https://abc123.ngrok.io/api/telegram
BotFather will confirm: ✅ "Webhook was set"
5️⃣ Test Your Bot!
- Go to your bot (search by username)
- Click "Start" or type
start - Select subjects for each time slot
- See your schedule appear!
What Works Right Now
- ✅ Manual
/startcommand - test anytime - ✅ Interactive subject selection
- ✅ Auto-generated schedule
- ❌ Daily 7 AM reminder - requires deployed bot (see next step)
Deploy to Production (Optional)
Ready to go live with 7 AM reminders?
Deploy to Vercel (Free):
- Push code to GitHub
- Go to vercel.com
- Import your repository
- Add environment variables:
TELEGRAM_BOT_TOKENandCRON_SECRET - Deploy!
Set Webhook in Telegram:
Message BotFather:
/setwebhook https://your-project.vercel.app/api/telegram
Set Daily Reminder (7 AM):
Go to cron-job.org and create:
- URL:
https://your-project.vercel.app/api/cron/schedule - Method: POST
- Header:
x-cron-secret: your-secret-key - Schedule: 7:00 AM daily
File Reference
| File | Purpose |
|---|---|
lib/telegram-bot.ts | Telegram API calls |
lib/schedule.ts | Store/manage user schedules |
lib/handlers.ts | Handle messages & buttons |
app/api/telegram/route.ts | Webhook endpoint |
app/api/cron/schedule.ts | Daily 7 AM trigger |
Useful BotFather Commands
| Command | What it does |
|---|---|
/newbot | Create a new bot |
/mybots | See your bots |
/setwebhook | Set webhook URL |
/deletewebhook | Remove webhook |
/getwebhookinfo | Check webhook status |