Telegram AI Chatbot
Multi-user AI chatbot on a Linux VPS with Gmail OAuth2 integration.
- Python
- Groq API
- Flask
- python-telegram-bot
- systemd
- Linux
- Role
- Solo developer — architecture, build, deployment
- Outcome
- Running in production, handling multi-user sessions with email read/reply from Telegram
Problem
Email and chat live in two different places, and the switching cost between them eats focus. I wanted a single interface — Telegram — where I could have a real conversation with an LLM and read, triage, and reply to email, without juggling an inbox tab. Off-the-shelf bots either locked me into a single model or ignored email entirely, so I decided to build my own.
Approach
The bot is a Python service built around python-telegram-bot for the chat surface and a small Flask app that handles the Gmail OAuth2 consent flow. Incoming messages are routed to the Groq API for completion, with session state scoped per Telegram user so multiple people can use the same instance without leaking context. Gmail integration is wired through Google's official OAuth2 flow, so each user authorizes their own account and tokens are stored per user. The whole thing runs on a Linux VPS under a systemd unit, which gives me auto-restart, journald logging, and zero-touch reboots.
Outcome
It's been running in production and holds up under real use — multi-user sessions stay cleanly separated, and the Gmail integration lets me read and reply to email from Telegram without leaving the thread. The systemd deploy has been effectively maintenance-free, and swapping the LLM backend is a config change rather than a rewrite, which matters as Groq's model lineup shifts. Source is on GitHub.