AK
← All projects

AI Automation

RAG Email Customer Support Agent with Human Approval

Reads incoming support emails, retrieves the right answer from a vector knowledge base, drafts a reply, and waits for a human to approve before sending. Built in three industry variants.

n8nOpenAIPineconeGmailHuman-in-the-loop
n8n workflow — ingestion sub-flow into Pinecone, and a Gmail-triggered AI support agent with a human approval step

How it flows

  1. 1New customer email arrives in Gmail
  2. 2Fields are normalised (sender, subject, body, thread)
  3. 3AI Agent searches the Pinecone knowledge base
  4. 4Draft reply is emailed to a reviewer with Approve / Reject buttons
  5. 5Approved reply is sent in the original thread

The problem

Support teams answer the same questions every day: refund policy, shipping times, how to reset a password. An AI reply is fast, but a wrong AI reply damages trust. The system needed to be accurate and safe.

What I built

One n8n workflow with two parts.

Ingestion (run once, or whenever documents change)

  1. A manual trigger loads the company knowledge text.
  2. A Recursive Text Splitter cuts it into 800-character chunks with 100-character overlap.
  3. OpenAI embeddings turn each chunk into a vector.
  4. The vectors are inserted into a Pinecone index.

Reply flow (runs every minute)

  1. A Gmail trigger picks up new customer emails (and ignores the approval emails it sends itself).
  2. A Set node prepares clean fields: sender, subject, body, thread ID, message ID.
  3. An AI Agent (GPT-4o-mini, temperature 0.2) is given the Pinecone store as a retriever tool. The system prompt says: always search the knowledge base first; answer only from retrieved content; if the answer is not there, say you will escalate.
  4. A Gmail Send and Wait node emails the draft to a reviewer with the original customer message and two buttons: Approve & Send or Reject. The workflow pauses here.
  5. An If node checks the decision. Approved drafts are sent as a reply in the customer’s thread. Rejected drafts go to a No-Op branch for manual handling.

Three industry variants

The same workflow was cloned with a different knowledge base and Pinecone index for each:

  • E-commerce — orders, shipping tiers, returns, payments, warranties
  • SaaS — accounts, plans and billing, integrations, troubleshooting, security
  • Education — enrollment, course access, certificates, refunds, instructors

Each knowledge base includes an escalation note that tells the agent which topics (billing disputes, security incidents, accessibility requests) must always go to a human.

Why it matters

The retriever tool gives the model real company facts. The approval step gives the company control. Together they turn an experiment into something a real support team could run.