{
  "name": "Document-based RAG chat assistant with Google Drive, Supabase & OpenAI",
  "nodes": [
    {
      "id": "f954e0ec-cb2b-46ca-9eeb-4d759aeb42a1",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -240,
        -256
      ]
    },
    {
      "id": "f90a3e4a-061e-4e16-9ed3-588a065942bd",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -320,
        -16
      ]
    },
    {
      "id": "3539cd74-b7ba-494f-adcf-d31f5681c4e9",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        32,
        -128
      ]
    },
    {
      "id": "d6f00a9e-d191-4c26-b77a-733b36812c35",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        160,
        0
      ]
    },
    {
      "id": "3d23aeec-7ca6-4206-b0b0-e6da0130587f",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        272
      ]
    },
    {
      "id": "cf07ce8a-b2e7-4172-9a12-a06ccfa2ef8b",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        320,
        368
      ]
    },
    {
      "id": "5b34dc6b-d9de-42da-8a2c-151767bc36e3",
      "name": "Supabase Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        1216,
        368
      ]
    },
    {
      "id": "cf86dcb2-82a1-41dd-9043-3d0be136959a",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1152,
        576
      ]
    },
    {
      "id": "837f40b1-c942-4bc6-a52f-6bd064f1625b",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1328,
        576
      ]
    },
    {
      "id": "6a8c893a-2eb3-4f18-9456-d88bcab012c2",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        544,
        368
      ]
    },
    {
      "id": "9bd7615a-b548-44cc-b562-a143d8405aa6",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -544,
        -240
      ]
    },
    {
      "id": "d111c777-4692-4c72-9f1c-0f7c21a9de78",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -672
      ]
    },
    {
      "id": "81227c5e-88da-4867-a264-4105a2fe53d6",
      "name": "Create folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        272,
        -784
      ]
    },
    {
      "id": "c64affd4-a8b0-42d5-90b9-42f4cd7ba128",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        512,
        -688
      ]
    },
    {
      "id": "b11c3b19-9530-40f6-b867-655b4a1460eb",
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        880,
        -688
      ]
    },
    {
      "id": "d774e77e-1222-43a4-a295-4e5a2bbeb363",
      "name": "Update File",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -800,
        272
      ]
    },
    {
      "id": "cd75c7cd-5e72-4da2-a32c-fad1b7176c74",
      "name": "New File",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -128,
        464
      ]
    },
    {
      "id": "ff28339d-2dcd-4307-ba3b-70282c193da3",
      "name": "Delete a row",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -352,
        272
      ]
    },
    {
      "id": "73592614-20c7-4761-9738-0720ff417f3f",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        -128,
        272
      ]
    },
    {
      "id": "66e3701d-6e84-49cd-8e8b-23e892efb773",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -864
      ],
      "parameters": {
        "width": 1408,
        "height": 480,
        "content": "### 4. Save Incoming PDF Files ###"
      }
    },
    {
      "id": "9a48ac99-bd5b-451b-88f4-f761147c5808",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -336
      ],
      "parameters": {
        "width": 1472,
        "height": 464,
        "content": "### 1. RAG Agent with Chat Interface ###"
      }
    },
    {
      "id": "e0104821-7c02-4bc2-ba6c-f40ec382982c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        176
      ],
      "parameters": {
        "width": 2400,
        "height": 544,
        "content": "### 2. Data Pipeline ###\n"
      }
    },
    {
      "id": "2de51cb7-7b18-41d0-91ba-21233c21180d",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -768,
        880
      ]
    },
    {
      "id": "7757ac2d-1758-4339-b2b3-c9ec1757cefb",
      "name": "Search files and folders",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -544,
        880
      ]
    },
    {
      "id": "96263b53-3d53-4220-afb1-ac45ee17e0f4",
      "name": "Get many rows",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -320,
        768
      ]
    },
    {
      "id": "635ae043-99fa-4071-86a4-813831c45177",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        -96,
        864
      ]
    },
    {
      "id": "930056fb-692a-41f6-8af9-19a035105f46",
      "name": "Delete a row1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        176,
        864
      ]
    },
    {
      "id": "c39def47-78ee-478c-9bc2-d4ea488a116f",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        464
      ]
    },
    {
      "id": "54b5e4b4-c7e1-4023-8dc5-ae353925cae6",
      "name": "Edit Fields3",
      "type": "n8n-nodes-base.set",
      "position": [
        992,
        368
      ]
    },
    {
      "id": "7537c93d-a1bd-450f-8128-75565c25a3b8",
      "name": "Edit Fields4",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        272
      ]
    },
    {
      "id": "2caf4053-ae32-4109-b359-ef170f10be83",
      "name": "Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -816,
        -240
      ]
    },
    {
      "id": "41bbbdd3-e06b-4705-bcc6-78de6c5f1f38",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        752
      ],
      "parameters": {
        "width": 1248,
        "height": 304,
        "content": "### 3. Vector Store Cleanup ###"
      }
    },
    {
      "id": "8389e70f-b386-41a2-a58a-1f7b6a6dc5f4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1776,
        -192
      ],
      "parameters": {
        "width": 800,
        "height": 1264,
        "content": "### What is this?\nThis RAG workflow allows you to build a smart chat assistant that can answer user questions based on any collection of documents you provide. It automatically imports and processes f"
      }
    },
    {
      "id": "c4037172-7d28-4469-bcd0-efdc2731b016",
      "name": "Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -144,
        -32
      ]
    },
    {
      "id": "7a590db0-a5a6-402d-b2a0-e71d1e4e3149",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        768,
        272
      ]
    },
    {
      "id": "42202c9f-6c71-446e-9b0b-d8e3568fd2f5",
      "name": "Extract from Binary File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        768,
        464
      ]
    },
    {
      "id": "9f2de02c-842b-4e80-bc82-2855b2a5aae6",
      "name": "Extract From PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -240,
        -672
      ]
    }
  ],
  "connections": {
    "Chat": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Delete a row1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Extract From PDF",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "New File": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Delete a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update File": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete a row": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Create folder",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create folder": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many rows": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract From PDF": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Binary File": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Get many rows",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}