A Telegram bot for searching and accessing course notes by subject name or code from Notezy.online.
- π Advanced Search - Smart search with scoring and fuzzy matching
- π€ AI-Powered Enhancement - Grok AI integration for intelligent responses
- π Quick access to study materials via branch page links
- π Smart Greetings - Recognizes 40+ greeting patterns in multiple languages
- π Semester Queries - Direct links to semester pages (e.g., "4th sem", "for 3rd sem")
- π Auto-Sync - Automatically sync new notes from MongoDB
- π Fast and responsive with MongoDB backend
- π Integration with Notezy.online
- βοΈ Render Deployment - Ready for cloud deployment
- Query Enhancement - AI analyzes and improves search queries for better results
- Personalized Greetings - Context-aware greetings based on time and user
- Smart Suggestions - AI-generated alternatives when searches return no results
- Study Tips - Personalized study advice for engineering students
- Feedback Prompts - AI-generated specific questions to improve the bot
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
- Copy
.env.exampleto.envand add your credentials - Set
BOT_TOKENandMONGODB_URI - Optional: Set
GROK_API_KEYfor AI features (get from https://console.groq.com)
- Copy
-
Import notes from MongoDB:
python import_notes.py # Choose option 6 (MongoDB import) -
Test AI integration (optional):
python test_ai.py
-
Run the bot:
python bot.py
/start- Welcome message with usage instructions/sync- Manually sync new notes from database (admin only)
- Subject Search: Send any subject name or code (e.g., "18CS51" or "Data Structures")
- Semester Links: Send "4th sem", "for 4th sem", "chemistry cycle", etc.
- Greetings: Send "hi", "hello", "namaste", "good morning", etc.
18CS51β Direct match for Data Structuresbiologyβ All biology-related subjectsmachine learningβ AI/ML subjects4th semβ Direct links to all 4th semester brancheschemistry cycleβ 1st semester (Chemistry Cycle) branches
Recognizes greetings in multiple languages:
- Basic: hi, hello, hey, hai, hii, helo
- Time-based: good morning, good afternoon, good evening, good night
- Cultural: namaste, namaskar, vanakkam, salaam, assalamualaikum
- Casual: howdy, sup, yo, wassup, what's up
- International: greetings, welcome, bonjour, hola, ciao, aloha
Direct access to semester pages:
4th semβ 4th Semester branchesfor 3rd semβ 3rd Semester brancheschemistry cycleβ 1st Semester (Chemistry Cycle)physics cycleβ 2nd Semester (Physics Cycle)
Search Strategies:
- Exact Code Match - "18CS51" finds exact subject
- Exact Name Match - "Data Structures" finds exact subject
- Partial Matches - "data" finds all data-related subjects
- Smart Scoring - Results ranked by relevance
# Run periodically to sync new notes
python auto_sync.pySend /sync command to the bot (admin only)
- β Checks for new notes in source MongoDB
- β Adds only new notes (no duplicates)
- β Updates bot database instantly
- β Logs sync results
Webhook deployment prevents multiple instance conflicts and is more reliable for production.
- Push code to GitHub/GitLab
- Go to render.com
- New β Blueprint β Connect your repo
- Set environment variables:
BOT_TOKEN- Your Telegram bot tokenMONGODB_URI- MongoDB connection stringWEBHOOK_URL- Your Render service URL (will be auto-generated)GROK_API_KEY- Optional: Groq API key for AI features
- Deploy - The
render.yamlfile handles the webhook setup automatically!
For development or testing, use polling mode:
- Service Type: Web Service
- Runtime: Python 3
- Build Command:
pip install -r requirements.txt - Start Command:
python start.py
- Environment Variables:
BOT_TOKEN,MONGODB_URI(no WEBHOOK_URL needed)
The bot automatically chooses the deployment mode:
- Webhook Mode: When
WEBHOOK_URLis set (Production) - Polling Mode: When
WEBHOOK_URLis not set (Development)
start.py- Auto-detects deployment modewebhook_bot.py- Webhook implementationbot.py- Polling implementationrender.yaml- Render webhook configuration
Source MongoDB (test.notes):
{
"subject": "Biology for Engineers (BBOK407/BBOC407)",
"sem": "Sem4",
"department": ["computerscience", "electronics", ...],
"fileUrl": "https://drive.google.com/...",
"title": "Module 1"
}Bot Database (processed):
{
"subject_code": "BBOK407",
"subject_name": "Biology for Engineers",
"branch_url": "/Sem4/computerscience",
"semester": "Sem4",
"branch": "Computer Science"
}bot.py- Main bot with polling mode (development)webhook_bot.py- Webhook-based bot (production)start.py- Auto-deployment mode selectordatabase.py- MongoDB handler with sync functionalityauto_sync.py- Automatic sync scriptimport_notes.py- Import tools for MongoDBrender.yaml- Render webhook deployment configurationrequirements.txt- Python dependencies.env- Environment variables (not in repo)
The bot uses these branch URLs:
https://www.notezy.online/Sem4/computersciencehttps://www.notezy.online/Sem5/mechanical- etc.
Create a .env file in the project root with the following variables:
# Required
BOT_TOKEN=your_telegram_bot_token
MONGODB_URI=your_mongodb_connection_string
# Optional - for AI features (Groq)
GROK_API_KEY=your_groq_api_key
# For webhook deployment (Render)
RENDER_EXTERNAL_HOSTNAME=your-app.render.com
PORT=8080
# For admin features
ADMIN_USER_ID=your_telegram_user_id- BOT_TOKEN: Create a bot via @BotFather on Telegram
- MONGODB_URI: Get from MongoDB Atlas (free tier available)
- GROK_API_KEY: Get from Groq Console (optional, for AI features)
- Search is case-insensitive
- Partial matches work great (e.g., "math" finds all math subjects)
- Branch links keep users on your website for page views
- Sync automatically handles new notes without downtime
- Bot responds to greetings in multiple languages
- Semester queries provide direct access to branch pages
- AI features enhance user experience but bot works without them
- Webhook-based auto-sync
- User feedback collection
- Download statistics tracking
- Admin panel for note management
- Multi-language support expansion