n8n supabase rag agent

    by Nada Ahmed

    1

    Configure and troubleshoot n8n RAG workflows with Supabase pgvector, Google Gemini, and OpenRouter.

    Free

    Security scanned

    Works with the AI Agents you already use

    n8n supabase rag agent

    Example session with this skill installed

    I'm getting a dimension mismatch error in Supabase when trying to ingest docs using Gemini embeddings. How do I fix the SQL table?

    • Read your context and instructions
    • Compiled the n8n supabase rag

    The error occurs because the Google Gemini embedding model generates 3072-dimensional vectors, but your Supabase documents table is likely still using the default 1536 dimensions.

    Supabase Vector Table Alignment

    To resolve this, you must update the table schema and the matching function to accept 3072-dimensional vectors. Run the following SQL in your Supabase SQL Editor:

    -- 1. Alter the embedding column to match Gemini 3072 dimensions
    ALTER TABLE documents 
    ALTER COLUMN embedding TYPE vector(3072);
    
    -- 2. Drop the existing match function to allow recreation
    DROP FUNCTION IF EXISTS match_documents;
    
    -- 3. Recreate the function with the correct vector dimensions
    CREATE OR REPLACE FUNCTION match_documents (
      query_embedding vector(3072),
      match_threshold float,
      match_count int,
      filter jsonb DEFAULT '{}'
    )
    RETURNS TABLE (
      id bigint,
      content text,
      metadata jsonb,
      similarity float
    )
    LANGUAGE plpgsql
    AS $$
    BEGIN
      RETURN QUERY
      SELECT
        documents.id,
        documents.content,
        documents.metadata,
        1 - (documents.embedding <=> query_embedding) AS similarity
      FROM documents
      WHERE (documents.metadata @> filter)
        AND 1 - (documents.embedding <=> query_embedding) > match_threshold
      ORDER BY similarity DESC
      LIMIT match_count;
    END;
    $$;
    

    Next steps

    1. Clear existing rows: If you had 1536-dimension data, delete it before re-ingesting.
    2. Restart Ingestion: Run the n8n Google Drive ingestion workflow for one file to verify the insert.
    3. Verify Retrieval: Test the Chat workflow to ensure the match_documents call succeeds.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Building a reliable RAG system often fails at the seams: mismatched embedding dimensions, broken ingestion pipelines, or hallucinations when retrieval returns empty results. This skill provides the direct technical guidance needed to configure and maintain a production-ready n8n RAG agent using Supabase and Google Gemini.

    What it does

    • Workflow configuration provides step-by-step setup for n8n ingestion and chat retrieval exports.
    • Database synchronization ensures Supabase documents tables and match_documents functions match embedding dimensions.
    • Ingestion management handles Google Drive triggers, text chunking, and metadata-aware vector inserts.
    • Response grounding optimizes AI Agent system instructions to cite sources and prevent hallucinations.
    • Troubleshooting diagnoses common failures in embedding generation, vector retrieval, and chat memory.

    How it works

    1. Environment audit identifies your n8n version and verifies credentials for Supabase, Gemini, and OpenRouter.
    2. Ingestion setup configures the pipeline from Google Drive through the Recursive Character Text Splitter to Supabase.
    3. Retrieval tuning connects the AI Agent to the vector store tool and configures Postgres Chat Memory context.
    4. Validation runs a multi-step test from single-document ingestion to out-of-scope query handling.

    Frameworks & tools

    This skill is built for n8n workflows utilizing Supabase (pgvector), Google Gemini (embeddings), OpenRouter (LLMs), Google Drive, and PostgreSQL.

    Why this beats prompting it yourself

    Generic prompts often ignore the specific architectural requirements of n8n node inputs or pgvector function signatures. This skill uses the provided project exports as a source of truth to ensure metadata filters and embedding dimensions are technically aligned.

    Use cases

    • Deploy a document Q&A bot that pulls live data from a Google Drive folder.
    • Fix embedding-dimension errors when switching between different Gemini models.
    • Set up automated document updates that clear old vector rows before re-indexing.
    • Implement metadata filtering to isolate chat retrieval to specific files or projects.

    Known limitations

    Does not support file types incompatible with the n8n Extract from File node. Requires manual credential setup within the n8n UI as it cannot handle sensitive API keys.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Frequently Asked Questions

    This skill provides specialized technical guidance and pre-configured workflow logic to bridge n8n, Supabase pgvector, and Google Gemini, solving common issues like embedding dimension mismatches and broken document ingestion pipelines.

    It is designed for n8n environments using Supabase (pgvector), Google Gemini for embeddings, and OpenRouter for LLM orchestration, specifically supporting Google Drive as a primary data source.

    You will receive a comprehensive implementation guide, n8n workflow export templates for ingestion and retrieval, and the specific SQL schema requirements for your Supabase vector store.

    No, due to security best practices, you must manually input your own API keys for Gemini, OpenRouter, and Supabase within your n8n credentials manager after importing the workflows.

    The skill includes specific troubleshooting steps for the Supabase 'match_documents' function to ensure your vector retrieval remains accurate even if you change embedding models or dimensions.

    Yes, the skill provides a framework for metadata-aware indexing, allowing you to filter chat responses based on specific folders, projects, or file types stored in your database.

    New in Workflow Automation

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Workflow Automation.

    Free