RAG on living data n8n Workflow Template

n8n workflow template · 18 nodes · OpenAI

RAG on living data is a free n8n workflow template that starts when a chat message is received and works with OpenAI, Supabase and Notion. It has 18 nodes, 9 of them AI nodes (OpenAI Embeddings, Token Splitter, Question and Answer Chain and Vector Store Retriever). The notes inside the workflow say: “Using a manual approach for polling data from Notion for more accuracy.” To run it, you add your own credentials for Notion API, OpenAI API and Supabase API.

At a glance

Trigger
Chat Trigger (When chat message received)
Nodes
18
Apps
OpenAI, Supabase and Notion
AI nodes
9
Credentials
3 types
Category
RAG, documents and vector search

Apps and integrations

  • OpenAI
  • Supabase
  • Notion

Node types used

  • OpenAI Embeddings
  • Token Splitter
  • Loop Over Items
  • Question and Answer Chain
  • Vector Store Retriever
  • OpenAI Chat Model
  • Chat Trigger
  • Schedule Trigger
  • Limit
  • Supabase
  • Notion
  • Default Data Loader
  • Notion Trigger
  • Supabase Vector Store
  • Summarize

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Using a manual approach for polling data from Notion for more accuracy.

Simple chat bot to ask specific questions while having access to the context of the Notion Knowledge Base which was stored in the Vector Store

Switch trigger (optional)

If you are on the cloud plan, consider switching to the Notion Trigger Node instead, to save on executions.

Select Database

Choose the database which represents your Knowledge Base

This placeholder serves as a reference point so it is easier to swap the data source with a different service

Process each page/document separately.

All chunks of a previous version of the document are being deleted by filtering the meta data by the given ID

Reduce the active streams/items to just 1 to prevent the following nodes from double-processing

Model used for both creating and reading embeddings

Retrieve all page contents/blocks

Combine all contents to a single text formatted into one line which can be easily stored as an embed

Embed item and store in Vector Store. Depending on the length the content is being split up into multiple chunks/embeds

Store additional meta data with each embed, especially the Notion ID, which can be later used to find all belonging entries of one page, even if they got split into multiple embeds.

Adjust chunk size and overlap

For more accurate search results, increase the overlap. For the text-embedding-ada-002 model the chunk size plus overlap must not exceed 8191

Reduce the active streams/items to just 1 to prevent the following nodes from double-processing

Nodes in this workflow

The 18 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. Embeddings OpenAI (OpenAI Embeddings)
  2. Token Splitter (Token Splitter)
  3. Loop Over Items (Loop Over Items)
  4. Question and Answer Chain (Question and Answer Chain)
  5. Vector Store Retriever (Vector Store Retriever)
  6. OpenAI Chat Model (OpenAI Chat Model)
  7. When chat message received (Chat Trigger)
  8. Schedule Trigger (Schedule Trigger)
  9. Limit (Limit)
  10. Limit1 (Limit)
  11. Delete old embeddings if exist (Supabase)
  12. Get page blocks (Notion)
  13. Default Data Loader (Default Data Loader)
  14. Notion Trigger (Notion Trigger)
  15. Get updated pages (Notion)
  16. Supabase Vector Store1 (Supabase Vector Store)
  17. Supabase Vector Store (Supabase Vector Store)
  18. Concatenate to single string (Summarize)

Credentials you need

  • Notion API – used by Get page blocks, Get updated pages and Notion Trigger
  • OpenAI API – used by Embeddings OpenAI and OpenAI Chat Model
  • Supabase API – used by Delete old embeddings if exist, Supabase Vector Store and Supabase Vector Store1

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us