Aigram
Turns your own Telegram account into a self-hosted, installable AI messenger (formerly SakaiBot). Read and send messages with inline media in a glassy web app, and call an LLM right inside any chat — analyze, ask, translate, image, voice. AI results land in a panel, so you decide what to send.
Gallery
The problem
Telegram has no built-in AI, and bolting one on usually means copy-pasting into another app or handing a third-party bot your account. Aigram runs as a userbot on your own account (Telethon) behind a glassy, installable web app: a real messenger you can read and send from, with an AI co-pilot in every chat — your account, your keys, your server.
My role
Built it end-to-end in Python — the Telethon/MTProto core, a FastAPI + vanilla-JS PWA on the same asyncio loop, the multi-provider AI layer, and a single audited send-bridge with ban-safety throttling.
How it works
Engineering highlights
A real, installable messenger
A glassy PWA over your own account: grouped bubbles, inline photos/stickers/voice, reply/edit/forward/delete, live typing and presence pushed over SSE, dark + light — installable to your phone's home screen over a free Cloudflare Tunnel.
AI in every chat — you stay in control
An ✨ AI sheet inside any chat: analyze or ask about its history, prompt (deep-thinking + web search), translate with Persian phonetics, generate images, TTS/STT. Results land in a panel — saved, categorized, and filterable — and nothing is sent until you choose to.
One audited path to Telegram
FastAPI and the Telethon client share one MTProto session on a single asyncio loop, and a single audited bridge is the only code that ever writes to Telegram — with pacing and FloodWait handling for ban-safety.
Stays up under quota limits
Runs on Gemini (primary) with OpenRouter fallback and rotates up to 4 keys per provider; add, test, and hot-swap keys live in the panel with no restart.
Outcomes
- Gives you a real messenger plus an AI co-pilot on your own Telegram account — installable on your phone, with no central party holding your session.
- Runs anywhere cheap: a €1.49 VPS, a home device, Termux, or a Raspberry Pi, with an Iran-friendly deploy path.