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 JSON
TriggerAI stepApp actionTransformBranch
14 nodes

Scroll sideways to see all branches

billing +3othertruefalse1. Gmail: New EmailGmail01New Email2. Clean EmailSet02Clean Email3. LLM: ClassifyLLM03Classify4. Parse TriageCode04Parse Triage5. Switch: CategorySwitch05Category6. LLM: Draft ReplyLLM06Draft Reply7. Gmail: Create DraftGmail07Create Draft8. Merge: Triage PathsMerge08Triage Paths9. Gmail: Get LabelsGmail09Get Labels10. Resolve Label IDsCode10Resolve Label IDs11. Gmail: Label TicketGmail11Label Ticket12. IF: High UrgencyIF12High Urgency13. Slack: #cx-urgentSlack13#cx-urgent14. Sheets: Ticket LogSheets14Ticket Log

Node by node

#NodeTypeWhat it does
01Gmail: New EmailTriggerPolls the support inbox every minute for untriaged mail
02Clean EmailTransformSets 5 fields: messageId, threadId, from, subject…
03LLM: ClassifyAI stepChat completion (gpt-4o-mini), JSON-only output
04Parse TriageTransformValidates the classification. Anything unexpected is escalated as urgent so a human reads the email.
05Switch: CategoryBranchRoutes to: billing, shipping, returns, product, other
06LLM: Draft ReplyAI stepChat completion (gpt-4o-mini), JSON-only output
07Gmail: Create DraftApp actionSaves a reply draft in the original thread
08Merge: Triage PathsTransformJoins the draft and no-draft paths into one run
09Gmail: Get LabelsApp actionReads every Gmail label once, to resolve label IDs by name
10Resolve Label IDsTransformLooks up the real Gmail label IDs by name and builds one ticket per email. Fails loudly if a label is missing.
11Gmail: Label TicketApp actionApplies the triage labels
12IF: High UrgencyBranchTrue if urgency = high
13Slack: #cx-urgentApp actionPosts a message to #cx-urgent
14Sheets: Ticket LogApp actionAppends a row to the "Tickets" tab

How a run goes

  1. Gmail trigger polls support@ every minute for messages that are not yet labelled.

  2. A Set node strips quoted history and signatures to keep the prompt short.

  3. The LLM classifies category, urgency, sentiment and extracts the order number; a Code node validates the answer and escalates anything invalid as urgent.

  4. Switch routes billing, shipping, returns and product emails to the drafting step.

  5. The LLM writes a reply using your real policy snippets; Gmail saves it as a draft in the thread.

  6. 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 nameWhat you need
Gmail – support@Google OAuth client with the Gmail API enabled
OpenAI – FlowforgeAPI key from platform.openai.com
Slack – Flowforge BotBot token with the chat:write scope
Google Sheets – OpsGoogle OAuth client with the Sheets API enabled

Setup in about 30 minutes

  1. Import the file. In n8n open Workflows, then Import from file, and pick support-triage.json. The workflow arrives inactive.

  2. Create the 4 credentials listed above with exactly those names.

  3. Replace the placeholders with your own IDs:

    • REPLACE_WITH_TICKETS_SHEET_ID in “Sheets: Ticket Log”
  4. 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.
  5. Connect error reporting. Import error-reporter.json once, 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.

  6. 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

65%of replies sent from AI drafts
-60%median first reply time
< 5 minto surface urgent damage claims
+0.5CSAT on a 5-point scale

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.