Back to Projects
Workflow Automation SystemLiveBuilt on n8n

Local LLM Email Triage

Inbox triage by a locally hosted model, so no message body ever leaves the machine

Project Snapshot
Local LLM Email Triage

Overview

An inbox without priority is a queue in arrival order, where the message that needed an answer today sits under thirty that did not. The usual fix hands every message body to a cloud AI provider, which is a poor trade for private correspondence. This system keeps the judgement local. Seven workflows pull unread mail on a schedule, pass one message at a time to a model running on the same machine, and turn the verdict into labels, a daily digest, and an inbox that can be questioned in plain language.

Approach & Architecture

A scheduled workflow queries a bounded lookback window for unread mail that has not been processed yet, then sends one message at a time to a local model pinned to JSON mode. The model returns a summary, an importance score, an urgency level, whether a reply is required, and whether the message is a genuine opportunity. A deterministic guard re-scores the opportunity flag before anything is applied. Label IDs resolve live from the account, archive and mark-read actions sit behind config flags, and every analysed message is appended to a log the digest workflow reads.

Workflow Topology

COLLECTANALYSEDECIDEACTREPORTif enabledevery 24hexcludedSchedule — Runs on a fixed intervalScheduleFetch Unread — Bounded lookback window; processed mail self-excludedFetch UnreadOne at a Time — Bounded batch size, continue-on-fail per messageOne at a TimeLocal Model — Self-hosted model pinned to JSON mode and held warmLocal ModelParse + Repair — Hand-written JSON parsing with a repair pathParse + RepairOpportunity Gate — Deterministic score downgrades cold sales the model over-flagsOpportunity GateScore to Labels — Importance, urgency and reply-required map to a label setScore to LabelsApply Labels — Label IDs resolved live from the accountApply LabelsArchive / Read — Config-gated; archiving only removes the inbox labelArchive / ReadMark Processed — Doubles as the exactly-once dedup markerMark ProcessedAppend Log — One record per analysed messageAppend LogDaily Digest — A separate workflow composes and sends the 24-hour summaryDaily Digest7 workflows · 60 nodes · Schedule, Webhook, Sub-workflown8n

A condensed view of the real node graph.

Outcome & Impact

Mail arrives sorted: priority, urgency, follow-up, and opportunity labels are already applied, and a single digest covers the last 24 hours. No message body reaches a third-party provider, and no destructive action runs unless its flag is set. Sixty nodes across seven workflows, validated end to end against a live mailbox.

Challenges & Solutions

  • Getting reliable structured output from a small local model by pinning JSON mode at the runtime and hand-writing the parsing and repair path rather than depending on a framework parser
  • Suppressing false positives, where hype-heavy cold sales read as genuine opportunities, with a deterministic guard that scores sender patterns, unsubscribe text, and discount language before the verdict is trusted
  • Guaranteeing exactly-once processing across reruns and two separate pipelines by making a processed label double as the dedup marker, with every search query self-excluding it
  • Limiting blast radius on a live mailbox, where continue-on-fail isolates one bad message from the batch, destructive actions sit behind config gates, and archiving never deletes

Key Features

  • Scheduled triage over a bounded lookback window, plus a resumable one-time sweep of the historical archive
  • Self-hosted model returns strict JSON: summary, importance, urgency, reply-required, and opportunity flags
  • Verdicts become labels for priority, urgency, follow-up, and three opportunity categories
  • Deterministic guard downgrades the cold sales a small model over-flags as genuine opportunities
  • Archive and mark-read gated behind config flags, and archiving only removes the inbox label
  • Daily digest composed from an on-disk log of everything analysed in the previous 24 hours
  • Webhook workflow answers free-text questions over a mailbox search and cites the message behind each fact

Tech Stack

n8nOllamaLangChainGmail APIOAuth 2.0JavaScriptDocker

Automation

Platform
n8n
Workflows
7
Nodes
60
Triggers
Schedule, Webhook, Sub-workflow
Scheduled Triage
Pulls unread mail in a bounded window, analyses one message at a time, and applies labels
Archive Backfill
One-time resumable sweep over the historical archive, in bounded batches
Daily Digest
Composes and sends a summary of the previous 24 hours from the analysis log
Inbox Questions
Webhook endpoint answering free-text questions over a mailbox search, citing each source message

Tags

AutomationLocal LLMPrivacySelf-Hosted AIEmail TriageWebhooks

Status

Live