Turn any topic into a scroll-friendly study feed with audio — inside Telegram.
User sends topic → llm generates cards → Audio is created → Mini App opens in Telegram
GakutoBot/
├── bot/
│ └── main.py # Telegram bot — receives topics, sends Mini App button
├── generator/
│ ├── content.py # Claude API → structured JSON study cards
│ └── audio.py # gTTS → MP3 audio summary
├── api/
│ └── server.py # FastAPI — serves session data, audio, and the webapp
├── webapp/
│ └── index.html # The scroll feed Mini App UI (served by FastAPI)
├── storage/
│ └── sessions/ # Per-session .json and .mp3 files
├── run.py # Starts API + bot together
├── requirements.txt
└── .env.example
git clone https://github.com/johntharian/GakutoBot.git
cd GakutoBot
pip install -r requirements.txtcp .env.example .envEdit .env:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
WEBAPP_BASE_URL=https://your-domain.com- Open Telegram and message @BotFather
- Send
/newbotand follow the prompts - Copy the token into
.env
Telegram Mini Apps must be served over HTTPS. Deploy to one of these for free:
Render (recommended)
- Push your code to GitHub
- Create a new Web Service on render.com
- Set build command:
pip install -r requirements.txt - Set start command:
python run.py - Add your environment variables in the Render dashboard
- Your URL will be
https://your-app-name.onrender.com
Railway
railway upFly.io
flyctl launch
flyctl deploy- Message @BotFather
- Send
/newapp - Select your bot
- Set the Web App URL to your deployed server URL (e.g.
https://your-app.onrender.com)
Set WEBAPP_BASE_URL in your .env (and in your hosting dashboard) to your deployed HTTPS URL.
python run.pyFor local development with Telegram Mini Apps, you need HTTPS. Use ngrok:
ngrok http 8000
# Copy the https URL and set it as WEBAPP_BASE_URL in .env- User sends a message to the bot with any topic
- Bot calls LLM (Gemini or Claude) which returns 12-18 structured study cards as JSON
- Bot generates audio using gTTS (text-to-speech) from the card content
- Session is saved as
{session_id}.jsonand{session_id}.mp3 - Bot replies with an inline button that opens the Mini App
- Mini App loads the cards and renders them as a scroll feed with:
- Color-coded card types (concept, analogy, example, quiz, summary)
- Tap-to-reveal quiz cards
- Scroll progress bar
- Sticky audio player with speed control (1×, 1.25×, 1.5×, 2×)
| Type | Purpose | Color |
|---|---|---|
| 📌 Concept | Core definition | Purple |
| 🔗 Analogy | Relates to something familiar | Teal |
| 💡 Example | Real-world application | Green |
| 🔬 Deep Dive | Extra depth | Orange |
| 🧠 Quiz | Tap to reveal answer | Pink |
| ✅ Summary | End recap | Purple |