Supabase Insertion & Upsertion & Retrieval n8n Workflow Template

n8n workflow template · 16 nodes · Google Drive

Supabase Insertion & Upsertion & Retrieval is a free n8n workflow template that starts when a chat message is received and works with Google Drive, OpenAI and Supabase. It has 16 nodes, 12 of them AI nodes (Default Data Loader, Question and Answer Chain, OpenAI Chat Model and Vector Store Retriever).

At a glance

Trigger
Chat Trigger (When chat message received)
Nodes
16
Apps
Google Drive, OpenAI and Supabase
AI nodes
12
Credentials
None
Category
RAG, documents and vector search

Apps and integrations

  • Google Drive
  • OpenAI
  • Supabase

Node types used

  • Google Drive
  • Default Data Loader
  • Question and Answer Chain
  • OpenAI Chat Model
  • Vector Store Retriever
  • Recursive Character Text Splitter
  • Edit Fields (Set)
  • Chat Trigger
  • Supabase Vector Store
  • OpenAI Embeddings
  • Supabase

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.

INSERTING

  • it's important to use the same embedding model when for any interaction with your vector database (inserting, upserting and retrieval)

Setup notes

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.

PREPARATION (in Supabase)

  • your database needs the extension 'pgvector' enabled -> select Database > Extension > Search for 'vector'
  • make sure you have a table that has the following columns (if not, use the query below in the Supabase SQL Editor)
  • make sure you have the right policies set -> select Authentication > Policies
  • make sure you have the custom function match_documents set up in Supabase -> This is needed for the Vector Store Node (as query name)

(if not, use the query below in the Supabase SQL Editor to create that function)

  • make sure you check the size of the AI model as it should be the same vector size for the table

(e.g. OpenAI's Text-Embedding-3-Small uses 1536)

DELETION

At the moment n8n does not have a built-in Supabase Node to delete records in a Vector Database. For this you would typically use the HTTP Request node to make an authorized API call to Supabase.

HTTP Request Node

Use this node to send a DELETE request to your Supabase instance.

  • Supabase API Endpoint: Use the appropriate URL for your Supabase project. The endpoint will typically look like this: https://.supabase.co/rest/v1/. Replace and with your details.

HEADERS

  • apikey: [redacted] Supabase API key.
  • Authorization: [redacted] token with your Supabase JWT.
  • Query Parameters: Use query parameters to specify which record(s) to delete. For example,?id=eq. where is the specific record ID you want to delete

(You can also reference back to the Retrieve Rows From Table Node to get the ID dynamically)

Ensure you have the necessary permissions set up in Supabase to delete records through the API.

Please refer to the official n8n documentation for more detailed information on using the HTTP Request Node.

_Note: Deleting records is a sensitive operation, so make sure that your permissions are correctly configured and that you are targeting the correct records to avoid unwanted data loss.

Nodes in this workflow

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

  1. Google Drive (Google Drive)
  2. Default Data Loader (Default Data Loader)
  3. Question and Answer Chain (Question and Answer Chain)
  4. OpenAI Chat Model (OpenAI Chat Model)
  5. Vector Store Retriever (Vector Store Retriever)
  6. Recursive Character Text Splitter1 (Recursive Character Text Splitter)
  7. Customize Response (Edit Fields (Set))
  8. When chat message received (Chat Trigger)
  9. Retrieve by Query (Supabase Vector Store)
  10. Embeddings OpenAI Retrieval (OpenAI Embeddings)
  11. Embeddings OpenAI Insertion (OpenAI Embeddings)
  12. Placeholder (File/Content to Upsert) (Edit Fields (Set))
  13. Embeddings OpenAI Upserting (OpenAI Embeddings)
  14. Insert Documents (Supabase Vector Store)
  15. Retrieve Rows from Table (Supabase)
  16. Update Documents (Supabase Vector Store)

Credentials you need

The workflow JSON lists no credentials. Nodes that call external services may still need credentials after you import it.

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