AutomationFlowsAI & RAG › Supabase RAG AI Agent with Ollama

Supabase RAG AI Agent with Ollama

Original n8n title: V2 Supabase RAG AI Agent

V2 Supabase RAG AI Agent. Uses memoryPostgresChat, lmChatOllama, lmOllama, toolVectorStore. Chat trigger; 23 nodes.

Chat trigger trigger★★★★☆ complexityAI-powered23 nodesMemory Postgres ChatOllama ChatLm OllamaTool Vector StoreDocument Default Data LoaderText Splitter Recursive Character Text SplitterOllama EmbeddingsChat Trigger
AI & RAG Trigger: Chat trigger Nodes: 23 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "V2 Supabase RAG AI Agent",
  "nodes": [
    {
      "parameters": {},
      "id": "3e70b57d-49fb-4cb0-8f9f-29d39adf6a65",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.1,
      "position": [
        480,
        340
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "qwen2.5:7b-instruct-q4_K_M",
        "options": {}
      },
      "id": "8d61de27-45d8-4d10-97cc-3c36d224f865",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        360,
        340
      ],
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "qwen2.5:7b-instruct-q4_K_M",
        "options": {}
      },
      "id": "cbd5b56f-7afc-4e83-a221-6be4d348374e",
      "name": "Ollama Model",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [
        1400,
        280
      ],
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "name": "documents",
        "topK": 3
      },
      "id": "c15bd0a8-286a-4076-8ce8-8c0e54f73e2a",
      "name": "Vector Store Tool",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1,
      "position": [
        1180,
        100
      ]
    },
    {
      "parameters": {
        "operation": "text",
        "destinationKey": "=data",
        "options": {}
      },
      "id": "ab9fb44a-85c6-486b-b5de-0f9d768d91b2",
      "name": "Extract Document Text",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        920,
        640
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "file_id",
                "value": "={{ $('Local File Trigger').item.json.path }}"
              }
            ]
          }
        }
      },
      "id": "b5abf0a5-f62a-49a6-bf81-bf002ba4bb90",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        1300,
        880
      ]
    },
    {
      "parameters": {
        "chunkSize": 100,
        "options": {}
      },
      "id": "1e2791c1-86e7-4fe1-a76d-732f87e6f41a",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        1300,
        1100
      ]
    },
    {
      "parameters": {
        "model": "nomic-embed-text:latest"
      },
      "id": "909713ea-5be3-4916-b12e-a8e848c949cb",
      "name": "Embeddings Ollama1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOllama",
      "typeVersion": 1,
      "position": [
        1140,
        880
      ],
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Local RAG AI Agent with Chat Interface",
        "height": 527.3027193303974,
        "width": 969.0343804425795
      },
      "id": "de473f2f-b806-45bc-a0e0-2ef0d2aa9b55",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "content": "## Agent Tools for Local RAG",
        "height": 528.85546469693,
        "width": 583.4552380860637,
        "color": 4
      },
      "id": "b23ef570-f642-4503-87b9-3494ffdbf768",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        980,
        0
      ]
    },
    {
      "parameters": {
        "content": "## Workflow to Create Local Knowledgebase",
        "height": 705.2695614889159,
        "width": 1568.9362829025763,
        "color": 5
      },
      "id": "836cd765-dae8-460e-951d-66e19d0cce77",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        540
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "f8b5039c-4b00-453a-b30e-31a59f5d36ad",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        60,
        120
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "2f64907b-42ef-4bd6-83ba-e97584271bc7",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        780,
        120
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "invoke_n8n_agent",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "9a30041f-0c14-41d8-a811-229b890bb1b7",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        60,
        300
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "8311e22f-bddd-41f8-9d40-fde119126dc9",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        440,
        120
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "75ebfdef-c8e2-4c3e-b716-1479d0cc2a73",
              "name": "chatInput",
              "value": "={{ $json?.chatInput || $json.body.chatInput }}",
              "type": "string"
            },
            {
              "id": "59b7a20f-0626-4861-93e2-015d430c266e",
              "name": "sessionId",
              "value": "={{ $json?.sessionId || $json.body.sessionId}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "4988a14f-a2ea-4c4b-8f66-0f1773e11ea0",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        120
      ]
    },
    {
      "parameters": {
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "options": {
          "queryName": "match_documents"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1,
      "position": [
        1000,
        240
      ],
      "id": "9841944a-5a85-437d-a9ed-a3e7393d7a8d",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "nomic-embed-text:latest"
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOllama",
      "typeVersion": 1,
      "position": [
        1180,
        380
      ],
      "id": "24e6e703-33c2-426d-ab59-7c9cad0fded9",
      "name": "Embeddings Ollama2",
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "options": {
          "queryName": "match_documents"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1,
      "position": [
        1180,
        640
      ],
      "id": "d72c6f38-7766-4a10-9897-362539a6bcc0",
      "name": "Supabase Vector Store1",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "delete",
        "tableId": "documents",
        "filterType": "string",
        "filterString": "=metadata->>file_id=like.*{{ $json.path }}*"
      },
      "id": "ab0e0395-9f88-438f-bc47-ea3913b869fe",
      "name": "Delete Old Doc Rows",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        460,
        840
      ],
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "triggerOn": "folder",
        "path": "/data/shared",
        "events": [
          "add",
          "change"
        ],
        "options": {
          "followSymlinks": true,
          "usePolling": true
        }
      },
      "type": "n8n-nodes-base.localFileTrigger",
      "typeVersion": 1,
      "position": [
        60,
        840
      ],
      "id": "eba68fe1-738d-451b-a2a7-9ee2942dd727",
      "name": "Local File Trigger"
    },
    {
      "parameters": {
        "fileSelector": "={{ $('Local File Trigger').item.json.path }}",
        "options": {
          "dataPropertyName": "=data"
        }
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        640,
        640
      ],
      "id": "b9459d4d-836c-47c4-9651-ebf3129f8864",
      "name": "Read/Write Files from Disk",
      "executeOnce": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e051736f-949a-4230-bf32-c9ade2674b12",
              "leftValue": "={{ $json.event }}",
              "rightValue": "add",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        280,
        660
      ],
      "id": "27123d6a-e27a-49a9-bd73-8a27235928ea",
      "name": "If"
    }
  ],
  "connections": {
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Vector Store Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Document Text": {
      "main": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Ollama1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vector Store Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Vector Store Tool",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Ollama2": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Doc Rows": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Local File Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk": {
      "main": [
        [
          {
            "node": "Extract Document Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Delete Old Doc Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ea9ff68c-8fc0-40b0-aa5d-48217cda89f3",
  "id": "hrnPh6dXgIbGVzIk",
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

V2 Supabase RAG AI Agent. Uses memoryPostgresChat, lmChatOllama, lmOllama, toolVectorStore. Chat trigger; 23 nodes.

Source: https://github.com/161sam/Workspace-in-a-Box/blob/main/n8n/backup/workflows/V2_Local_Supabase_RAG_AI_Agent.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

• Create a Google Drive folder to watch. • Connect your Google Drive account in n8n and authorize access. • Point the Google Drive Trigger node to this folder (new/modified files trigger the flow).

Agent, Chat Trigger, Memory Buffer Window +14
AI & RAG

The workflow operates through a three-step process that handles incoming chat messages with intelligent tool orchestration: Message Trigger: The node triggers whenever a user message arrives and passe

Chat Trigger, Memory Postgres Chat, OpenAI Embeddings +16
AI & RAG

An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free-tier tools like Gemini, Gemma and Supabase.

Document Default Data Loader, Text Splitter Recursive Character Text Splitter, Supabase +9
AI & RAG

RAG Agent Integration Hub mit Knowledge Management. Uses memoryPostgresChat, lmChatOllama, lmOllama, toolVectorStore. Chat trigger; 27 nodes.

Memory Postgres Chat, Ollama Chat, Lm Ollama +8
AI & RAG

This workflow provides comprehensive AI-driven stock analysis, generating detailed deep reports by leveraging advanced vector-based data retrieval and API integrations for precise financial analytics

Tool Think, Supabase Vector Store, OpenAI Embeddings +9