{
  "name": "RAG with Supabase and OpenAI",
  "nodes": [
    {
      "parameters": {},
      "id": "c3e46ae0-cd78-4cf7-9974-c8c2c67c6615",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        256,
        304
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "sample_text",
        "returnAll": true
      },
      "id": "a409b874-c251-4663-8171-245780769a24",
      "name": "Get Text from Supabase",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        480,
        304
      ],
      "credentials": {
        "supabaseApi": {
          "id": "pB7GUJQvGXDvXL0R",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "embeddings",
          "mode": "list",
          "cachedResultName": "embeddings"
        },
        "options": {}
      },
      "id": "87af8c46-04a8-478f-a1a0-00d085541392",
      "name": "Store Embeddings in Supabase",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        736,
        304
      ],
      "credentials": {
        "supabaseApi": {
          "id": "pB7GUJQvGXDvXL0R",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "66006801-c147-4d5e-a42c-8f3a32ce34d8",
      "name": "OpenAI Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        656,
        528
      ],
      "credentials": {
        "openAiApi": {
          "id": "ajfzTMQlqmNRpqfc",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsonMode": "expressionData",
        "jsonData": "={{ $json.description }}",
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "City",
                "value": "={{ $json.city }}"
              },
              {
                "name": "Id",
                "value": "={{ $json.id }}"
              }
            ]
          }
        }
      },
      "id": "612eb203-d784-4a52-9f97-1cdb6892ee08",
      "name": "Document Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        832,
        528
      ]
    },
    {
      "parameters": {},
      "id": "69c1b810-3114-4320-b76d-2102754b15df",
      "name": "Token Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterTokenSplitter",
      "typeVersion": 1,
      "position": [
        912,
        736
      ]
    },
    {
      "parameters": {
        "public": true,
        "options": {}
      },
      "id": "676f7150-b79c-4d1e-8371-0728942c4f2e",
      "name": "Chat Interface",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        1440,
        288
      ],
      "webhookId": "1bd5f2fd-acbe-433a-9053-4cac5d7aa2b7"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful AI assistant that answers questions based on the information stored in the vector database. ALWAYS Use the vector store tool to search for relevant information to answer user questions."
        }
      },
      "id": "22e1af5f-2afe-40bd-934d-4a6067405690",
      "name": "RAG Chat Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1728,
        288
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "7f07cab8-1b1f-42e2-8299-6587caace2f3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        1664,
        512
      ],
      "credentials": {
        "openAiApi": {
          "id": "ajfzTMQlqmNRpqfc",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolDescription": "Search the knowledge base for information relevant to the user question. Use this tool to find context before answering.",
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "embeddings",
          "cachedResultName": "embeddings"
        },
        "options": {}
      },
      "id": "2b5fbe56-1cf1-4fd0-a4b9-d740791e1aa5",
      "name": "Query Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        1920,
        512
      ],
      "credentials": {
        "supabaseApi": {
          "id": "pB7GUJQvGXDvXL0R",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "355b1598-e66d-468a-90cc-d6191c4131fb",
      "name": "OpenAI Embeddings for Query",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2000,
        720
      ],
      "credentials": {
        "openAiApi": {
          "id": "ajfzTMQlqmNRpqfc",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {},
      "id": "585e69d3-f2f5-49b2-8d18-e905aff98f1b",
      "name": "Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        1792,
        512
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Get Text from Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Text from Supabase": {
      "main": [
        [
          {
            "node": "Store Embeddings in Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Store Embeddings in Supabase",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Document Loader": {
      "ai_document": [
        [
          {
            "node": "Store Embeddings in Supabase",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Token Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Document Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Chat Interface": {
      "main": [
        [
          {
            "node": "RAG Chat Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "RAG Chat Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Query Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "RAG Chat Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings for Query": {
      "ai_embedding": [
        [
          {
            "node": "Query Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "RAG Chat Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "2d14bf36-9a8c-4690-8e84-5a8d52cd281c",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "a19823c907272f8687059b461f3d7dc5c110f9ecbd72c676b4ef2b872c5a0b6a"
  },
  "id": "d84VE1uQ5HfDEb6EYyGQU",
  "tags": []
}