Full-Stack & AI Engineer

OpenClaw AI: The Autonomous Multi-Account Email Agent

Reduced daily email management time by 84% through fully automated AI classification and conversational UI.

Golang SQLite-vec HTMX Tailwind CSS Google Gemini API Docker Telegram Bot API

πŸ’‘ The Vision: Killing the "Context-Switching Tax"

In the modern digital workspace, managing multiple email accounts is a fragmented, distracting process. Professionals lose hours logging into different web clients, fighting spam, and desperately trying not to miss high-priority messages like job offers or client contracts.

The goal of OpenClaw was to build a centralized, intelligent pipeline that intercepts emails across multiple accounts, understands their semantic meaning, and delivers only what matters via a zero-friction interface.

🧠 The Solution: Conversational UI meets RAG

Instead of building another bloated email web client, I decoupled the processing engine from the interface. OpenClaw runs silently in the background and communicates with the user entirely through a Telegram Bot (supporting both text and voice).

Key Product Features:

  • πŸ“‘ Active Radar (Semantic Tracking): The flagship feature. Users can tell the bot in natural language, "Expect an email from Umbrella Corporation." The AI actively monitors incoming streams. When a match occurs, it bypasses the standard queue and pushes a high-priority alert directly to the user's phone.
  • ✍️ Smart Summaries & Auto-Drafting: Leveraging the Google Gemini API, the agent reads long email threads, extracts the TL;DR, and immediately drafts a context-aware reply in the user's preferred language (Native Bilingual Support: EN/RU). Approving the reply takes one tap.
  • πŸ”— Smart Deep-Linking: Tapping a notification in Telegram doesn't just show text; it uses deep links to open the exact email thread directly within the native Gmail mobile app or web browser, handling multi-account routing flawlessly.
  • 🌍 Native Bilingual Support: The AI dynamically adapts its summaries, responses, and UI based on the user's selected language, ensuring a localized experience.

βš™οΈ Architecture & Engineering Decisions

Building an API wrapper is trivial. Designing a resilient, state-synchronized backend requires deep engineering.

graph TD classDef default color:#000; classDef storage fill:#f9f,stroke:#333,stroke-width:2px,color:#000; classDef external fill:#eee,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5,color:#000; classDef core fill:#bbf,stroke:#333,stroke-width:2px,color:#000; User(["πŸ‘€ User"]) Gmail["βœ‰οΈ Gmail API"]:::external TG["πŸ€– Telegram API"]:::external subgraph OpenClaw ["OpenClaw Core (Go Backend)"] Worker["πŸ”„ Async Worker (Polling)"]:::core Handler["πŸ’¬ Command Handler"]:::core RAG["🧠 RAG Engine"]:::core end LLM["✨ Google Gemini (AI)"]:::external DB[("πŸ—„οΈ SQLite sqlite-vec")]:::storage User -->|Conversation| TG TG --> Handler Handler -->|Process & Fetch| RAG Worker -->|History Sync| Gmail Gmail -->|New Emails| Worker Worker -->|Indexing| RAG RAG -->|Save/Search Embeddings| DB RAG -->|Generate Drafts| LLM LLM -->|TL;DR & Draft| RAG Handler -->|High-Priority Push| TG TG --> User

1. The Core Engine (Golang)

I chose Go for its superior concurrency model. The system relies heavily on lightweight Goroutines to perform asynchronous, non-blocking polling of the Gmail API across multiple accounts simultaneously without freezing the main thread or causing race conditions.

2. Hybrid RAG with Local Vector Memory

Instead of relying on expensive, cloud-based vector databases (like Pinecone or Milvus), I implemented a fully local RAG (Retrieval-Augmented Generation) pipeline using SQLite extended with sqlite-vec.

Why? It keeps the application lightweight, reduces network latency to zero, and ensures all semantic embeddings stay strictly on the user's server.

3. Two-Way State Consistency (History API)

One of the hardest challenges in building an email client is remote state synchronization. OpenClaw integrates directly with the Gmail History API. If a user deletes an email in the standard Gmail web interface, the Go background worker catches the remote deletion event and instantly purges the corresponding vectors from the local SQLite database. This ensures 100% memory consistency.

4. Admin Dashboard (HTMX)

For OAuth 2.0 token management and system monitoring, I built a lightweight web dashboard. Instead of spinning up a heavy React/Vue SPA, I used HTMX + Tailwind CSS. This allowed me to create a reactive, real-time UI that is served directly by the Go backend with minimal JavaScript overhead.

πŸ›‘οΈ Security & DevSecOps

An email agent handles highly sensitive data. Security was built into the foundation:

  • Encryption at Rest: All OAuth 2.0 access and refresh tokens are encrypted in the database using AES-256 (GCM).
  • Isolated Deployment: The application is packaged using a multi-stage Docker build.
  • Least Privilege: The container runs as a non-root user, with a read-only filesystem, and strictly drops all unnecessary Linux capabilities (cap_drop: ALL).

πŸ€– The AI-Augmented Development Experience

OpenClaw was built using an AI-augmented workflow. Pair-programming with Google Gemini accelerated the development cycle exponentially. However, it wasn't just about generating code snippetsβ€”it was about high-level architectural sparring. Together, we navigated complex API rate-limiting (HTTP 429), engineered robust state synchronization logic, and refined the conversational UX.

This project stands as a testament to what a single developer can achieve when combining solid backend engineering principles with modern Generative AI tools.