Implement an Adaptive RAG system using this advanced n8n workflow. Classify user queries (Factual, Analytical, Opinion, Contextual) and customize retrieval strategies with Google Gemini, Qdrant, and specific n8n node configurations.
Download this n8n workflow template and start using it instantly.
Who is this for?
This comprehensive n8n workflow provides a blueprint for building advanced Retrieval-Augmented Generation (RAG) systems that move beyond standard keyword matching. The primary challenge this n8n template solves is that not all queries are equal; a factual question requires precision, while an analytical query needs breadth. By classifying the incoming user query (using the Query Classification n8n node powered by Google Gemini) into one of four categories (Factual, Analytical, Opinion, Contextual), the system dynamically selects an optimal retrieval strategy. This powerful adaptive approach ensures that the documents retrieved from the Qdrant vector database are maximally relevant to the user's intent, resulting in highly accurate and context-aware responses. This specific n8n workflow serves as an excellent reference for anyone looking to deploy production-ready, context-sensitive AI agents.
The operation of this complex n8n workflow is divided into four main stages, starting immediately after the initial n8n trigger:
Combined Fields n8n node ensures that the userquery, chatmemorykey, and vectorstore_id (the Qdrant collection ID) are standardized for subsequent processing.Query Classification n8n node, powered by Google Gemini, analyzes the user query and classifies it (e.g., 'Factual', 'Analytical'). A Switch n8n node then directs the flow to one of four specialized paths.Retrieve Documents from Vector Store n8n node, which uses Gemini embeddings to search the Qdrant database. The resulting documents are concatenated.Answer agent uses the specific system prompt (set according to the original classification), the retrieved context, the original user query, and the ongoing conversation history (via Chat Buffer Memory) to generate the definitive response. This response is then immediately returned to the user via the Respond to Webhook n8n node.To utilize this sophisticated n8n workflow, follow these setup steps:
Gemini Classification, Gemini Answer, etc.).Retrieve Documents from Vector Store n8n node.vectorstoreid variable within the Combined Fields n8n node, or ensure it is passed correctly via the n8n trigger, to match the ID of the Qdrant collection containing your documents. This n8n workflow leverages various advanced n8n node types to achieve the Adaptive RAG logic:
Chat / Execute Workflow Trigger (n8n trigger): Initiates the entire process. Provides the initial userquery and session keys.
Combined Fields (Set n8n node): Standardizes input variables (userquery, chatmemorykey, vectorstoreid) from the n8n trigger for consistent data flow.
Query Classification (Gemini Agent n8n node): Function: Classifies the raw query into Factual, Analytical, Opinion, or Contextual. Key Configuration: Uses a highly constrained system message to return only the category name.
Switch (Core Logic n8n node): Function: Routes the workflow based on the classification output provided by the previous n8n node.
Factual/Analytical/Opinion/Contextual Strategy (Gemini Agent n8n node): Function: Dynamically adapts the original query based on the category (e.g., query rewriting, sub-question generation). Each strategy uses its own memory buffer.
Retrieve Documents from Vector Store (Qdrant n8n node): Function: Executes the vector search using the adapted query output and Google Gemini embeddings. Key Configuration: Targets the collection specified by vectorstoreid and retrieves topK: 10 documents.
Concatenate Context (Summarize n8n node): Function: Aggregates the pageContent from all retrieved documents into a single block of context, separated by a distinct marker (---\n\n).
Answer (Gemini Agent n8n node): Function: The final generation step. It utilizes the concatenated context and a category-specific system prompt (defined by a preceding Set n8n node) to produce the final, comprehensive response.
Implement an Adaptive RAG strategy using n8n to classify user queries (Factual, Analytical, Opinion, Contextual) and tailor retrieval prompts using Gemini and Qdrant. A powerful n8n workflow template.

Automate Gmail responses using an advanced n8n workflow leveraging OpenAI, LangChain RAG, and Google Sheets for continuous learning and dynamic prompting. Find the best n8n templates here.

Automate ad library monitoring using this comprehensive n8n workflow. Scrape ads, filter by engagement, analyze video and image creatives using Gemini and GPT (OpenAI/Langchain n8n node), and log results to Google Sheets.

Automate content enrichment using this powerful n8n workflow. Fetch WordPress articles, generate AI summaries via GPT-4.1, and update posts automatically. Ideal for content marketing teams.

Use this powerful n8n workflow and LangChain AI agent to converse naturally with a bot, automatically creating and logging project tasks directly into Google Sheets. Leverage n8n templates for instant task automation.


software dev | business automation specialist







































