Workflow review
ai_email_triage
Needs a human decision (2)
FlowGuard could not apply these fixes safely, so the fixed workflow leaves them unchanged.
Classify Email· Extract only the subject line and a truncated plain-text preview (e.g. first 200 characters) before passing to the classifier.Build Prompt· Strip HTML to plain text and truncate to 500 characters before building the prompt.
| Severity | Category | Node | Issue and fix | Status |
|---|---|---|---|---|
| high | cost | Classify Email | Uses premium model gpt-4 with maxTokens 4096 for a single-label classification task; this is 2–4× more expensive than necessary. Fix: Switch to gpt-4o-mini (or gpt-3.5-turbo) and cap maxTokens at 20 (only one label is returned). | Fixed |
| high | reliability | (workflow) | No errorWorkflow is configured; unhandled runtime errors are silently dropped with no alerting or logging. Fix: Set settings.errorWorkflow to the shared error-handler workflow ID. | Fixed |
| high | security | Classify Email | Full email body (including HTML content, sender address, and thread messages — which may contain PII) is forwarded to an external LLM (gpt-4) without any field selection or redaction. Fix: Extract only the subject line and a truncated plain-text preview (e.g. first 200 characters) before passing to the classifier. | Manual |
| medium | cost | Gmail Trigger | Polling trigger runs every minute, consuming Gmail API quota and incurring n8n execution charges even when no new emails arrive. Fix: Increase the polling interval to at least 5 minutes, or switch to Gmail push notifications if near-real-time routing is required. | Fixed |
| medium | cost | Build Prompt | The prompt concatenates the full HTML email body plus all thread message HTML with no truncation; oversized emails will send thousands of input tokens to gpt-4 per classification. Fix: Strip HTML to plain text and truncate to 500 characters before building the prompt. | Manual |
| medium | reliability | Route by Category | Switch node has no fallbackOutput; if the LLM returns any label other than support/sales/billing/spam (e.g. 'Support' with capitals, or an explanation), the item is silently dropped. Fix: Set parameters.options.fallbackOutput to an extra output connected to a logging or quarantine node. | Fixed |
Fixed workflow
flowchart LR
n0["Gmail Trigger"]
n1["Build Prompt"]
n2["Classify Email"]
n3["Route by Category"]
n4["Create Zendesk Ticket"]
n5["Notify Sales"]
n6["Label Billing"]
n7["Archive Spam"]
n8["Unmatched Category"]
n0 --> n1
n1 --> n2
n2 --> n3
n3 --> n4
n3 --> n5
n3 --> n6
n3 --> n7
n3 --> n8
classDef red fill:#fdecea,color:#8a1c12,stroke:#d0402b,stroke-width:1.5px
classDef orange fill:#fdf0e3,color:#7a3a06,stroke:#d9731a,stroke-width:1.5px
classDef yellow fill:#fbf5dc,color:#5e4b05,stroke:#b8960f,stroke-width:1.5px
classDef blue fill:#e8f0fb,color:#153e75,stroke:#3d74c4,stroke-width:1.5px
classDef clean fill:#f6f7f9,color:#2b3139,stroke:#c3c8cf
class n0 yellow
class n1 yellow
class n2 orange
class n3 yellow
class n4 clean
class n5 clean
class n6 clean
class n7 clean
class n8 clean