Self-Improving AI Email Support System with Human-in-the-Loop - n8n Workflow

Automate customer support using a smart n8n workflow powered by Google Gemini and a Google Sheet knowledge base. This system learns continuously from human experts.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Companies seeking to scale their customer support without increasing headcount.

  • Users looking for advanced n8n templates integrating Google Gemini and Google Sheets.

  • Operations specialists who need a reliable, self-improving AI-powered helpdesk solution.

  • Developers utilizing the power of the n8n node ecosystem for sophisticated decision-making.

Overview

This sophisticated n8n workflow solves the dual challenge of providing instant, high-quality customer support while ensuring the knowledge base remains perpetually up-to-date. When a customer sends an email, this n8n template first checks a centralized Google Sheet knowledge base using an intelligent AI model (Google Gemini 2.5 Pro). If a confident answer is found, the system responds instantly via Gmail.

Critically, if the AI cannot find a relevant answer, the query is escalated to a human expert via the Gmail n8n node. The expert's reply is then automatically captured by the n8n workflow, analyzed by a specialized AI, generalized into a reusable Q&A pair, and appended to the Google Sheet knowledge base. This creates a powerful, autonomous feedback loop, ensuring the n8n workflow continuously learns and improves its automation capabilities, making it one of the most intelligent n8n templates available for support operations.

How it Works

The process begins with the On New Email Received n8n trigger, capturing incoming customer emails.


  1. Classification: The Is it a Support Request? n8n node uses AI (Gemini 2.5 Flash Lite) to classify the email content, ensuring only genuine support queries proceed through the n8n workflow.

  2. Knowledge Retrieval: The Get Knowledge Base Google Sheets n8n node retrieves all existing Q&A pairs. This data is prepared and aggregated into a single context input.

  3. AI Decision: The Find Answer with AI n8n node, powered by Gemini 2.5 Pro, evaluates the customer's query against the retrieved knowledge base. It strictly outputs a JSON object indicating whether an answer was found.

  4. Routing (If Answer Found): The Support Answer Found n8n node checks the AI's response. If true, the Send AI Answer Gmail n8n node sends the formatted HTML reply back to the customer.

  5. Routing (If No Answer): If false, the Ask Human for Help Gmail n8n node forwards the summarized question to a human expert using a 'Send and Wait' operation, pausing the n8n workflow execution until the expert responds.

  6. Autonomous Learning: Once the human expert replies, the AI: Create Reusable Q&A n8n node processes the human's response and the original question to generate a clean, generalized Q&A pair using a separate AI model.

  7. Knowledge Update: Finally, the Add to Knowledge Base Google Sheets n8n node appends this new Q&A pair to the knowledge base, permanently improving the accuracy of the n8n workflow for all future, similar inquiries.

Installation Guide

This n8n workflow is ready for deployment but requires key credential setup.


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance.

  2. Credential Setup: Ensure you have configured and selected working credentials for:

Gmail: Required for the On New Email Received n8n trigger and subsequent send actions (Send AI Answer, Ask Human for Help).
Google Sheets: Required for the Get Knowledge Base and Add to Knowledge Base n8n nodes.
* Google Gemini API: Required for all AI-based LangChain n8n nodes (Is it a Support Request?, Find Answer with AI, AI: Create Reusable Q&A).

  1. Knowledge Base Preparation: Create a Google Sheet with a sheet named 'QA Database' containing 'Question' and 'Answer' column headers. Link this sheet in the Google Sheets n8n nodes.

  2. Expert Configuration: Customize the recipient email address in the Ask Human for Help n8n node to direct unresolved questions to your expert team.

  3. Activate: Once all connections are verified, activate the n8n trigger to begin the automated process.

Node Details

On New Email Received (Gmail Trigger): This is the crucial starting n8n trigger that initiates the entire n8n workflow upon receiving a new email.
Is it a Support Request? (LangChain Text Classifier): Uses Gemini to quickly categorize emails, preventing the rest of the n8n workflow from wasting resources on non-support related messages.
Get Knowledge Base (Google Sheets n8n node): Fetches all available Q&A data from the configured spreadsheet, which serves as the AI's reference context.
Find Answer with AI (LangChain Chain LLM): The core intelligence n8n node. It uses a detailed prompt and Gemini 2.5 Pro to search the knowledge base context for a confident match, outputting a highly structured JSON response.
Structured Output Parser: Paired with the main AI n8n node, this ensures the AI's response adheres strictly to the required JSON format for reliable parsing by the downstream nodes.
Support Answer Found (If Node): Manages the conditional logic, routing the item either to automated response or human escalation, depending on the AI's decision.
Ask Human for Help (Gmail n8n node): Utilizes the 'Send and Wait' operation to notify a human expert and pause the n8n workflow until a solution is provided, enabling the Human-in-the-Loop feature.
AI: Create Reusable Q&A (LangChain Chain LLM): This learning n8n node generalizes the human expert's ad-hoc response into a canonical, future-proof Q&A pair.


  • Add to Knowledge Base (Google Sheets n8n node): Executes the knowledge update by appending the newly generated, AI-refined Q&A pair to the end of the sheet.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by

Innovative builder with a passion for crafting automation solutions that solve real-world challenges. From streamlining workflows to driving efficiency, my work empowers teams and individuals to achieve more with less effort. Experienced in developing scalable tools and strategies that deliver results with n8n, supabase and cline. Join the N8N Academy:

Featured*