Knowledge Base Chatbot using OpenAI, Notion, and Agent Logic - n8n Workflow

Build a powerful RAG chatbot using an n8n workflow combining OpenAI, Notion database tools, and conversational memory. Use this n8n template for fast deployment of AI knowledge agents.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers deploying custom chat widgets or conversational APIs.

  • Businesses looking to automate customer support using existing Notion documentation.

  • Technical users implementing Retrieval-Augmented Generation (RAG) systems.

  • n8n users seeking advanced LangChain agent examples and complex n8n templates.

Overview

This robust n8n workflow template demonstrates how to construct a sophisticated Retrieval-Augmented Generation (RAG) chatbot agent entirely within n8n. By leveraging specialized n8n node types from the LangChain integration, this automation connects an OpenAI Large Language Model (LLM) to a proprietary knowledge source—specifically, a designated Notion database. This powerful structure allows the AI to answer user questions based on the content of your Notion pages, vastly improving accuracy and relevance beyond general model training. This is a crucial n8n workflow for anyone aiming to build embedded customer support features or internal knowledge search tools, offering a highly customizable alternative to off-the-shelf solutions. Utilizing this n8n template ensures rapid deployment of a smart, context-aware agent.

How it Works

This n8n workflow operates as a continuous service, responding to incoming chat requests and intelligently synthesizing information:


  1. Trigger Initiation: The flow begins when a user sends a message, captured by the Start Chat Conversation n8n trigger node. This node provides the real-time endpoint for the chatbot interface.

  2. Agent Orchestration: The user's input is passed directly to the Smart AI Agent n8n node. This agent acts as the brain, determining whether the query requires external knowledge or can be answered contextually.

  3. Core AI Processing: The Agent leverages the OpenAI Chat Model for complex reasoning, language understanding, and response generation.

  4. Context Maintenance: Throughout the conversation, the Remember Chat History n8n node maintains conversation context. This memory feature allows the n8n workflow to handle follow-up questions accurately.

  5. Knowledge Retrieval (RAG): If the Agent decides the query needs specific data (e.g., product facts, policies), it utilizes the connected n8n tool, Set & Get Notion Database. It performs a lookup, retrieves the relevant text from Notion, and integrates this data into the prompt before generating the final, informed response to the user. This dynamic tool usage defines the intelligence of this n8n workflow.

Installation Guide

To deploy this n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON code and paste it into your n8n instance via the 'New' menu and selecting 'Import from JSON'.

  2. OpenAI Credential Setup: Locate the OpenAI Chat Model n8n node and set up or select your existing OpenAI API key credential. This is essential for the language model functionality.

  3. Notion Credential Setup: Locate the Set & Get Notion Database n8n node. You must connect your Notion credential (API key) and specify the Database ID that holds your knowledge base content.

  4. Agent Configuration: Verify the connections between the Smart AI Agent and the three supporting n8n node components (Model, Memory, Tool).

  5. Activation: Once credentials are set, save and activate the n8n workflow. The Start Chat Conversation n8n trigger will provide a URL endpoint for integrating this chatbot into your application or website.

Node Details

Start Chat Conversation (n8n Trigger Node):
Function: Serves as the primary entry point and n8n trigger for the conversational interface. It receives user messages and initiates the flow.
Key Configuration: Configured to expose a webhook ID for external chat integration.
Smart AI Agent (LangChain Agent Node):
Function: The central routing mechanism. It interprets the user's intent, manages conversation history, and decides whether to use the OpenAI model directly or call the Notion tool.
Key Configuration: Acts as the recipient for the n8n trigger and connects to the model, memory, and tool.
OpenAI Chat Model (LangChain LM Node):
Function: Provides the Large Language Model capabilities used by the Agent for complex reasoning and human-like response generation.
Key Configuration: Requires valid OpenAI API credentials for operation within the n8n workflow.
Remember Chat History (LangChain Memory Node):
Function: Stores preceding messages in the conversation to ensure the Agent maintains context, allowing for coherent back-and-forth communication within this n8n node setup.
Key Configuration: Uses Buffer Window Memory, retaining a fixed number of recent interactions.
Set & Get Notion Database (Notion Tool Node):
Function: This is the RAG tool. It allows the Agent to search and retrieve structured or unstructured data directly from a designated Notion database to answer fact-based questions.

Related n8n Workflows

Paid

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

We at Gegenfeld are an EdTech platform dedicated to delivering high-quality on-demand courses and interactive training sessions for professional development at all skill levels. With our commitment to "Accelerate your future," we empower professionals to enhance their expertise through engaging, industry-focused learning experiences. On n8n, we share some of the workflows used in our interactive training to provide deeper insights and practical applications.

Featured*