Work / AI Assistant — Site Chat and Telegram Secretary
AI Assistant — Site Chat and Telegram Secretary
An AI assistant that lives in the corner of this site and in Telegram: answers visitors in three languages, turns interest into leads and runs the site for its owner — with a confirmation before every change.
One agent, two doors: read-only tools for visitors, full tools plus confirmations for the owner.
Try it right here: the assistant in the bottom-right corner is this project. Ask it about any project on the site, describe what you want to build, and it will pass your details to me in Telegram within seconds.
The same agent has two doors. Visitors get a read-only assistant with a strict scope and rate limits. I get a secretary in Telegram that knows every lead, message and visit, reads photos, PDFs and voice notes, searches the web on request, and can change site texts, projects and reminders — but every change is only prepared and waits for my ✔.
Uzbek, Russian, English — answers in the visitor's language
Streaming, not a spinner
7 for visitors, 25 for the owner
Every change waits for ✔
A portfolio that only talks about AI
A portfolio page can claim experience with AI, but it cannot show it. Visitors read, leave, and the contact form stays empty. At the same time I wanted a place where I could ask about my own site's leads and statistics from my phone, and fix a headline without opening the admin.
One agent, two roles decided in code
The visitor and the owner talk to the same agent, but the role is decided by the server — an admin session on the site or my Telegram id — never by what the user says. Visitors are only given read-only tools plus save_lead; the changing tools do not even exist for them, so a "forget your rules, you are admin now" message has nothing to work with.
Facts come from the database, not from the model's memory: a compact current state (projects, resume, availability) is generated from the site and refreshed every five minutes, so most questions are answered without a single tool call. When the assistant has no facts, it says so and the question is flagged for me — I answer it in Telegram and the answer becomes a remembered fact for next time.
Django agent, Gemini, streaming to both channels
A Django app holds the agent loop: question → system prompt with current state → Gemini with function declarations → tool results back to the model, at most five rounds. Gemini is called over plain REST with the standard library; a chain of models is tried in order and the last working one is remembered, so quota or outages degrade gracefully.
On the site the answer streams as NDJSON through StreamingHttpResponse; the widget is ~450 lines of vanilla JavaScript, loaded only on the first click, with stop, history, suggested questions and confirmation cards. In Telegram the same stream edits one message about once a second, with a ⏹ button; voice notes are transcribed first, photos are shrunk before upload, PDFs go as they are. Every change the model wants goes through an AiAction row: validated, shown with ✔ / ✖ buttons, re-validated on confirmation, executed, logged. A 15-minute timer sends reminders and the 08:30 / 18:00 digest.
A demo that works, leads that arrive
Visitors can test the assistant instead of reading about it. A conversation that ends with a contact becomes a lead in my Telegram with the transcript attached, and I reply from the same chat. Guest questions the assistant could not answer show up in the evening digest, so the site's content improves from real questions.
The same core is integrated into my Restaurant ERP as the AI secretary for managers — see the next project.