Workflow 03 / Support
AI Support Email Triage
Every support email classified, drafted into the Gmail thread and escalated if urgent.
- Trigger
- New email in the support inbox
- Size
- 14 nodes, 4 credentials
- Typical build
- 7 working days
- Tools
- n8n, Gmail, OpenAI API, Slack, Google Sheets
Example scenario: DTC homeware brand, about 2,300 support emails a month, five agents
The problem
Agents spent the first hour of every shift sorting the inbox. Urgent damage claims were buried under "where is my order" questions and replies drifted away from policy depending on who wrote them.
What the workflow does
The solution
Each new email is cleaned, classified by an LLM (category, urgency, sentiment, order number) and routed with a Switch node. For known categories the LLM writes a policy-safe draft right inside the Gmail thread. Tickets are labelled using the real Gmail label IDs, urgent ones are escalated to Slack and everything is logged for weekly reporting. If the model returns something unusable, the ticket is escalated as urgent instead of being lost. Agents stay in control: drafts are never sent automatically.
The flow
Drawn from the real JSON
Node names, order and branches are read from the exported file at build time, so this diagram can never drift from what n8n will show you. Dashed lines are connections; amber ones leave an IF, a Switch or an error output.
Download n8n JSONScroll sideways to see all branches
Node by node
| # | Node | Type | What it does |
|---|---|---|---|
| 01 | Gmail: New Email | Trigger | Polls the support inbox every minute for untriaged mail |
| 02 | Clean Email | Transform | Sets 5 fields: messageId, threadId, from, subject… |
| 03 | LLM: Classify | AI step | Chat completion (gpt-4o-mini), JSON-only output |
| 04 | Parse Triage | Transform | Validates the classification. Anything unexpected is escalated as urgent so a human reads the email. |
| 05 | Switch: Category | Branch | Routes to: billing, shipping, returns, product, other |
| 06 | LLM: Draft Reply | AI step | Chat completion (gpt-4o-mini), JSON-only output |
| 07 | Gmail: Create Draft | App action | Saves a reply draft in the original thread |
| 08 | Merge: Triage Paths | Transform | Joins the draft and no-draft paths into one run |
| 09 | Gmail: Get Labels | App action | Reads every Gmail label once, to resolve label IDs by name |
| 10 | Resolve Label IDs | Transform | Looks up the real Gmail label IDs by name and builds one ticket per email. Fails loudly if a label is missing. |
| 11 | Gmail: Label Ticket | App action | Applies the triage labels |
| 12 | IF: High Urgency | Branch | True if urgency = high |
| 13 | Slack: #cx-urgent | App action | Posts a message to #cx-urgent |
| 14 | Sheets: Ticket Log | App action | Appends a row to the "Tickets" tab |
How a run goes
Gmail trigger polls support@ every minute for messages that are not yet labelled.
A Set node strips quoted history and signatures to keep the prompt short.
The LLM classifies category, urgency, sentiment and extracts the order number; a Code node validates the answer and escalates anything invalid as urgent.
Switch routes billing, shipping, returns and product emails to the drafting step.
The LLM writes a reply using your real policy snippets; Gmail saves it as a draft in the thread.
Both paths merge, the workflow looks up the real label IDs by name and applies them. High-urgency tickets alert Slack and every ticket goes to the metrics sheet.
Tools and credentials
Credentials are referenced by name inside the JSON. Create each one in n8n under Credentials, using these names, and the nodes connect automatically.
| Credential name | What you need |
|---|---|
| Gmail – support@ | Google OAuth client with the Gmail API enabled |
| OpenAI – Flowforge | API key from platform.openai.com |
| Slack – Flowforge Bot | Bot token with the chat:write scope |
| Google Sheets – Ops | Google OAuth client with the Sheets API enabled |
Setup in about 30 minutes
Import the file. In n8n open Workflows, then Import from file, and pick
support-triage.json. The workflow arrives inactive.Create the 4 credentials listed above with exactly those names.
Replace the placeholders with your own IDs:
REPLACE_WITH_TICKETS_SHEET_IDin “Sheets: Ticket Log”
Adapt it to your business.
- Create these Gmail labels first (the workflow looks their IDs up by name and stops with a clear error if one is missing): ai-triaged, ai/billing, ai/shipping, ai/returns, ai/product, ai/other.
- Replace the policy snippets in "LLM: Draft Reply" (return window, shipping times, refund rules) with your own text.
- Update the search filter in the Gmail trigger to your support address.
- Start with the Slack alert only for urgent tickets, then widen the filter once the team trusts the labels.
Connect error reporting. Import
error-reporter.jsononce, then open this workflow’s Settings and choose it as the Error workflow. Failed runs are posted to Slack and logged, with a link to retry.Test, then activate. Run the first node with sample data, check each output in the execution view, then switch the workflow to active. Keep the test run for your records.
Example figures for the scenario above, not guarantees
What this kind of build changes
Use it, or have it built for you
The JSON is free to import and adapt. If you would rather have it wired to your own stack and tested on your data, a single flow like this is a fixed-price project.