a Telegram bot that turns YouTube links into bite-sized learning snippets via Gemini, with SQLite persistence. Allow users to learn from videos anywhere, anytime, at their convinience.
- include cost report for each note *
./setup.sh (or uv sync) → source .venv/bin/activate.
Before using this, you need to chat with BotFather on Telegram to create a new bot. Add the bot name and token in .env file.
You also need a Gemini dev API for the LLM part.
Finally, find your Telegram chat id by sending a message to the bot and observe the log and add that to allowed list.
.env file
TELEGRAM_BOT_USERNAME=
TELEGRAM_BOT_TOKEN=
GEMINI_API_KEY=
ALLOWED_CHAT_IDS=
uv run python bot.py
- /start → help text shown.
- Send a single short YouTube link (e.g. a 2-min video) → expect
"Watching" → "Note ready" → 5–15 snippet messages.
- Send a message with 3 mixed links (youtu.be + watch?v= + shorts) →
expect 3 sequential processing flows, each producing snippets.
- Write something along with the links to steer learning focus in the note generation process. Example '[url1] [url2] summarize key marketing tips in all these videos'.
- Send "hello" → expect "No YouTube links detected."
- /status → shows correct counts.
fly auth login # if not already
fly launch --no-deploy --copy-config # uses existing fly.toml; pick a unique app name if "gogolearn-bot" is taken
fly volumes create gogolearn_data --region sea --size 1 # SQLite lives at /data/gogolearn.dbCreate a .env file in the project root with your secrets.
Push secrets and deploy:
./deploy.sh --secrets # loads .env → fly secrets set, then fly deploy./deploy.sh # fly deploy only (secrets already set)
./deploy.sh --secrets # re-push secrets + deploy (e.g. after rotating keys)python set_fly_secrets.py # reads .env and runs fly secrets setfly logs # tail
fly status # machine state
fly ssh console # shell into the VM (DB at /data/gogolearn.db)
fly scale count 0 # stop/turn down the deployment
fly scale count 1 # this is a polling bot — keep exactly 1 machinefly.tomlmounts thegogolearn_datavolume at/dataand setsGOGOLEARN_DB=/data/gogolearn.dbso the SQLite file survives deploys/restarts.- No
[http_service]block — the bot uses Telegram long-polling, so no public port is needed. - Run a single machine. Multiple machines polling the same bot token will conflict.
- Never commit
.env— it is listed in.gitignore.