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
Automate RAG with n8n and OpenAI

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

Learn how to Build this Workflow with AI:

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.


Automate RAG with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.