Notion Knowledge Base Retrieval Augmented Generation (RAG) Assistant - n8n Workflow

Build a Retrieval Augmented Generation (RAG) assistant using this n8n workflow. Connect OpenAI's GPT-4o to your Notion database for instant, accurate answers from internal company data.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Companies or teams that maintain critical documentation in Notion and require fast, conversational access to that data.

  • n8n users looking for advanced examples of combining LangChain AI nodes with standard application integrations.

  • Developers seeking a robust n8n workflow template for building custom RAG systems.

  • Automation specialists needing to leverage the power of the OpenAI n8n node for data retrieval.

Overview

Maintaining an extensive company knowledge base in Notion is standard practice, but quickly finding specific answers can be challenging. This advanced n8n workflow solves this by deploying a dedicated AI Agent that can intelligently query, search, and summarize data directly from your Notion workspace. This solution utilizes a Retrieval Augmented Generation (RAG) pattern, ensuring the AI's responses are grounded strictly in your proprietary data, minimizing hallucinations and maximizing accuracy.

This robust n8n template streamlines the interaction. Instead of manually searching, users simply chat with the AI assistant via the primary n8n trigger. The internal logic leverages several custom HTTP Request tools, allowing the AI Agent to perform sophisticated lookups based on keywords and tags defined within your Notion structure. This powerful n8n workflow transforms your static documentation into an active, responsive knowledge asset.

How it Works

This automation begins with the When chat message received n8n trigger, initiating the interactive chat session.


  1. Preparation: Upon receiving a user's prompt, the workflow first executes the Get database details n8n node. This essential step fetches the metadata and current available tags from the target Notion knowledge base. This dynamic information is then passed to the Format schema n8n node, which aggregates the session context, user input, database ID, and the dynamic list of Notion tags.

  2. AI Orchestration: The formatted data is fed directly into the AI Agent n8n node. This agent, powered by the OpenAI Chat Model (configured with gpt-4o), determines the best course of action.

  3. Context and Memory: Conversational continuity is maintained by the Window Buffer Memory n8n node, which stores the last four interactions, enhancing the agent's ability to handle follow-up questions within the same chat session.

  4. Tool Use (RAG): The AI Agent has access to two custom n8n tools built using the HTTP Request functionality:

Search notion database: Searches the database structure for relevant page records based on user keywords or tags.
Search inside database record: If the initial search yields a Page ID, the Agent uses this tool to retrieve the actual page content (blocks/children) to use for summarization.

  1. Final Response: Based on the information retrieved from the Notion database via these specialized tools, the AI Agent generates a concise, accurate response and sends it back to the user interface initiated by the n8n trigger.

Installation Guide

To deploy this comprehensive n8n workflow template, follow these steps:


  1. Import: Import the provided n8n workflow JSON into your n8n instance.

  2. Notion Setup: Ensure you have a Notion credential configured. You must share your target Notion knowledge base database with the integration you created for this credential.

  3. Credential Configuration:

Configure the OpenAI Chat Model n8n node with your OpenAI API Key credential.
Configure the Get database details, Search notion database, and Search inside database record n8n nodes with your Notion API credential.

  1. Database Selection: In the Get database details n8n node, use the dropdown menu to select the specific Notion database you intend to use as your knowledge source.

  2. Activation: Click the 'Chat' button on the When chat message received n8n trigger to test the interaction. Once confirmed working, activate the n8n workflow to make the chat URL public and accessible for your users.

Node Details

When chat message received (n8n trigger): This LangChain chat trigger starts the automation flow, providing an interactive, web-based chat interface for users to submit questions to the AI assistant. It handles the initial user input and session management.
Get database details (Notion n8n node): Fetches crucial metadata, including the ID and available multi_select options (tags), from the configured Notion database. This dynamic data informs the AI Agent about valid search parameters.
Format schema (Set n8n node): Gathers and structures key data variables (session ID, user chat input, Notion ID, and the retrieved list of tagsOptions) for use by downstream LangChain nodes, ensuring the AI Agent has all necessary context.
AI Agent (LangChain n8n node): The core decision-making component. It utilizes the provided System Message to adhere to strict RAG protocols (be concise, use only facts from records, provide URLs) and orchestrates the use of the available Notion tools.
OpenAI Chat Model (LangChain n8n node): Provides the LLM reasoning backbone for the Agent, configured to use gpt-4o with a standard temperature of 0.7.
Window Buffer Memory (LangChain n8n node): Maintains the chat history (context window length 4), allowing the AI Agent to reference previous turns in the conversation.
Search notion database (HTTP Request Tool n8n node): Acts as the AI's primary search tool. It constructs a Notion API query to find records based on keywords in the 'question' property or matching tags, using dynamic data supplied by the n8n workflow.
Search inside database record (HTTP Request Tool n8n node): This specialized tool allows the AI Agent to execute a second step: retrieving the detailed block content of a specific page ID identified by the Search notion database tool, completing the knowledge retrieval step of this n8n workflow.

Related n8n Workflows

Free

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

Principal Product Designer @ n8n

Featured*