AI Email Assistant on Telegram
- When
- November 2026
- Kind
- Side project
A private assistant I built for my own inbox. It watches Gmail, sorts mail into a to-do list and does mail chores through a Telegram chat. It can do a lot, and it is built so that it can do nothing outward without my tap.
Problem
An assistant that can read and send your email is only useful if you can trust it. A model that can send is one confused or hostile message away from sending the wrong thing, so the safety has to live in code, not in the prompt.
Highlights
- Nothing outward happens without a tap: the chat agent has no send tool, and a test fails if any tool could send. Outward steps are stored as pending actions with a preview, and only the Confirm tap runs the stored payload, once.
- Every change to the mailbox is written to a change log with the previous state, so Undo restores labels, trash, snooze or a calendar event for 7 days. No permanent delete exists.
- Email is treated as data, never as instructions. Secrets stay out of prompts, and for locked PDFs the model sees only the names of the facts it has.
- Built for personal use, but designed so each person's data stays separate: their own folder, database, chat history and Gmail tokens. Strangers who message the bot get a fixed introduction and never reach the database or a model.
- Routine sorting runs as a background pipeline on low-cost models with fallbacks, and conversation is a separate agent with tools. If every model is down, mail stays in the inbox and is retried.
- Runs in Docker on a private machine. It uses Telegram long polling and a tiny sign-in relay, so no port is opened to the internet.
- More than 1,300 automated tests, with fake models and fake Gmail.
Nothing sent without a tapEnforced in code, with a test that fails if any chat tool could send.
Stack
Architecture
Screens





What I learned
- Put the rule in code, not in the prompt: a test that fails if any tool could send is stronger than an instruction not to.
- Split routine work from conversation. A pipeline sorts the mail, an agent talks, and neither does the other's job.
- Ask for permissions late and in plain language, at the moment a feature needs them.