Gmail Assistant — An Autonomous Email Triage & Scheduling Agent
Reads a tracked inbox, drafts context-aware replies with Claude Sonnet 4.6, negotiates and auto-books meetings against live calendar availability, and writes a twice-daily priority-ranked recap — orchestrated as three synchronous n8n workflows.
At a glance
Most inbox-assistant demos stop at "draft a reply." This one closes the loop: it also negotiates a meeting time against live calendar availability, auto-books the confirmed slot, and writes a standing recap of the inbox twice a day. The logic is split into an orchestrator plus two synchronous sub-workflows, so triggers, drafting/booking, and reporting can be versioned and debugged independently.
The problem
Most of what arrives in an organization's inbox is routine, and none of it can be ignored. A municipal office, a clinic reception, a small practice: appointment requests, status questions, forwarded documents, confirmations. Individually trivial, collectively a full-time job.
- Scheduling is the worst of it — a request, a proposal of times, a counter-proposal, a confirmation. Four messages and two calendar checks for one half-hour meeting.
- Response time slips, and for a public office slow correspondence is not an inconvenience but a service failure the citizen experiences directly.
- Nobody has a reliable picture of what is actually outstanding. What is pending lives in someone's head, or in a thread nobody has scrolled back to.
- The obvious fix — let software answer the mail — is unacceptable wherever an outgoing message is an official act with a person's name on it.
How this helps
The agent does the preparation and stops short of the decision. It reads a tracked inbox, classifies what each message is asking for, drafts a reply, computes genuinely free slots from live calendars, proposes them, books the one that gets confirmed, and twice a day writes a priority-ranked brief of everything that came in.
- The human still sends. Every reply is created as a Gmail draft and never sent automatically. The work of composing and checking calendars is removed; the act of answering stays with the person accountable for it.
- Scheduling collapses into a review. Free slots are computed across two calendars over the next fourteen days, proposed inside the draft, and the confirmed one is booked — the back-and-forth happens without occupying anyone.
- A standing picture of the inbox. The twice-daily recap scores every message 1–5 with a one-line justification, so a supervisor sees what needs an answer today without reading the mailbox.
- Safe to re-run. A log of processed message IDs makes the workflow idempotent: a crash, a retry or a manual run never double-drafts and never double-books.
- Data residency is a configuration, not a rebuild. The model calls run through swappable nodes — a hosted model today, a self-hosted Ollama instance instead, wherever the data may not leave the premises.
Scope, honestly: the volumes on this page come from a test scope — the tracked senders are my own mailbox aliases, not third-party correspondents. The mechanics and the operational data are real; the traffic is not yet that of a working office.
Drafting & scheduling
- Reads an active-sender whitelist from an n8n data table, builds a Gmail search query from it, and pulls unprocessed messages from the last 7 days.
- Skips anything already handled by checking a second data table used purely as an idempotency log — safe to re-run without double-drafting or double-booking.
- Classifies each email with Claude Sonnet 4.6 through a schema-validated LangChain output parser: is this confirming a previously proposed time, a new appointment request, or neither.
- For a new appointment request, it reads two Google Calendars (a personal calendar plus a dedicated "Meetings" calendar), computes up to three free 30-minute slots over the next 14 days (weekdays, 09:00–18:00 Europe/Rome), and has the model draft a reply proposing them.
- For a confirmation, it books the matching slot straight to Google Calendar and marks the thread confirmed.
- Every reply is created as a Gmail draft, never sent automatically — review and send stays a manual step.
The twice-daily recap
- Runs after Drafting finishes, pulling the last 12 hours of inbox mail plus the idempotency log.
- Batches emails (10 per call) through the same model, which assigns each one a free-form topic label and a 1–5 priority score — 5 for action-needed-within-a-day, 1 for ignore — with a one-line justification and a one-sentence summary.
- Formats the result into a priority-grouped brief and writes it to a new Google Doc, with bold section headers applied via a direct call to the Docs API
batchUpdateendpoint, since n8n's Google Docs node doesn't expose character-level styling.
Operational data
Pulled directly from n8n's execution log and the workflow's own data tables since the build started on 30 Aug 2026 — not simulated.
Scope note: the tracked-sender list currently holds two of Marco's own mailbox aliases used for testing, not real third-party correspondents yet. The mechanics below — drafting, negotiation, booking, recap — are fully live; the volumes just reflect a test scope rather than production email traffic.
Reliability & safety
- Every reply lands as a Gmail draft, never auto-sent — a human always reviews before anything goes out.
- Idempotent by construction: a data-table log of processed message IDs means re-running the workflow, manually or after a crash, never double-drafts or double-books.
- Calendar lookups have an explicit fallback path if either Google Calendar is temporarily unreachable, so a transient API error degrades gracefully instead of drafting into an unknown schedule.
- The classification, drafting, and recap LLM calls all run through swappable model nodes. Anthropic Claude Sonnet 4.6 is the active path; OpenAI GPT-4.1-mini and a self-hosted Ollama (qwen3:32b) are wired in as disabled alternates for cost or data-residency needs.
- Structured, schema-validated outputs throughout via LangChain output parsers, rather than parsing free-text model responses.