An email arrives, the workflow decides if it is a support request, pulls the right answer from your Pinecone knowledge base and replies in the original Gmail thread. When the knowledge is not good enough, a person gets it instead. Built and tested before applying.
This is the real node layout of the importable JSON. Press run: each fictional email lights up the path it takes, and the result lands in the log.
–
–
Recorded simulation: the Code nodes and the routing are executed from the workflow JSON itself. Gmail is replaced by 8 fixture emails, OpenAI calls are the LLM step (client's own API key) and are mocked here, Pinecone is a local keyword index over a small fictional knowledge base. In your project it runs against your real Gmail, OpenAI and Pinecone index.
Each scenario from your post, with the route the workflow took. Full trace per email in test-log.json.
| # | Scenario | Category | Top score | Route | Result | |
|---|---|---|---|---|---|---|
| m01 | Support email, strong KB match | Our website is down!! dana@harborbakery.example · thread t01 | outage | 0.95 | Replied in thread | PASS |
| m02 | Billing question, strong KB match | Copy of invoice 2026-0412 accounts@peakdental.example · thread t02 | outage | 0.95 | Replied in thread | PASS |
| m03 | Newsletter, filtered without reply | 5 growth hacks for agencies this week news@growthweekly.example · thread t03 | newsletter | – | Filtered, no reply | PASS |
| m04 | Change request, KB match | Change the banner on the homepage mark@ridgeoutdoor.example · thread t04 | change_request | 0.905 | Replied in thread | PASS |
| m05 | Follow-up in existing thread (thread continuity) | Re: Our website is down!! dana@harborbakery.example · thread t01 | outage | 0.95 | Replied in thread | PASS |
| m06 | Support question the KB cannot answer | Custom ERP sync for our product feed li@oakfurniture.example · thread t06 | other_support | 0.5 | Escalated to human | PASS |
| m07 | Auto-reply, filtered without reply | Automatic reply: Out of office sam@peakdental.example · thread t07 | auto_reply | – | Filtered, no reply | PASS |
| m08 | Credential failure on the reply step (OpenAI 401), retried, then escalated | Password reset email not arriving nina@citylaw.example · thread t08 | access | 0.95 | Escalated to human | PASS |
The integration mapping that ships with the handover document.
| Node | What it does | Credential |
|---|---|---|
| Gmail Trigger | Polls the support inbox every minute for unread mail in INBOX. | Gmail OAuth2 |
| Normalize email | Captures sender, subject, body, message ID and thread ID once, so every later node uses the same fields. | – |
| AI classify | OpenAI chat call in JSON mode: is_support, category, confidence, a short search query. Retries 3× with 2 s wait; errors go to escalation. | OpenAI |
| Parse classification · Is support? | Unparsable answers or confidence under 0.6 never trigger a reply. Non-support mail is labelled and logged. | – |
| Embed question · Pinecone query | OpenAI embeddings of the search query, top 4 matches with metadata from your existing index and namespace. | OpenAI, Pinecone |
| Knowledge gate · Enough knowledge? | Only answers when the top match is at least 0.78 (tunable in one place). Builds the numbered context for the reply. | – |
| AI draft reply | Answers only from the snippets, says a person will follow up if they do not cover it. | OpenAI |
| Reply in thread | Gmail reply operation on the original message ID, so the answer stays in the customer's thread. | Gmail OAuth2 |
| Prepare escalation · Escalate to human | Every path that cannot answer safely (low knowledge, API or credential error) lands here and goes to the support lead with context. | Gmail OAuth2 |
| Log … · Write log row | Exactly one row per email in a Google Sheet: route, category, score, sources, note. | Google Sheets |
| Error Trigger · Alert support lead | Anything unexpected sends an alert with the failing node and execution link. | Gmail OAuth2 |
You add the Gmail, OpenAI and Pinecone credentials in n8n. I confirm the index name, namespace, embedding model and who receives escalations.
Import the workflow, connect your credentials and index, tune the score threshold on your own emails, then run every scenario from your list.
Workflow design and integration mapping, process diagram, testing notes with checklist, handover summary with activation and maintenance steps, final JSON.
The complete workflow configured on your n8n, tested against all scenarios from your post, plus the five handover documents. Delivered within 3 working days of access.
n8n, OpenAI and Pinecone run on your own accounts and keys. Nothing is routed through mine.
The workflow from your post (Gmail → AI classification → Pinecone retrieval → AI reply in thread, with escalation), error handling and retries, testing of all listed scenarios, and the five handover documents including the importable JSON.
Your n8n version and hosting (cloud or self-hosted), the Pinecone index name, namespace and the embedding model it was built with (the query must use the same one), one support inbox, English emails, and the address that receives escalations.
14 days after handover for fixes and threshold tuning, included. I work Central European business hours, which overlaps with your US morning.
Building or re-indexing the Pinecone knowledge base, extra inboxes or channels (chat, helpdesk tools), attachments and image parsing, ongoing monitoring after the support window, and the usage costs of n8n, OpenAI and Pinecone.