AI Auto-Response System with RAG and Qdrant - n8n Workflow

Deploy this robust n8n workflow for automated email responses. It integrates RAG (Qdrant) and OpenAI/DeepSeek to summarize inquiries, classify requests, and generate professional, knowledge-based replies. Leverage this powerful n8n template today.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Business owners or support teams receiving high volumes of repetitive inquiries.
Technical users looking for advanced n8n templates integrating multiple LLMs (DeepSeek, OpenAI).
Developers needing a ready-made solution for implementing RAG (Retrieval-Augmented Generation) within a live email n8n workflow.
Companies aiming to improve initial response times using an automated n8n solution.

Overview

Managing high volumes of business email requests, especially those related to common company information, is time-consuming. This specialized n8n workflow provides a solution by automating the entire lifecycle: reception, summarization, classification, knowledge retrieval, response generation, and delivery.

This robust n8n template solves the problem of delayed or inconsistent responses by leveraging cutting-edge AI agents and a dedicated knowledge base (Qdrant Vector Store). The powerful combination ensures that only relevant emails trigger the RAG mechanism, allowing the n8n node flow to access proprietary knowledge and generate highly accurate, concise, and professionally formatted replies. This advanced n8n automation saves staff hours and significantly boosts customer service efficiency.

How it Works

This comprehensive n8n workflow operates in two distinct parts: the RAG Knowledge Base setup and the primary email automation flow.

1. Knowledge Base Setup (Initial Run)


  1. The setup path, triggered manually, first uses an HTTP Request n8n node to create and refresh the Qdrant collection.

  2. Next, it connects to Google Drive via the Google Drive n8n node to retrieve documents from a specified folder.

  3. These documents are downloaded, processed by the Default Data Loader, and chunked using the Token Splitter n8n node.

  4. The documents are vectorized using the Embeddings OpenAI n8n node and finally inserted into the Qdrant Vector Store, creating the operational knowledge base (RAG).

2. Primary Email Automation Flow


  1. Trigger: The automation starts with the Email Trigger (IMAP) n8n trigger, which listens for new incoming emails.

  2. Preprocessing: The incoming HTML email body is converted to Markdown using the Markdown n8n node for optimal LLM processing.

  3. Summarization: The Email Summarization Chain, leveraging the DeepSeek R1 model, generates a concise summary (max 100 words) of the email content.

  4. Classification: The Email Classifier n8n node (using OpenAI 4-o-mini) checks if the summarized request matches the 'Company info request' category. If it does not, the n8n workflow ends via the 'Do nothing' node.

  5. Response Generation (RAG): If classified positively, the 'Write email' Agent n8n node takes over. This agent is configured to access the proprietary Qdrant Vector Store (RAG) to find necessary company information and draft a professional response based on the original email query and the retrieved context. The agent uses a strict system message to ensure the reply is professional and under 100 words.

  6. Review and Formatting: The raw AI-generated text is passed to the 'Review email' LLM Chain n8n node. This node uses a specialized model (DeepSeek) to review, structure, and convert the response into a ready-to-send HTML format, maintaining professional structure and brevity.

  7. Delivery: Finally, the Send Email n8n node automatically replies to the original sender's address, completing the cycle of this sophisticated n8n workflow.

Installation Guide

To utilize this n8n template, follow these steps:


  1. Import Workflow: Copy the provided n8n workflow JSON and paste it into your n8n instance.

  2. Set up Credentials: This n8n workflow requires several credentials:

IMAP/SMTP: Credentials for the Email Trigger (IMAP) n8n trigger and the Send Email n8n node for monitoring and sending emails.
OpenAI/OpenRouter: API keys for the language models (DeepSeek R1 and OpenAI 4-o-mini) used for summarization, classification, and response generation.
Qdrant API: Credentials for your Qdrant vector database instance.
Google Drive: OAuth2 credentials for accessing the documents used for RAG.

  1. Configure RAG Settings: In the RAG setup path (Sticky Note 1 & 2):

Update the QDRANTURL and COLLECTION names in the HTTP Request nodes (Create collection, Refresh collection).
Update the folder ID in the Get folder Google Drive n8n node to point to your knowledge base documents.

  1. Activate: Save the n8n workflow and activate the main trigger (Email Trigger (IMAP)) for continuous automation.

Node Details

This powerful n8n workflow leverages a variety of standard and AI-specific n8n node types:

Email Trigger (IMAP):
Function: The primary n8n trigger, initiating the automation upon receiving a new email.
Key Configuration: Monitored mailbox (e.g., [email protected]).
Email Summarization Chain (LangChain):
Function: Utilizes DeepSeek R1 (via OpenRouter) as the LLM to create a concise summary of the lengthy email body.
Key Configuration: Summarization prompt limits output to a maximum of 100 words.
Email Classifier (LangChain):
Function: A routing n8n node that classifies the summarized email into categories (e.g., 'Company info request') to determine if RAG response is appropriate.
Key Configuration: Uses gpt-4o-mini for fast and accurate classification.
Qdrant Vector Store (LangChain):
Function: Configured in 'retrieve-as-tool' mode. This is the crucial RAG component, providing context from the vector database to the AI Agent.
Key Configuration: Linked to a specific COLLECTION and assigned the tool name companyknowledgebase.
Write email (LangChain Agent):
Function: The core response generator. It uses the input email and the RAG tool (Qdrant) to write a professional, informative reply.
Key Configuration: System message enforces expert tone and a limit of 100 words.
Review email (LangChain LLM Chain):
Function: Acts as a final editorial layer, ensuring the generated text is structured professionally and formatted using basic HTML tags (like and
) before being sent.
Send Email (SMTP):
Function: The final action n8n node, dynamically sending the reviewed response back to the original sender, completing the n8n workflow's objective.
Key Configuration: To Email is dynamically mapped from the IMAP trigger's from field.

Related n8n Workflows

Free

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

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza

Featured*