Agentic Gmail
AI-assisted email classification and concise Telegram notifications using n8n and high-throughput Groq Chat Models.
Project Overview
Agentic Gmail is an automated inbox processing pipeline built in n8n. The workflow polls for incoming emails every minute and immediately splits the message into two concurrent execution paths:
1. An AI Classification Path: An AI Agent powered by Groq evaluates the sender identity, message intent, and priority to classify the email into one of 8 distinct categories, mapping the result directly to native Gmail labels.
2. An Email Summarization Path: A dedicated summarization agent digests the sender and email body, producing an under-80-word, mobile-optimized brief that is instantly delivered to Telegram.
Problem & Solution
The Challenge
Developers and university students receive dozens of emails daily spanning university notifications, GitHub alerts, cloud server usage warnings, subscriptions, and promotional clutter. Traditional keyword-based email filters are brittle and frequently misplace important server or university alerts.
The Automation
By connecting n8n directly to Gmail and LLM reasoning agents, incoming messages are classified based on context rather than plain text matching. Real-time Telegram alerts allow reviewing critical messages on mobile in under 5 seconds without opening the full email client.
How It Works
Detect Incoming Emails
Gmail TriggerThe workflow polls the Gmail inbox every minute. When a new email arrives, it outputs the message ID, Subject, From sender address, and message snippet, then fans out concurrently to both processing branches.
AI Intent & Risk Classification
Set Label Agent + Groq Chat Model
The classification agent receives the subject, sender, and snippet. Driven by strict persona instructions, it determines sender intent and categorizes the email into one of 8 target classes: Junk, Cloud, Gaming, Productivity, Tech, Security, Subscriptions, or Personal (safe harbor). The agent outputs structured JSON with its reasoning, chosen category, and confidence score.
Apply Gmail Label
Add label to message (Gmail Node)The node parses the category returned by the agent and maps it to the user's specific Gmail label ID using an inline dictionary lookup, attaching the appropriate tag directly inside Gmail.
Digest & Summarize Message
Summerize Agent + Groq Chat Model1Concurrently on path 2, a summarization agent strips out greetings, email footers, and tracking noise to extract key facts, deadlines, OTPs, or action items. It enforces a strict format (Sender Name, Sender Email, and a concise summary capped under 80 words).
Deliver Telegram Notification
Send a text message (Telegram Node)The workflow transmits the clean summary directly to the user's private Telegram chat, enabling quick scanning on mobile without latency.
Dual-Path Execution Diagram
Prompt Rules & Technical Highlights
Strict Anti-Failure Rules
Prompt instructions explicitly forbid marking university, GitHub, OTP, banking, or server alerts as Junk. If confidence is below 70%, it falls back to Personal.
High-Speed Groq Inference
Uses Groq's high-speed inference engine (openai/gpt-oss-120b) to process email categorization and summarization with minimal turnaround time.
Structured Category-to-Label Mapping
The Gmail node maps category keys (Junk, Cloud, Gaming, Personal, Productivity, Tech, Security, Subscriptions) directly to pre-configured Gmail label IDs.
Mobile-Optimized Telegram Alerts
Enforces a 3-line format (Name, Email, concise body under 80 words) highlighting OTPs, deadlines, or urgency without clutter.
Technical Notes & Scope
- AI Classification Boundaries: While the agent uses strict anti-failure prompts, LLM text classification is probabilistic and not guaranteed to be 100% error-free on ambiguous marketing or security notices.
- Snippet Length Limits: The workflow ingests
{{ $json.snippet }}; exceptionally long emails with crucial details buried in attachments or deep body sections are evaluated based on their top snippet. - Disconnected Nodes in Export: The JSON file contains several dormant experiment nodes (a Google Gemini Chat Model node, an OpenAI Chat Model node, a Switch node, and a Wait node) that are disconnected from the active connections. These do not execute during active runtime.
- Polling Latency: The Gmail trigger is set to poll every minute rather than an immediate push webhook, meaning notifications have up to a ~60-second delivery interval.