AI Agent: Notion to Supabase Vector Document Creator with OpenAI
Integrates with:
Overview
Unlock Automated Knowledge Base Creation with this AI Agent
This AI Agent automatically transforms new Notion pages into vector documents using OpenAI embeddings and stores them in Supabase, creating a readily searchable and AI-enhanced knowledge base. It's designed for founders, CTOs, and automation leads looking to leverage their existing Notion content for advanced AI applications like RAG (Retrieval Augmented Generation), semantic search, or AI-powered Q&A systems.
How This AI Agent Works
This AI Agent automates the ingestion of Notion content into a Supabase vector database, leveraging OpenAI for embedding generation. Here’s the step-by-step process:
- Watches for New Notion Pages: The workflow starts with the 'Notion - Page Added Trigger', which activates whenever a new page is added to your target Notion database.
- Retrieves Page Details: 'Notion - Retrieve Page Content' then fetches the full content (all blocks) of this new page.
- Filters for Text: 'Filter Non-Text Content' processes these blocks, removing images and videos to isolate the textual information.
- Aggregates Textual Content: The 'Summarize - Concatenate Notion's blocks content' node takes all the filtered text blocks and combines them into a single text string.
- Creates Searchable Documents: This text string, along with metadata like the Notion Page ID, title, and creation date, is then formatted into Langchain-compatible documents by the 'Create metadata and load content' node.
- Stores with AI-Generated Embeddings: The 'Supabase Vector Store' node takes these documents. It uses the 'Embeddings OpenAI' node (which you configure with your OpenAI API key) to generate vector embeddings for the document content. Both the documents and their embeddings are then saved into your specified Supabase table, making your Notion content searchable and AI-ready.
Note: This workflow includes a 'Token Splitter' node, which is configured but not actively connected in the main data path. You can integrate it between the 'Create metadata and load content' and 'Supabase Vector Store' nodes if you need to split large documents into smaller chunks before embedding and storage. This can improve search relevance for certain use cases and is a recommended step for production RAG systems.
Key Features & Benefits
- Automated Sync: Automatically processes new Notion pages, keeping your Supabase vector store up-to-date without manual intervention.
- AI-Powered Embeddings: Leverages OpenAI's state-of-the-art models to create rich semantic embeddings for your content.
- Intelligent Content Filtering: Focuses on textual content by automatically excluding images and videos.
- Metadata Preservation: Captures essential metadata from Notion (page ID, title, creation time) for better context and filtering in Supabase.
- Ready for RAG: Creates the foundational vector data needed for building advanced Retrieval Augmented Generation applications.
- Scalable Knowledge Base: Easily build and maintain a large, searchable knowledge repository from your Notion workspace.
- Customizable Chunking (Optional): Includes a 'Token Splitter' node for optional document chunking to optimize for specific embedding models or retrieval strategies.
Use Cases
- B2C E-commerce: Automatically build a vector database from product descriptions or FAQs in Notion to power an AI-driven product recommendation engine or an intelligent customer support chatbot.
- B2B SaaS: Convert internal documentation, knowledge base articles, or meeting notes from Notion into a searchable Supabase vector store, enabling faster information retrieval for support teams or powering in-app AI assistants.
- Content Creators: Transform blog posts, research notes, or script outlines from Notion into a vector database for semantic search, content repurposing, or feeding into AI writing assistants.
- Solopreneurs/Founders: Create a personal or company-wide knowledge hub by automatically indexing important documents from Notion for easy AI-powered querying and RAG implementation.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- Notion account and API credentials (ensure the integration has access to the target database).
- Supabase project with a database and the pgvector extension enabled.
- A Supabase table specifically configured for vector storage (e.g., with a
vector
type column). Refer to Supabase documentation for creating vector columns. - OpenAI API Key with access to an embeddings model (e.g.,
text-embedding-ada-002
or newer).
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure Credentials: Create or select existing credentials for Notion, OpenAI, and Supabase within n8n.
- Notion Trigger: Open the 'Notion - Page Added Trigger' node. Select your Notion credential and specify the Database ID you want to monitor.
- OpenAI Embeddings: Open the 'Embeddings OpenAI' node. Select your OpenAI credential. You can also adjust the model if needed (default is usually fine for embeddings).
- Supabase Vector Store: Open the 'Supabase Vector Store' node. Select your Supabase credential. Enter the exact 'Table Name' and 'Content Column Name' (for original text) and 'Embedding Column Name' (for vectors) that you've set up in your Supabase database.
- Metadata Configuration: Review the 'Create metadata and load content' node. It's pre-configured to extract
pageId
,createdTime
, andpageTitle
. You can customize this if you have other metadata you wish to include from the Notion page trigger data. - (Optional) Enable Text Chunking: To split large documents:
a. Disconnect the existing connection from the 'Create metadata and load content' node to the 'Supabase Vector Store' node (remove the wire going to the
Documents (ai_document)
input). b. Connect theDocuments (ai_document)
output of 'Create metadata and load content' to theDocument (ai_document)
input of the 'Token Splitter' node. c. Connect theDocument (ai_document)
output of 'Token Splitter' to theDocuments (ai_document)
input of 'Supabase Vector Store'. d. AdjustChunk Size
andChunk Overlap
parameters in the 'Token Splitter' node as needed for your content and embedding model. - Activate the workflow. New pages added to the specified Notion database will now be automatically processed and stored in Supabase.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation