Templates / Build a support knowledge base from historical Gmail emails with OpenAI and PostgreSQL

Build a support knowledge base from historical Gmail emails with OpenAI and PostgreSQL

Ready for 3.0

by Vivekanand M ✓ · 113 views · created 2026-04-24 · Internal Wiki, AI RAG

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 16 nodes and runs manually, when you click “Execute workflow”. Along the way it connects Gmail, Postgres and OpenAI Chat Model.

How it runs

Trigger: Manually, when you click “Execute workflow”.

  1. Fetch Emails (Gmail): get many
  2. Parse and Filter (Code): runs custom JavaScript code
  3. Is Customer Email (If): checks a condition and branches into true / false
  4. Check Duplicate in DB (Postgres): run a query
  5. Merge Duplicate Result (Code): runs custom JavaScript code
  6. Not Already Processed (If): checks a condition and branches into true / false
  7. Assemble Thread (Code): runs custom JavaScript code
  8. AI Extract KB Entries (AI Agent): runs an AI agent, with model: OpenAI Chat Model
  9. Parse KB Entries (Code): runs custom JavaScript code
  10. Has KB Entries (If): checks a condition and branches into true / false

…plus 4 more steps. See the full node list below.

Services it uses

GmailPostgresOpenAI Chat Model

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (7)

From the author

KB Builder — Historical Emails n8n Workflow Template --- 📘 Description This workflow automates the process of building a structured Knowledge Base (KB) from your existing Gmail inbox by processing historical email threads, extracting customer-support…

Excerpt from Vivekanand M's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.