Running customer support solo is brutal. Every ticket feels urgent. The same questions repeat — password resets, order status, refund policy. You spend hours copy-pasting the same answers.
I built an n8n workflow that uses GPT-4o-mini to categorize incoming support emails and send accurate auto-replies for the 80% of tickets that follow predictable patterns. Human escalation for the rest.
Here's exactly how it works — full JSON at the bottom.
What it does
- Catches incoming support emails via Gmail
- Uses GPT-4o-mini to categorize: BILLING / SHIPPING / ACCOUNT / GENERAL
- Sends a category-appropriate auto-reply (fully customizable templates)
- Logs every ticket to Google Sheets (sender, category, response, timestamp)
- Routes unclassified tickets to a fallback output for human handling
Setup time: 15–20 minutes
Cost per ticket: ~$0.001 (GPT-4o-mini is very cheap)
n8n version: 1.40+
The 7-node workflow
- Gmail Trigger — polls every minute for new unread emails
- Skip No-Reply — IF node filters automated senders (prevents reply loops)
- Prepare Text — Code node cleans subject + snippet for the AI
- AI Categorize — OpenAI node classifies the ticket with one word
- Route Category — Switch node routes to the right reply template
- Send Reply — Gmail node sends the appropriate response
- Log Ticket — Google Sheets records everything for audit
Full workflow JSON
{"name":"AI Customer Support Bot","nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"filters":{}},"id":"cs1","name":"Gmail Trigger","type":"n8n-nodes-base.gmailTrigger","typeVersion":1,"position":[240,300]},{"parameters":{"conditions":{"string":[{"value1":"={{ $json.from }}","operation":"notContains","value2":"noreply"}]}},"id":"cs2","name":"Skip No-Reply","type":"n8n-nodes-base.if","typeVersion":1,"position":[460,300]},{"parameters":{"jsCode":"const subject=$json.subject||'';const snippet=$json.snippet||'';return[{json:{...$json,textForAI:'Subject: '+subject+'\nMessage: '+snippet}}];"},"id":"cs3","name":"Prepare Text","type":"n8n-nodes-base.code","typeVersion":2,"position":[680,300]},{"parameters":{"resource":"chat","operation":"message","model":"gpt-4o-mini","messages":{"values":[{"content":"You are a customer support classifier. Given an email subject and message, respond with exactly one word: BILLING, SHIPPING, ACCOUNT, or GENERAL. No explanation.\n\nEmail: {{ $json.textForAI }}"}]},"options":{}},"id":"cs4","name":"AI Categorize","type":"@n8n/n8n-nodes-langchain.openAi","typeVersion":1,"position":[900,300]},{"parameters":{"rules":{"values":[{"conditions":{"options":{"caseSensitive":false},"conditions":[{"leftValue":"={{ $json.message.content }}","operator":{"type":"string","operation":"contains"},"rightValue":"BILLING"}]}},{"conditions":{"options":{"caseSensitive":false},"conditions":[{"leftValue":"={{ $json.message.content }}","operator":{"type":"string","operation":"contains"},"rightValue":"SHIPPING"}]}},{"conditions":{"options":{"caseSensitive":false},"conditions":[{"leftValue":"={{ $json.message.content }}","operator":{"type":"string","operation":"contains"},"rightValue":"ACCOUNT"}]}}]}},"id":"cs5","name":"Route Category","type":"n8n-nodes-base.switch","typeVersion":3,"position":[1120,300]},{"parameters":{"sendTo":"={{ $('Gmail Trigger').item.json.from }}","subject":"Re: {{ $('Gmail Trigger').item.json.subject }}","message":"Hi,\n\nThanks for reaching out about billing. [YOUR BILLING RESPONSE HERE]\n\nBest,\nSupport Team","options":{}},"id":"cs6a","name":"Reply Billing","type":"n8n-nodes-base.gmail","typeVersion":2,"position":[1340,160]},{"parameters":{"sendTo":"={{ $('Gmail Trigger').item.json.from }}","subject":"Re: {{ $('Gmail Trigger').item.json.subject }}","message":"Hi,\n\nThanks for your shipping question. [YOUR SHIPPING RESPONSE HERE]\n\nBest,\nSupport Team","options":{}},"id":"cs6b","name":"Reply Shipping","type":"n8n-nodes-base.gmail","typeVersion":2,"position":[1340,300]},{"parameters":{"sendTo":"={{ $('Gmail Trigger').item.json.from }}","subject":"Re: {{ $('Gmail Trigger').item.json.subject }}","message":"Hi,\n\nFor account help: [YOUR ACCOUNT RESPONSE HERE]\n\nBest,\nSupport Team","options":{}},"id":"cs6c","name":"Reply Account","type":"n8n-nodes-base.gmail","typeVersion":2,"position":[1340,440]},{"parameters":{"operation":"append","documentId":{"value":"YOUR_SHEET_ID"},"sheetName":"Tickets","columns":{"mappingMode":"defineBelow","value":{"sender":"={{ $('Gmail Trigger').item.json.from }}","subject":"={{ $('Gmail Trigger').item.json.subject }}","category":"={{ $('AI Categorize').item.json.message.content }}","timestamp":"={{ new Date().toISOString() }}"}},"options":{}},"id":"cs7","name":"Log Ticket","type":"n8n-nodes-base.googleSheets","typeVersion":4,"position":[1340,560]}],"connections":{"Gmail Trigger":{"main":[[{"node":"Skip No-Reply","type":"main","index":0}]]},"Skip No-Reply":{"main":[[{"node":"Prepare Text","type":"main","index":0}]]},"Prepare Text":{"main":[[{"node":"AI Categorize","type":"main","index":0}]]},"AI Categorize":{"main":[[{"node":"Route Category","type":"main","index":0}]]},"Route Category":{"main":[[{"node":"Reply Billing","type":"main","index":0}],[{"node":"Reply Shipping","type":"main","index":0}],[{"node":"Reply Account","type":"main","index":0}],[{"node":"Log Ticket","type":"main","index":0}]]}}}
How to import
Workflows → New → ⋯ menu → Import from JSON → paste the above
Then activate and it runs continuously.
Setup (5 steps)
- Add Gmail OAuth2 credentials (Settings → Credentials → New → Gmail OAuth2)
- Add OpenAI API key credential
- Replace
YOUR_SHEET_IDwith your Google Sheets ID (the string in the sheet URL) - Customize the reply templates in each Reply node to match your actual responses
- Activate the workflow
Tips that actually matter
Tune the prompt. Add your company name and top 3 products to the classification prompt. GPT-4o-mini does much better with context: "You are a support classifier for [Your Company], which sells [Product A] and [Product B]..."
Add more categories. Extend the Switch node: RETURNS, TECHNICAL, COMPLAINT. Each gets its own reply node.
Test manually first. Before activating, use the "Test workflow" button with real email data from your inbox. Check that categories are landing correctly before it goes live.
The fallback output matters. The Switch node has a fallback (anything not matched). Wire that to a Slack message so a human catches anything the AI couldn't classify.
Cost is negligible. At ~$0.001/ticket with gpt-4o-mini, 1,000 tickets/month = $1. Run it continuously without worry.
I built this as part of a set of n8n automation templates for common business workflows. The JSON above is the complete working core — if you want the extended version with Slack escalation, confidence scoring, and a pre-filled setup guide, the full pack is at https://stripeai.gumroad.com.
Happy to answer setup questions in the comments!
Top comments (0)