Your support inbox fills up with the same questions over and over — billing issues, login errors, feature questions — and your team spends hours writing responses that could have been templated. What if every new support email was automatically read, classified, answered with a personalized AI reply grounded in your actual documentation, and logged to a dashboard, all before your team even opens their laptop? That’s exactly what this n8n workflow does. It connects Gmail, GPT-4o-mini, Google Gemini, and Pinecone into a full AI support pipeline — no code required, no custom server needed.
Prefer to skip the setup? Grab the ready-made template → and be up and running in under 10 minutes.
What You’ll Build
- A Gmail trigger polls your support inbox every minute for new unread emails.
- GPT-4o-mini classifies each email into one of four categories: Technical Support, Billing, Urgent/Critical, or General Inquiry.
- A specialized AI agent (powered by Gemini 1.5 Flash + your company knowledge base in Pinecone) drafts a personalized, accurate reply for each category.
- The reply is automatically sent via Gmail, and every ticket is appended to a Google Sheets support dashboard.
- Urgent emails trigger an immediate Slack alert to your team with the full context.
- A companion sub-workflow watches a Google Drive folder and indexes new documents into Pinecone so your knowledge base stays up to date automatically.
How It Works — The Big Picture
The system is two workflows that share a Pinecone vector index. The main pipeline handles incoming emails in real time. The ingestion sub-workflow keeps the knowledge base current. Here’s the full architecture:
┌─────────────────────────────────────────────────────────────────────┐ │ MAIN WORKFLOW: AI EMAIL SUPPORT PIPELINE │ │ │ │ [Gmail Trigger] ──► [Text Classifier (GPT-4o-mini)] │ │ | │ │ .─────────────────────────────. │ │ v v v v│ │ [Set TECH Metadata] [Set BILL Metadata] [Set URG Metadata] [Set GEN]│ │ v v v v│ │ [Technical Agent] [Billing Agent] [Urgent Agent] [General Agent]│ │ (Gemini+RAG) (Gemini+RAG) (Gemini+RAG) (Gemini+RAG) │ │ | | | | | │ │ '─────────────────────────' | ' │ │ v v │ │ [Send Gmail Reply] [Slack Human Alert] │ │ [Log to Google Sheets] │ └─────────────────────────────────────────────────────────────────────┘ Shared: Pinecone Vector Store (RAG tool for all 4 agents) ┌─────────────────────────────────────────────────────────────────────┐ │ SUB-WORKFLOW: KNOWLEDGE BASE INGESTION │ │ │ │ [Google Drive Trigger] ──► [Download File] │ │ v │ │ [Recursive Text Splitter (1000/200)] │ │ v │ │ [Default Data Loader] ──► [Embeddings (OpenAI)] │ │ v │ │ [Pinecone Insert] │ └─────────────────────────────────────────────────────────────────────┘
What You’ll Need
- n8n — cloud or self-hosted (v1.0+)
- Gmail account — your support inbox, connected via Google OAuth2
- OpenAI API key — for GPT-4o-mini (classifier) and text-embedding-3-small (vectors)
- Google Gemini API key — free tier available at aistudio.google.com
- Pinecone account — free starter tier works; create one index (1536 dimensions, cosine)
- Slack workspace — for urgent escalation alerts
- Google Sheets — your support ticket dashboard
- Google Drive — a folder for your knowledge base documents (FAQs, guides, policies)
Estimated build time: 45–60 minutes from scratch, or under 10 minutes with the template.
Part 1 — The Email Classification & Response Pipeline
1 Gmail Trigger (gmailTrigger)
This is the entry point of the workflow. It polls your Gmail inbox every minute for new unread emails and passes each one downstream as an n8n item. Configure it to poll your support inbox — not your personal account.
In the node settings, set Poll Times to Every Minute and Read Status filter to Unread. Disable the Simple option so you get the full email body in the output.
After triggering, the data flowing forward looks like this:
{
"id": "192ab3c4d5e6f700",
"threadId": "192ab3c4d5e6f700",
"from": "james.carter@gmail.com",
"subject": "Getting a 404 error when trying to export my data",
"text": "Hi, every time I click the Export button I get a 404 Not Found error...",
"date": "2026-04-10T09:23:11.000Z",
"labels": ["INBOX", "UNREAD"]
}
Tip: Add a Gmail label filter like support or help to avoid your personal inbox getting processed. Forward all support emails to a dedicated support@ address and connect that account.
2 Text Classifier (textClassifier)
The classifier node uses GPT-4o-mini (via the OpenAI Classification Model sub-node) to read the email subject and body together and route it to one of four output ports. This is the decision node of the entire pipeline.
The four categories are configured with plain-English descriptions that guide the AI:
| Output Port | Category | Description |
|---|---|---|
| 0 | technical_support |
Bugs, errors, login issues, integration failures |
| 1 | billing_payment |
Payments, invoices, subscriptions, refunds, pricing |
| 2 | urgent_critical |
Outages, data loss, security issues, needs immediate human |
| 3 | general_inquiry |
Feedback, feature requests, general questions |
Tip: The fallback category is set to general_inquiry — any ambiguous email that doesn’t clearly match the other three goes to the General Agent rather than causing an error.
3 Set Ticket Metadata (set)
Each of the four branches has its own Set Ticket Metadata node that enriches the data before passing it to the agent. These nodes stamp the ticket with a type prefix, a unique timestamp-based ID, and carry forward the sender and email body for the agent to use.
{
"ticket_type": "technical_support",
"ticket_id": "TECH-1712744591234",
"received_at": "2026-04-10T09:23:11.234Z",
"sender_email": "james.carter@gmail.com",
"subject": "Getting a 404 error when trying to export my data",
"email_body": "Hi, every time I click the Export button I get a 404 Not Found error..."
}
The four branches use ticket ID prefixes TECH-, BILL-, URG-, and GEN- so you can filter your Google Sheets dashboard by category at a glance.
4 Specialized AI Support Agents (agent)
This is where the real intelligence lives. Each branch has a dedicated AI agent with a tailored system prompt. All four agents share the same Google Gemini 1.5 Flash language model and the same Pinecone Vector Store as a RAG tool — so every agent searches your knowledge base before composing its reply.
| Agent | Tone | Primary Behavior |
|---|---|---|
| Technical Support | Professional, methodical | Searches KB for solutions, provides step-by-step fixes |
| Billing Support | Empathetic, policy-aware | Looks up billing policies, handles refund questions carefully |
| Urgent Escalation | Reassuring, brief | Acknowledges urgency, promises 1-hour human follow-up, does NOT over-resolve |
| General Support | Warm, conversational | Handles feedback and feature requests, routes creatively |
Each agent’s prompt includes the ticket ID, sender email, and subject so it can reference them in the reply. The output field $json.output contains the ready-to-send email reply body.
Tip: The more documents you have in your Pinecone knowledge base, the better these agents perform. Even a simple FAQ document dramatically improves response accuracy. Start by uploading your most frequently asked questions as a plain text file.
5 Send Gmail Response (gmail)
After each agent finishes, the workflow automatically sends the reply. The node is configured with operation: reply — it threads the response back to the original email rather than creating a new one. The message body comes from {{ $json.output }} (the agent’s output) and the message ID comes from {{ $('Gmail Trigger').item.json.id }}.
All four agents fan into the same Send Gmail Response node — n8n handles fan-in gracefully. The node runs once per item received regardless of which branch it came from.
6 Log to Support Dashboard (googleSheets)
Every resolved ticket is appended to your Google Sheets dashboard in parallel with sending the reply. The node writes seven columns per row: Ticket ID, Ticket Type, Sender Email, Subject, Received At, AI Response, and Status (set to “Responded”).
To configure: open the node, set Document ID to your spreadsheet’s ID (from its URL), and set Sheet Name to Support Tickets. Create the sheet with these exact column headers first.
7 Slack Human Escalation (slack)
Only the Urgent Escalation Agent branch connects to the Slack node. When an urgent email is detected, Slack receives a formatted alert with the ticket ID, sender, subject, and the full customer message. Your team can then follow up within the promised 1-hour window.
Configure the node: set Channel to your team’s support channel ID (right-click the channel in Slack → View channel details → copy the ID at the bottom). Make sure the n8n Slack app is invited to that channel with /invite @n8n.
Part 2 — Knowledge Base Ingestion
The second workflow runs in the background and keeps your Pinecone knowledge base populated. It fires automatically whenever you add a new document to your designated Google Drive folder.
8 Google Drive Trigger (googleDriveTrigger)
Watches a specific Google Drive folder for new files. When a document is added, it passes the file metadata to the next node. Set Trigger On to Specific Folder and paste your knowledge base folder’s Drive ID into the Folder to Watch field.
Tip: Get a Google Drive folder ID by right-clicking the folder in Drive → Share → copy the URL. The ID is the string after /folders/ in the URL.
9 Google Drive Download (googleDrive)
Downloads the file content as binary data using {{ $json.id }} from the trigger. The downloaded file flows as binary to the data loader in the next step.
10 Chunk & Embed (textSplitter + embeddingsOpenAi)
The Recursive Character Text Splitter breaks the document into 1,000-token chunks with 200-token overlap — this overlap ensures sentences crossing chunk boundaries aren’t lost. The Default Data Loader wraps the binary input for the vector pipeline, and Embeddings OpenAI converts each chunk into a 1,536-dimensional vector using text-embedding-3-small.
11 Pinecone Insert (vectorStorePinecone)
The embedded chunks are stored in your Pinecone index. The agents in the main pipeline can search these immediately after insertion. Both workflows use the same index name — that’s the bridge between them.
You only need to run the ingestion workflow once per document. It does not re-index on every execution — only when a new file appears in the Drive folder. To update a document, delete and re-add it.
The Data Structure
The Google Sheets support dashboard should have these exact column names (the workflow writes to them by name):
| Column | Type | Example | Description |
|---|---|---|---|
Ticket ID |
Text | TECH-1712744591234 |
Unique ticket identifier with category prefix |
Ticket Type |
Text | technical_support |
Category assigned by the classifier |
Sender Email |
Text | james.carter@gmail.com |
Customer’s email address |
Subject |
Text | Getting a 404 error on export |
Original email subject line |
Received At |
Text | 2026-04-10T09:23:11.234Z |
ISO 8601 timestamp when email was processed |
AI Response |
Text | Hi James, I understand you're... |
Full text of the AI reply sent |
Status |
Text | Responded |
Ticket status (auto-set to “Responded”) |
Column names are case-sensitive — they must match exactly as shown, including spaces. Create your Google Sheet with these headers in row 1 before activating the workflow.
Full System Flow
Customer sends email
|
v
[Gmail Trigger -- polls every 1 min]
|
v
[Text Classifier -- GPT-4o-mini reads subject + body]
|
.------+-------------------.-------------------.
v v v v
TECH BILLING URGENT GENERAL
| | | |
v v v v
[Set Metadata -- ticket_type, ticket_id, timestamps, email fields]
| | | |
v v v v
[AI Agent (Gemini 1.5 Flash + Pinecone RAG)]
| | | |
'------+-------------------+-------------------'
| |
v v
[Send Gmail Reply] [Slack Alert] (urgent only)
[Log to Sheets]
-- -- -- -- -- BACKGROUND -- -- -- -- -- --
New doc added to Drive folder
|
v
[Drive Trigger] -> [Download] -> [Chunk+Embed] -> [Pinecone Insert]
Testing Your Workflow
- First, upload a test document to your Drive knowledge base folder — even a plain .txt file with a few sample FAQs. Wait about 30 seconds for the ingestion sub-workflow to index it.
- From a different email account, send an email to your Gmail support inbox with subject: “Getting a login error — can’t access my account”
- Wait up to 60 seconds for the Gmail trigger to poll (or use n8n’s manual trigger to run it immediately).
- Check the original sender’s inbox — an AI reply should arrive within 60–90 seconds.
- Open your Google Sheets dashboard and confirm a new row was added with all seven columns populated.
- For Slack testing: send an email with subject “CRITICAL: Complete platform outage, all users affected” — you should receive a Slack alert within 60 seconds.
| Problem | Likely Cause | Fix |
|---|---|---|
| Trigger never fires | Workflow not active | Toggle the Active switch in n8n top-right |
| Credential error on Gmail | OAuth token expired | Go to Settings → Credentials → re-authorize Gmail OAuth2 |
| No row in Sheets | Wrong spreadsheet ID | Open Log to Support Dashboard → verify Document ID matches sheet URL |
| No Slack notification | Wrong channel ID or app not invited | Check YOUR_SLACK_CHANNEL_ID; run /invite @n8n in the channel |
| Agents respond off-topic | Empty Pinecone index | Upload at least one document to Drive KB folder and wait for indexing |
| Classifier routes everything to General | Input text too vague | Refine category descriptions in the Text Classifier node |
Frequently Asked Questions
Can I use this with a support@ email address instead of a personal Gmail?
Yes. Any Gmail or Google Workspace email account works — just connect that account’s OAuth2 credential. Google Workspace accounts (like support@yourcompany.com) are ideal since they separate support traffic from personal mail.
What happens if the AI doesn’t know the answer?
The agents are prompted to acknowledge what they don’t know rather than making things up. If the knowledge base returns no relevant results, the agent gives a polite, honest response and suggests a human specialist will follow up. You can customize this fallback behavior in each agent’s system prompt.
How much does this cost to run?
Very little for most support volumes. GPT-4o-mini costs roughly $0.15 per million input tokens — classifying 1,000 emails costs about $0.05. Gemini 1.5 Flash has a generous free tier (1,500 requests/day). text-embedding-3-small is similarly cheap. For a team handling 100–500 support emails per day, expect under $5/month in AI API costs.
Can I add a 5th category, like “Onboarding” or “Enterprise”?
Absolutely. Open the Text Classifier node, add a new category with a clear description, then add a corresponding branch: a new Set Ticket Metadata node, a new Agent node with a tailored system prompt, and connect them to the same Send Gmail Response and Log to Support Dashboard nodes. The workflow is fully modular by design.
What file types can I put in the Google Drive knowledge base folder?
The Default Data Loader supports most common text-based formats: PDF, DOCX, TXT, and Markdown. Google Docs should be exported as PDFs or DOCX first. Avoid purely image-based files — they require OCR preprocessing, which this workflow doesn’t include out of the box.
Will it re-process emails I’ve already replied to?
No. The Gmail Trigger is configured to only pick up unread emails. Once a reply is sent, Gmail automatically marks the thread as read, so the same email won’t be processed twice.
🚀 Get the AI Email Support System Template
Skip 45 minutes of setup — get the fully configured workflow JSON, Setup Guide PDF, and Credentials Guide PDF in one download. Import, fill in your API keys, and your AI support agent is live.
Instant download · Works on n8n Cloud and self-hosted
What’s Next?
- Add CSAT follow-up: 24 hours after the initial response, automatically send a one-question satisfaction survey and log responses back to Sheets.
- Sentiment-based prioritization: Add a sentiment analysis node before the classifier — flag angry or frustrated emails for faster human review regardless of category.
- Multi-channel support: Duplicate this pipeline for WhatsApp (via email or SMS) or Telegram to handle all support channels from a single n8n instance.
- Weekly digest report: Add a scheduled workflow that queries your Sheets dashboard every Monday and sends a summary of ticket volumes by category to Slack.
- Escalation SLA tracking: If an urgent ticket hasn’t been resolved within 1 hour, send a follow-up Slack ping to the on-call engineer.