Sparrow is a self-hosted Gmail summarizer for Telegram. It was created to solve a personal problem: receiving too many emails that don't need immediate full-text reading but require a quick scan for action items.
- Language: Python 3.10+
- Telegram Bot API:
python-telegram-bot - Email Interface: Google Gmail API (OAuth2)
- Summarization: Ollama (running
qwen3:4b-instructor similar) - Model Management: Custom
Modelfilefor optimized Telegram formatting
The bot polls linked Gmail accounts periodically. When a new email is detected:
- The full body is extracted via Gmail API.
- It's passed to a local Ollama instance with a specific system prompt.
- A concise summary (Sender, Headline, Action Item) is sent to the user's Telegram chat.
- The message is marked as read in Gmail to prevent duplicate summaries.
- Prerequisites:
- Linux environment (tested on Termux and standard distros)
- Ollama installed and running
- Google Cloud Project with Gmail API enabled
- Setup:
- Clone the repository
- Copy
config.example.pytoconfig.pyand add yourBOT_TOKEN - Place
credentials.jsonfrom Google Cloud in the root directory - Run
pip install -r requirements.txt
- Running:
./run.shwill handle dependencies, model creation, and bot execution.
/start: Welcome and migration detection./help: List available commands./list: See all linked accounts./privacy: Toggle content protection./status: Check bot and system health (Admin only).