Automate RAG with Notion & OpenAI in n8n

Streamline retrieval-augmented generation (RAG) on your Notion knowledge base with this comprehensive n8n workflow using OpenAI and Supabase. Automate embedding updates and smart Q&A with chat triggers to save hours and boost accuracy.
embeddingsOpenAi
chainRetrievalQa
supabase
+13
Workflow Identifier: 1284
NODES in Use: embeddingsOpenAi, textSplitterTokenSplitter, splitInBatches, chainRetrievalQa, retrieverVectorStore, lmChatOpenAi, chatTrigger, scheduleTrigger, stickyNote, limit, supabase, notion, noOp, summarize, documentDefaultDataLoader, vectorStoreSupabase

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Workflow Does

This workflow updates and uses a Notion knowledge base automatically inside n8n. It fixes the problem of long manual search through many pages. The result is fast, accurate answers to questions using OpenAI and Supabase embedding search.

It pulls new or changed Notion pages, removes old saved data, creates new text chunks and embeddings, stores them, and lets users ask questions that get smart answers from the updated data.


Tools and Services Used

  • Notion API: To fetch pages and content blocks from the knowledge base.
  • OpenAI API: To create embeddings for text and generate chat answers.
  • Supabase Vector Store: To save and search text embeddings efficiently.
  • n8n: Automation platform to run the workflow steps and connect nodes.

How the Workflow Works: Inputs → Process → Output

Inputs

  • Schedule trigger starts the update check on a time interval.
  • Notion database ID to fetch updated pages.
  • OpenAI API key for embedding and chat model.
  • Supabase credentials for embedding storage.

Processing Steps

  • Get Notion pages updated in last minute.
  • Loop through updated pages one by one.
  • Delete old embeddings in Supabase for each updated page.
  • Fetch all content blocks of each page from Notion.
  • Combine all blocks into one text string.
  • Split text into chunks of 500 tokens for efficient embedding.
  • Create embeddings for each chunk using OpenAI.
  • Save embeddings with page info in Supabase.
  • Accept chat questions via webhook node.
  • Use vector store retriever to find matching chunks.
  • Generate answer using OpenAI chat model with retrieved context.

Output

  • Clean, up-to-date vector store with fresh embeddings.
  • Instant, relevant answers to user questions from the knowledge base.

Who Should Use This Workflow

This workflow is good for people who want to make their Notion knowledge bases smart and searchable. Users who need fast answers without searching manually will like this.

Anyone who wants to keep the data fresh automatically, without spending hours updating embeddings by hand, will find this useful.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Download and Import

  1. Download the workflow file by clicking the Download button on this page.
  2. Open the n8n editor where you want to run the workflow.
  3. Use “Import from File” in n8n to load the workflow you downloaded.

Step 2: Add Credentials and IDs

  1. Add your Notion API credentials under Credentials in n8n.
  2. Enter your OpenAI API key in the corresponding OpenAI node.
  3. Add Supabase credentials in the Supabase node and check the table name “documents” exists.
  4. Update any Notion database IDs or page IDs if needed in the nodes.

Step 3: Test the Workflow

  1. Run the workflow manually once to see if it fetches pages and creates embeddings.
  2. Check any errors or missing data to fix the config.

Step 4: Activate for Production Use

  1. After testing success, activate the workflow in n8n.
  2. Keep the schedule trigger active to poll for updates automatically.
  3. Use the chat webhook URL to send questions and receive answers.

For self hosting n8n, see self-host n8n for help running the workflow continuously.


Customizations

  • Change token chunk size in the Token Splitter node if you want fewer or smaller pieces of text.
  • Select different embedding models in the OpenAI node if cost or accuracy needs vary.
  • Turn on the Notion Trigger node instead of Schedule Trigger to listen for updates automatically and save calls.
  • Add more metadata fields like author or date in the Supabase node to improve search detail.

Common Problems and Fixes

  • No pages found on update check: Check the time filter expression in the Notion getAll node. Make sure pages have been edited recently.
  • Embeddings not saved in Supabase: Confirm table name is “documents” and metadata keys are correct.
  • Chat webhook unreachable: Ensure the webhook URL is public, workflow is active, and there is no firewall blocking access.

Summary of Benefits and Results

✓ Saves hours of manual knowledge base updates every day.
✓ Keeps vector store embeddings fresh and accurate.
✓ Answers questions instantly using latest Notion content.
✓ Makes knowledge bases smarter with automation.
✓ Easy to use and adapt for your own data and needs.


Frequently Asked Questions

The workflow uses a Schedule Trigger to check every minute for Notion pages updated in the last minute using a time filter expression.
Deleting old embeddings ensures that only current, relevant text chunks are stored in Supabase vector store, avoiding outdated search results.
Yes, the chunk size is set in the Token Splitter node and can be adjusted to balance between embedding size and number of chunks.
Chat questions go to a webhook node, then a Vector Store Retriever finds matching embeddings, and finally OpenAI chat model generates answers using that context.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free