A Telegram bot that accepts voice messages, transcribes them, and parses workout data (exercise, reps, weight) for logging to a csv or database.
flowchart LR
user([User])
telegram(Telegram Bot)
server([Server])
extractor([Speech2Text + parsing])
logger([Logger])
db([Database])
user -- voice --> telegram
telegram -- webhook --> server
server -- audio --> extractor
extractor -- text --> server
server -- text --> logger
logger --entry--> db
uvpackage manager- A Telegram bot token (from @BotFather)
- Configure the bot token
Create a bot using Telegram's
@BotFather. Grab your token and create a.envfile in the project root with it like this:
TELEGRAM_API_TOKEN=your_telegram_bot_token_here
- Launch Server Make sure you have uv installed in your machine.
Run this on your terminal (at project root level):
./run_server.shThat will set up the venv, install dependencies and launch the server that communicates with your telegram bot.
You can healthcheck the server typing /health on your telegram bot chat.
The bot will listen for voice, messages and commands (start with /).
You can send a voice message describing your workout. The bot transcribes it, parses the result, and logs it into the database/csv file.
The bot understands natural language, for example:
- "Press de banca, 10 repeticiones, 80 kilos, categoría pecho"
- "Sentadilla 5 reps 100 kg"
- "Shoulder press 8 repetitions 60 lbs"
These are the commands
/last <exercise>: Returns the most recent logged set for a given exercise, as a JSON code block, for example/last sentadilla./sql <query>: Runs a SQL query againstlog.dband returns the results as a JSON code block. The connection is read-only, so onlySELECTstatements work, for example:
/sql
SELECT * FROM logs
where exercise like "%press%"
order by date desc
LIMIT 10
Launch the database view You can visualize your database and run queries against it using a UI. Run this command to launch the UI:
./launch_db_view.shThis script:
- Imports your latest
log.csvinto a SQLite database calledlog.db(table:logs). - Starts a local Datasette server.
Open your browser on http://127.0.0.1:8001 — you'll see your workouts as an interactive table.