Learn programming by chatting with an AI tutor that remembers your conversation
Runs 100% on your machine using local AI (Ollama) - no data leaves your computer.
MyClassBot turns Telegram into an interactive coding classroom:
- You send programming questions β Bot replies with explanations/examples
- Remembers your conversation history (unlike basic chatbots)
- Works completely offline - your chats stay private
- Built for teaching: explains concepts step-by-step, gives code examples, helps debug
Example conversation:
You: How do I make a list in Python?
Bot: Use square brackets! Try: my_list = [1, 2, 3]
You: How do I add an item?
Bot: Use .append(): my_list.append(4) # Now it's [1, 2, 3, 4]
Before starting, verify you have:
| Tool | Version | Install Command | Verify |
|---|---|---|---|
| Node.js | 20+ (LTS) | brew install node (macOS) or nodejs.org |
node --version β v20.x.x |
| Ollama | Latest | ollama.com/download | ollama --version |
| ngrok | Latest | brew install ngrok (macOS) or ngrok.com/download |
ngrok version |
| Telegram | Any | telegram.org/dl | Already have it! |
| Trigger.dev Account | Free | Sign up at trigger.dev | Verify email |
π‘ Mac users with Homebrew: Install all three at once:
brew install node ollama ngrok
Follow these steps exactly to get your bot running in under 5 minutes:
git clone <your-repository-url>
cd MyClassBot
npm installcp .env.example .env
# Edit .env with your values (see next section)Terminal 1 (ngrok - makes your computer accessible):
ngrok http 3000
# β COPY THE HTTPS URL (looks like https://abc123.ngrok-free.app)Terminal 2 (Ollama - your local AI):
ollama serveTerminal 3 (Trigger.dev - processes requests):
npx trigger.dev@latest devTerminal 4 (Webhook - receives Telegram messages):
npm run dev:webhook- Update
.envwith your ngrok URL from Terminal 1:TELEGRAM_WEBHOOK_URL=https://abc123.ngrok-free.app/telegram/webhook
- Register webhook (run once):
npm run register:webhook
- Test in Telegram: Message your bot! π
- Open Telegram β search for
@BotFather - Send
/newbot - Follow prompts to name your bot
- Copy the token (looks like
123456789:ABCdefGHIjklMNOpqrsTUVwxyz) - Paste into
.env:
TELEGRAM_TOKEN=your-token-here
- Go to Trigger.dev Dashboard
- Create a new project (or use existing)
- Click "API Keys" β "Create Development Key"
- Copy the key (starts with
tr_dev_) - Paste into
.env:
TRIGGER_SECRET_KEY=your-key-here
# Download Ollama from ollama.com if not installed
ollama serve & # Start in background
ollama pull qwen2.5:7b # Download the AI model (~4.7GB)
ollama list # Should show qwen2.5:7bngrok http 3000Important: Keep this running! You'll see:
Forwarding https://abc123.ngrok-free.app -> http://localhost:3000
Copy that HTTPS URL (the https://abc123.ngrok-free.app part)
Edit .env with your values:
# FROM TELEGRAM BOTFATHER
TELEGRAM_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
# GENERATE THIS (run: openssl rand -hex 32)
TELEGRAM_WEBHOOK_SECRET=a5098f0b847e374f636ed9312d24655f27f57ab18f0f09286ba7ae2c3fee47f9
# FROM NGROK STEP 4 (UPDATE THIS!)
TELEGRAM_WEBHOOK_URL=https://abc123.ngrok-free.app/telegram/webhook
# FROM TRIGGER.dev DASHBOARD
TRIGGER_SECRET_KEY=tr_dev_0NwSOjW08CX5GpM8cOQO
# KEEP THESE AS IS UNLESS YOU KNOW WHAT YOU'RE DOING
OLLAMA_URL=http://127.0.0.1:11434/api/generate
OLLAMA_MODEL=qwen2.5:7b
CONVERSATION_LOG_PATH=conversations/telegram-conversations.jsonl
CONVERSATION_TRANSCRIPT_PATH=conversations/telegram-conversations.txt
PORT=3000npm run register:webhookYou should see: Telegram webhook registered successfully.
You need 4 terminals open simultaneously:
| Terminal | Command | What It Does |
|---|---|---|
| 1 | ngrok http 3000 |
Creates public URL for Telegram |
| 2 | ollama serve |
Runs your local AI model |
| 3 | npx trigger.dev@latest dev |
Processes requests (your bot's "brain") |
| 4 | npm run dev:webhook |
Listens for Telegram messages |
β οΈ Keep all 4 terminals open while using the bot. Closing any will break the pipeline.
- Open Telegram
- Search for your bot's username
- Tap Start
- Send a message:
"Hello! Can you explain what a variable is in Python?" - Wait 5-15 seconds for response (first response may be slower as model loads)
Here's the exact command sequence for daily use:
# TERMINAL 1: Public tunnel (run first, get URL)
ngrok http 3000
# TERMINAL 2: Local AI server
ollama serve
# TERMINAL 3: Bot's reasoning engine
npx trigger.dev@latest dev
# TERMINAL 4: Message receiver
npm run dev:webhook
# ONE-TIME SETUP (after ngrok URL is known):
# 1. Update .env with your ngrok URL
# 2. Run: npm run register:webhook# 1. FROM @BotFather in Telegram
TELEGRAM_TOKEN=your_telegram_bot_token_here
# 2. GENERATE THIS: openssl rand -hex 32
TELEGRAM_WEBHOOK_SECRET=your_generated_secret_here
# 3. FROM NGROK (UPDATE EVERY TIME YOU RESTART NGROK)
TELEGRAM_WEBHOOK_URL=https://your-ngrok-subdomain.ngrok-free.app/telegram/webhook
# 4. FROM TRIGGER.dev DASHBOARD
TRIGGER_SECRET_KEY=your_tr_dev_key_here
# 5. KEEP DEFAULTS (change only if you know why)
OLLAMA_URL=http://127.0.0.1:11434/api/generate
OLLAMA_MODEL=qwen2.5:7b
CONVERSATION_LOG_PATH=conversations/telegram-conversations.jsonl
CONVERSATION_TRANSCRIPT_PATH=conversations/telegram-conversations.txt
PORT=3000Unlike basic chatbots, MyClassBot actually remembers what you talked about:
- Every exchange gets saved to
conversations/telegram-conversations.jsonl - Before responding, it fetches your last 5 messages with this bot
- It includes that history in the AI's prompt as context
- Result: The AI sees the full conversation flow!
Example:
You: How do I make a loop in JavaScript?
Bot: Use for loops! For example: for(let i=0; i<5; i++){ console.log(i); }
You: How do I stop it early?
Bot: Use break! Like: for(let i=0; i<10; i++){ if(i===5) break; console.log(i); }
- Check all 4 terminals are running without errors
- Look at the Trigger.dev dashboard: cloud.trigger.dev β Your project β "Runs" tab
- Test Ollama directly:
curl -X POST http://localhost:11434/api/generate \ -H "Content-Type: application/json" \ -d '{"model":"qwen2.5:7b","prompt":"Say hello in Python","stream":false}'
- Verify webhook is reachable:
Visithttps://your-ngrok-url.ngrok-free.app/telegram/webhookin browser - should show{"status":"ok"}
- Telegram issues: BotFather Help
- Trigger.dev issues: Docs | Discord
- Ollama issues: GitHub Issues
- ngrok issues: Docs | Status
Your bot is now:
- β Running completely on your computer
- β Remembering your conversation history
- β Ready to help you (or anyone you share it with) learn to code
- β 100% private - no data leaves your machine
Go teach something amazing! π
π‘ Pro tip: Share your bot with friends! Just give them your Telegram username and they can start learning immediately (they'll need to start a chat with your bot first).
Built with β€οΈ for lifelong learners. Questions? Open an issue or reach out!
Last updated: July 18, 2026