workflows.fit
Back to n8n workflows
n8n templateFreeBy Vivekanand M

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

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 th...

DevelopmentData & StorageCommunicationHITLCore NodesAILangchainManual Trigger
Loading interactive preview...

Template notes

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 conversation pairs, classifying them with AI, generating vector embeddings, and storing everything in a PostgreSQL database โ€” ready to power AI-assisted draft generation in downstream workflows.

The workflow is triggered manually and fetches the last N emails from your connected Gmail account. Each email is parsed, filtered, and deduplicated before being processed. A thread-level fetch retrieves the full conversation context, separating customer messages from support replies. An AI classification step categorises each thread into a defined scenario type. Vector embeddings are generated for semantic similarity search. Qualified threads are inserted into three database tables โ€” kbdata for clean Q&A pairs, scenariopatterns for reusable handling logic, and corrections for diverse real-world examples โ€” with strict deduplication to keep the KB clean and non-redundant.

---

โš™๏ธ What This Workflow Does (Step-by-Step)

๐Ÿ“ฅ Manual Trigger โ€” Run on demand whenever you want to import a batch of historical emails into the KB. No scheduling required.