📚 Telegram Study Schedule Bot - Setup Guide
This is a fully automated Telegram bot that helps users plan their study schedule with daily reminders at 7 AM.
Features
- ✅ Manual
/startcommand - Begin scheduling anytime (for testing) - ✅ Daily 7 AM automatic trigger - Sends schedule prompts automatically
- ✅ Interactive subject selection - Choose from 7 subjects across 4 time slots
- ✅ Auto-generated timetable - Bot creates and displays your complete schedule
Time Slots
- Slot 1: 8:30 AM - 11:00 AM
- Slot 2: 12:10 PM - 2:00 PM
- Slot 3: 2:40 PM - 5:40 PM
- Slot 4: 7:30 PM - 10:00 PM
Available Subjects
- 1. Aerodynamics
- 2. Space Dynamics
- 3. Propulsion
- 4. Structures
- 5. Flight Mechanics
- 6. Mathematics
- 7. Aptitude
1️⃣ Create a Telegram Bot (2 minutes)
- Open Telegram app
- Search for "BotFather" (official Telegram bot for creating bots)
- Type
/newbot - Choose a name (e.g., "Study Schedule Bot")
- Choose a username (must be unique, e.g., "study_schedule_bot_123")
- Copy the API Token - looks like:
123456789:ABCDefGhijKlmnoPqrsTuvWxyz-1A2B3C4D
2️⃣ Deploy Your Bot
Option A: Deploy to Vercel (Recommended - Free)
- Push your code to GitHub
- Go to vercel.com
- Click "New Project" and import your GitHub repository
- Add environment variables in Vercel dashboard:
TELEGRAM_BOT_TOKEN: Paste your API token from BotFatherCRON_SECRET: Create any random string (e.g., "your-super-secret-key-123")
- Deploy!
Your webhook URL will be: https://your-project.vercel.app/api/telegram
Option B: Run Locally
- Create
.env.localfile:
TELEGRAM_BOT_TOKEN=123456789:ABCDefGhijKlmnoPqrsTuvWxyz-1A2B3C4D CRON_SECRET=your-super-secret-key-123
- Run:
npm run dev - Your local URL:
http://localhost:3000/api/telegram - Use a service like ngrok to expose locally:
ngrok http 3000
3️⃣ Set Webhook URL
The webhook URL tells Telegram where to send user messages.
Using BotFather (Easiest):
- Open Telegram, message BotFather
- Type
/mybots→ select your bot → "API Token" - Go back to chat and type
/setwebhook - Send your webhook URL:
https://your-project.vercel.app/api/telegram - BotFather will confirm: "Webhook was set"
Using cURL:
curl -X POST https://api.telegram.org/bot{YOUR_TOKEN}/setWebhook \
-H "Content-Type: application/json" \
-d '{"url":"https://your-project.vercel.app/api/telegram"}'4️⃣ Set Daily 7 AM Reminder (Cron Job)
Your bot will send daily prompts to all users at 7 AM. Use a free cron service:
Using cron-job.org (Free - Recommended):
- Go to cron-job.org
- Sign up (free)
- Click "Create Cronjob"
- Fill in:
- Title: "Study Bot Daily Reminder"
- URL:
https://your-project.vercel.app/api/cron/schedule - Request Method:
POST - HTTP Headers: Add custom header:
- Key:
x-cron-secret - Value: The secret from your
CRON_SECRETenv variable
- Key:
- Schedule: Set to run daily at 7:00 AM (choose your timezone)
- Save!
Using Upstash (Free - Alternative):
- Go to upstash.com
- Sign up and create a QStash project
- Create a scheduled message:
- Endpoint:
https://your-project.vercel.app/api/cron/schedule - Schedule:
0 7 * * *(7 AM daily) - Headers:
x-cron-secret: your-secret-key - Method:
POST
- Endpoint:
5️⃣ Test Your Bot
- Open Telegram
- Search for your bot (the username you created)
- Click "Start"
- Or send the message:
start - Select subjects for each time slot
- Bot will show your complete schedule!
Test Manual Start Anytime:
- Type
/start→ Bot will reset and start the schedule process again - Perfect for testing!
How It Works
User Interaction Flow:
User sends /start
↓
Bot asks: "Select subject for Slot 1 (8:30 AM - 11:00 AM)"
↓
User clicks a subject button
↓
Bot asks: "Select subject for Slot 2 (12:10 PM - 2:00 PM)"
↓
User clicks a subject button