---
title: n8n IMAP Triage Pipeline
area: infrastructure
tags: [n8n, imap, llm, automation, email]
created: 2026-03-27
updated: 2026-05-28
status: active
related: [[Infrastructure/Automation/n8n Workflows]], [[Infrastructure/Architecture]]
---

# n8n IMAP Triage Pipeline

## Overview

- **Workflow:** `IMAP Inbox Triage + Obsidian Notes`
- **Workflow ID:** `9sFwRyUDz51csAp7`
- **Schedule:** every 15 minutes
- **Account:** `wills_portal` IMAP (`will@wills-portal.com`)

## Pipeline flow

Read Unseen Emails
→ Stage 1 - Static Filter
→ Any Left?
→ Needs LLM Judgement?
→ Judge with Local LLM (only for ambiguous mail)
→ Parse LLM Result / Tag Definite Signal
→ Merge All Signal
→ Format & Send → Send to Telegram
→ Format Email Notes → Write Email to Vault

## Local LLM

- **Model:** `gemma-4-26B-A4B-it-UD-IQ2_M.gguf`
- **Endpoint from n8n:** `http://172.19.0.1:18806/v1/chat/completions`
- **Endpoint from host:** `http://127.0.0.1:18806/v1/chat/completions`
- **Used for:** ambiguous emails only
- **Reply shape:** JSON like `{"signal": true|false, "priority": 1|2|3, "reason": "..."}`
- **Priority scale:**
  - `1` = act now 🔴
  - `2` = read today 🟡
  - `3` = FYI 🔵

## Static filter behavior

### Definite noise
Examples include newsletters, no-reply mail, marketing, Discord/Plex/Spotify/YouTube-style noise, and known recurring low-value sender/subject patterns.

### Definite signal
Examples include login attempts, unusual access, invoices, payment due, receipts, urgent/action-required mail, password resets, GitHub/Gitea, and similar operational/security mail.

### Everything else
Sent to the local LLM for judgement.

## Outputs

### Telegram
- digest sent via OpenClaw Telegram bot
- grouped by priority with concise reason text

### Obsidian
- writes per-email notes to `Notes/YYYY-MM-DD Subject.md`
- uses the Obsidian Local REST API at `http://127.0.0.1:27123` or LAN `http://192.168.153.130:27123`

## Important operational notes

- A major 2026-03-27 failure mode was **not** the LLM or the workflow logic — it was shared-vault cross-user permissions on the `virtiofs` mount. The API was up, but writes to some folders hung until permissions were fixed.
- On 2026-05-27, intermittent Gandi IMAP long-lived connection resets (`ECONNRESET`) were mitigated by setting the `Read Unseen Emails` node option `forceReconnect` to `10` minutes and restarting `n8n-agent`. Because n8n 2.x uses published workflow versions, the current workflow version was also inserted into `workflow_history` and the active/published version pointers were aligned. Backups were written under `~/.hermes/backups/n8n-imap-*`.
- On 2026-05-28, `llama-server.service` was changed from `--host 127.0.0.1` to `--host 0.0.0.0` so Dockerized n8n can reach the host local LLM via the bridge gateway `172.19.0.1:18806`. Verified from inside `n8n-agent` with `/v1/models` and a chat-completions smoke test. If this breaks again, check the service is still listening on `0.0.0.0:18806` and not only loopback.
- First checks if this breaks again:
  1. Obsidian Local REST API reachable?
  2. shared vault path writable from the current host user / Obsidian Local REST process? Older `claw`/`openclaw` VM ownership issues are historical.
  3. local LLM endpoint still serving `gemma-4-26B-A4B-it-UD-IQ2_M.gguf`, and reachable from `n8n-agent` at `http://172.19.0.1:18806/v1/models`?
  4. IMAP trigger node still has `options.forceReconnect: 10`?

## Validation summary

Validated live on 2026-03-27:
- n8n healthy
- local Gemma endpoint healthy (current model re-checked 2026-05-27 as Gemma 4 26B GGUF)
- live local inference succeeded
- Telegram notifications previously verified
- Obsidian REST writes repaired and re-verified after permission fix
