{
  "name": "Interactive knowledge base chat with Supabase RAG using AI 📚💬",
  "nodes": [
    {
      "id": "eff80cb0-26e5-4a19-a4d6-671a11fe26b6",
      "name": "File Created",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -80,
        880
      ]
    },
    {
      "id": "a78ad8a2-93a9-4c71-8916-e6247d408d82",
      "name": "Update to File",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -80,
        680
      ]
    },
    {
      "id": "f8a528ba-9638-4a32-a2e2-596c4a63da0c",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        140,
        780
      ]
    },
    {
      "id": "bf8e763f-fff5-4fa4-a0ec-4b13bdeb498d",
      "name": "Set File ID",
      "type": "n8n-nodes-base.set",
      "position": [
        360,
        640
      ]
    },
    {
      "id": "47bc2891-8f9f-416d-b2ce-8fd656796348",
      "name": "Check for Duplicates",
      "type": "n8n-nodes-base.postgres",
      "position": [
        800,
        540
      ]
    },
    {
      "id": "71dd64ed-9c40-4ef0-bf24-5243b2cff499",
      "name": "Insert Metadata",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1900,
        740
      ]
    },
    {
      "id": "6a66a187-30c1-46b0-830f-484add803b1d",
      "name": "Extract from File PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        180
      ]
    },
    {
      "id": "ebc02b0a-0481-42e8-8043-e9bcd6c0f02e",
      "name": "Extract from CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2560,
        580
      ]
    },
    {
      "id": "8bb13f35-03c3-413a-9dcc-1526f40325d3",
      "name": "Extract from XLSX",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2560,
        980
      ]
    },
    {
      "id": "a598e49c-d9bc-4305-b917-ccc64feb4c68",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2780,
        740
      ]
    },
    {
      "id": "e1c0c059-66f5-4a1b-b76a-8db1823c25e1",
      "name": "Summarize",
      "type": "n8n-nodes-base.summarize",
      "position": [
        3000,
        740
      ]
    },
    {
      "id": "cb46dfca-96ce-478a-98cb-5c94fd48e104",
      "name": "Extract from RTF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        1160
      ]
    },
    {
      "id": "9832240d-7cea-465e-b167-17fcf254f5f7",
      "name": "Error Logger",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1240,
        1380
      ]
    },
    {
      "id": "01b5f966-e5b7-436e-9551-c31f6b9d4eac",
      "name": "Validate File",
      "type": "n8n-nodes-base.if",
      "position": [
        580,
        640
      ]
    },
    {
      "id": "466e1cc8-25e7-462c-b19f-467c66eb1d77",
      "name": "IF Duplicate Check",
      "type": "n8n-nodes-base.if",
      "position": [
        1020,
        540
      ]
    },
    {
      "id": "0dd9891e-7dd3-4f2d-8a2e-094ab3cecec6",
      "name": "Log Duplicate",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1240,
        440
      ]
    },
    {
      "id": "7d05de17-7909-4da3-bba3-c7f512af1708",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        3240,
        440
      ]
    },
    {
      "id": "a764be2e-110f-4320-8bae-f04a749a3ac5",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3220,
        660
      ]
    },
    {
      "id": "0ef91d4c-7d6b-4544-9ef5-09a0bdb6dd7c",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        3340,
        660
      ]
    },
    {
      "id": "86c648a9-4b9d-4afb-9e2e-f4fff12a1ce0",
      "name": "Debug File ID",
      "type": "n8n-nodes-base.set",
      "position": [
        1240,
        740
      ]
    },
    {
      "id": "392916f3-2265-4c57-abfd-37054da9e741",
      "name": "Download File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2120,
        740
      ]
    },
    {
      "id": "a7367c0f-6f22-4099-ac6c-8511081b79f6",
      "name": "Set Schema",
      "type": "n8n-nodes-base.set",
      "position": [
        3360,
        1160
      ]
    },
    {
      "id": "7051505f-4da8-44c0-90c4-c522d3a2f6d3",
      "name": "Schema Document Metadata",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3600,
        1160
      ]
    },
    {
      "id": "6f76fa9d-d1f9-4e05-80af-ec78fed5416c",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2340,
        680
      ]
    },
    {
      "id": "f62efcf8-bb87-4e4e-9c73-0c86ec1c55fd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -60
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "82015f8b-1456-4b04-bf38-2735e7f416f6",
      "name": "Extract from DOC",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        1360
      ]
    },
    {
      "id": "7af0771c-bed1-4cbb-8122-01ec2d8b4664",
      "name": "Slack Duplicate Notification",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1460,
        440
      ]
    },
    {
      "id": "a5ef8a35-ea86-466a-bb6b-2f3ef72acab7",
      "name": "Error Notification",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1460,
        1400
      ]
    },
    {
      "id": "6ca4d2d7-536c-4229-ac19-39dcb0853c4c",
      "name": "Delete old Doc",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1460,
        740
      ]
    },
    {
      "id": "98d0c000-5d9b-419b-aa7c-e98a9f0a90e2",
      "name": "Extract from TXT",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        380
      ]
    },
    {
      "id": "a53ca5ed-b9f0-4f9e-bb55-017dc5ed1451",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        -40
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "a1c76c00-0bed-48f0-ad8c-f686d5186222",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1620,
        -40
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "71f8678a-ef8b-40ef-a3ef-3ee90afe65dc",
      "name": "RAG AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -880,
        700
      ]
    },
    {
      "id": "7c7ebb71-1699-46a5-a756-cf2589815dc8",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1460,
        1180
      ]
    },
    {
      "id": "510482ba-030b-4777-9740-bf8993dce021",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -1280,
        1180
      ]
    },
    {
      "id": "223791e6-5148-47cd-aab6-ca9cb20b7017",
      "name": "List Documents",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -1060,
        1180
      ]
    },
    {
      "id": "25cc4ca1-4910-4ae7-a755-c5611946c325",
      "name": "Query Document Rows",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -620,
        1180
      ]
    },
    {
      "id": "194c1ee8-1c21-4a1d-b8d2-9991dc8133fd",
      "name": "Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        3440,
        860
      ]
    },
    {
      "id": "f311ab63-88fa-413a-8ba9-aa866e1fb5f0",
      "name": "Insert Table Rows",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2780,
        940
      ]
    },
    {
      "id": "529e05ca-0494-4eb3-b0f4-275ba252f646",
      "name": "Delete Old Data Rows",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1680,
        740
      ]
    },
    {
      "id": "d1702791-fe65-4068-982b-8b378f9c2e0a",
      "name": "Set Error Type",
      "type": "n8n-nodes-base.set",
      "position": [
        1020,
        1200
      ]
    },
    {
      "id": "23a05be3-2b40-400b-b8d4-21ee6db78ac4",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1440,
        720
      ]
    },
    {
      "id": "89262c14-2910-4a9d-b86a-84c015e0daa5",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        -1180,
        700
      ]
    },
    {
      "id": "2325e26f-6237-4128-bead-17e0a9ccb50d",
      "name": "Supabase Vector Store2",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        -460,
        840
      ]
    },
    {
      "id": "1289b037-7bc9-4d13-9516-328f1f781c14",
      "name": "Embeddings OpenAI2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -240,
        1060
      ]
    },
    {
      "id": "3d15f7db-e7b7-4bb7-a5f7-9962f3a81051",
      "name": "Get Full Document Text - Get File Contents",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -820,
        1180
      ]
    }
  ],
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Extract from File PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from TXT",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from CSV",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from XLSX",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from RTF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from DOC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Schema": {
      "main": [
        [
          {
            "node": "Schema Document Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set File ID": {
      "main": [
        [
          {
            "node": "Validate File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "RAG AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Logger": {
      "main": [
        [
          {
            "node": "Error Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Created": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debug File ID": {
      "main": [
        [
          {
            "node": "Delete old Doc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Duplicate": {
      "main": [
        [
          {
            "node": "Slack Duplicate Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate File": {
      "main": [
        [
          {
            "node": "Check for Duplicates",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Error Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete old Doc": {
      "main": [
        [
          {
            "node": "Delete Old Data Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Documents": {
      "ai_tool": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Set Error Type": {
      "main": [
        [
          {
            "node": "Error Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update to File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Metadata": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Set File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from CSV": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from DOC": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from RTF": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from TXT": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XLSX": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store2",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "IF Duplicate Check": {
      "main": [
        [
          {
            "node": "Log Duplicate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Debug File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Query Document Rows": {
      "ai_tool": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Check for Duplicates": {
      "main": [
        [
          {
            "node": "IF Duplicate Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Data Rows": {
      "main": [
        [
          {
            "node": "Insert Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File PDF": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store2": {
      "ai_tool": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Full Document Text - Get File Contents": {
      "ai_tool": [
        [
          {
            "node": "RAG AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}