How to build an AI customer support agent in n8n that doesn't make things up

Short answer

Use a Google Sheet as the knowledge base, fetch unread support emails with the Gmail node, send each email plus the KB to an LLM that must return JSON (category, urgency, can_answer, confidence, reply), and enforce escalation in a Code/IF node: only create a Gmail draft when the answer is covered by the KB, confidence is high, and the category isn't refunds, complaints or legal. Log everything to a sheet and label processed emails.

The architecture

Schedule trigger → Config → Get Knowledge Base (Sheets) → build one KB text block (Code) → Get unread support emails (Gmail, search in:inbox is:unread -label:processed) → build the prompt (Code) → LLM call (HTTP Request with JSON mode) → parse and apply rules (Code) → IF safe → Gmail draft in the same thread, else mark needs_human → append to Tickets Log → add the processed label.

The prompt rules that matter

  • "Answer only with facts in the KNOWLEDGE BASE. If it's not there, set can_answer=false."
  • "Never promise refunds, discounts or deadlines unless the KB states them."
  • Return a confidence score and the KB entry ids used, so you can audit answers.

Put the guardrails in code, not just the prompt

Models occasionally ignore instructions. Compute auto_draft = can_answer && confidence ≥ threshold && category not in escalate_list && urgency != high in a Code node and route on that. Escalated emails get a reason in the log, which doubles as a list of gaps in your knowledge base.

Testing it before it touches customers

  1. Replace the Gmail and LLM nodes with Code nodes that return sample emails and canned model answers (including a malformed one).
  2. Check that the refund email is escalated, the KB-covered one gets a draft, and the malformed answer is logged as an error instead of crashing the run.
  3. Then run on 5 real emails with drafts only.

FAQ

Should it send replies automatically?

Not at first. Run in draft mode until your knowledge base covers most questions and you've reviewed a few hundred drafts. If you later automate replies for EU users, disclose that customers are interacting with AI.

Does this work with Zendesk or Freshdesk?

Yes: swap the Gmail nodes for n8n's Zendesk or Freshdesk nodes; the prompt and guardrails stay the same.

Skip the build

The AI Customer Support Agent is this workflow, tested and ready to import, with a setup guide (about 15 minutes on n8n Cloud). $19/month on Starter, 7-day free trial.