AI Agent Backend Infrastructure with Supabase RAG and Data Tools - n8n Workflow

Deploy a robust AI agent backend using this advanced n8n workflow. Integrates Supabase for vector storage, RAG capabilities, and full CRUD operations (messages, tasks, status, knowledge). Essential for custom n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers building sophisticated, stateful AI assistants.
Automation specialists looking for powerful n8n templates for agent tooling.
Users leveraging Supabase as a primary database and vector store for knowledge retrieval (RAG).
Engineers needing a detailed example of how to combine custom n8n node triggers with LangChain tools.

Overview

Building complex AI agents requires more than just calling an LLM; it demands robust mechanisms for memory, knowledge retrieval, and state management. This comprehensive n8n workflow provides the essential backend infrastructure by turning Supabase into a complete toolset for the agent. The core value of this specific n8n workflow is its dual functionality: it acts as a Retrieval Augmented Generation (RAG) system using vector similarity search, and simultaneously provides dedicated CRUD endpoints for managing the agent's internal state (messages, tasks, status). This setup ensures that the AI agent can recall previous interactions (ITERACOES tool) and maintain multi-tenant data integrity across various operational tables. Utilizing the native capabilities of the n8n node ecosystem dramatically simplifies deployment compared to traditional code-heavy solutions, making this one of the most powerful n8n templates available for AI development.

How it Works

The entire flow is activated by a specialized MCPSUPABASE n8n trigger, which functions as the gateway for the AI agent framework. This initial n8n trigger exposes dozens of distinct functionalities as callable AI tools.


  1. Agent Activation: The custom MCPSUPABASE n8n trigger starts the process, receiving instructions from the orchestrating LLM (LangChain).

  2. Knowledge Retrieval (RAG): When the agent needs contextual information or historical data, it calls the RAG tool. This tool, an n8n node specialized for Supabase vector stores, uses the Embeddings OpenAI n8n node (configured with text-embedding-ada-002) to vectorize the query. It then retrieves the top 5 relevant documents from the Supabase documents table to provide context (the ITERACOES tool).

  3. State Management (CRUD): The workflow includes four distinct sets of Supabase n8n node tools, corresponding to agent messages, tasks, status, and knowledge. For instance, if the agent needs to log a user interaction, the LLM calls the CREATEROWAGENTMESSAGE tool, which utilizes the specialized Supabase n8n node to perform the insertion operation. Similarly, if it needs to check pending tasks, it calls GETROWAGENTTASKS via the appropriate n8n node, ensuring efficient data access across the entire n8n workflow structure.

Installation Guide

To deploy this comprehensive n8n workflow and start using these advanced n8n templates, follow these steps:


  1. Import Workflow: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Supabase Credentials: You must configure the Supabase account credential. This requires your Supabase URL and API Key (Anon Key or Service Role Key, depending on permissions needed for CRUD operations).

  3. OpenAI Credentials: Configure the OpenAi account credential. This is essential for the Embeddings OpenAI n8n node, which powers the RAG vector search functionality.

  4. Database Setup: Ensure your Supabase instance has the necessary tables defined: agentmessages, agenttasks, agentstatus, and agentknowledge. Crucially, the RAG component requires a table named documents configured for vector storage.

  5. Activation: The MCP_SUPABASE n8n trigger is initially disabled (active: false). Once credentials are set, activate the n8n workflow to enable the AI tools.

Node Details

This n8n workflow leverages numerous specialized n8n nodes to achieve its powerful capabilities:

MCPSUPABASE (LangChain mcpTrigger n8n trigger):
Function: Serves as the primary entry point and exposes the entire n8n workflow as a suite of callable AI tools.
Key Configuration: Configured with a specific webhook ID to manage external communication.

RAG (LangChain vectorStoreSupabase n8n node):
Function: Handles Retrieval Augmented Generation (RAG). It queries the Supabase vector store (documents table) to retrieve contextual information.
Key Configuration: Mode set to retrieve-as-tool, using topK: 5 to retrieve the five most relevant documents. Named ITERACOES for tool identification.

Embeddings OpenAI (LangChain embeddingsOpenAi n8n node):
Function: Converts text queries into vector embeddings for similarity search within the RAG tool.
Key Configuration: Uses the text-embedding-ada-002 model.

Supabase Tool Nodes (Multiple, e.g., CREATEROWAGENTMESSAGE, GETROWAGENTTASKS):
Function: A comprehensive collection of standard Supabase n8n node instances providing full CRUD functionality (Create, Get, Update, Delete) for four critical agent tables (agentmessages, agenttasks, agentstatus, agent_knowledge).
Key Configuration: Each n8n node is configured for a specific operation and table, providing atomic data management functions for the AI agent.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

🇧🇷 Argentino de 30 anos e fundador da KORE Soluções em Belo Horizonte (MG). Há 1 ano, fornecemos automações, cursos, configurações e manutenção de workflows, ajudando empresas a aumentar eficiência e escalar processos com tecnologia. 🇺🇸 I’m a 30‑year‑old Argentine founder of KORE Soluções in Belo Horizonte (MG). For 1 year, we’ve delivered automations, courses, configuration, and workflow maintenance, helping businesses boost efficiency and scale processes with technology.

Featured*