{
  "name": "Index Google Drive files into a Supabase vector store with OpenAI embeddings",
  "nodes": [
    {
      "id": "eb4ca5ac-5ec2-447e-b903-df92db68346d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        1536
      ],
      "parameters": {
        "width": 480,
        "height": 976,
        "content": "## RAG\n\n### How it works\n\n1. A one-time setup flow (triggered by a chat message) creates the required Postgres/Supabase database tables and match function.\n2. Google Drive triggers fire whenever a fil"
      }
    },
    {
      "id": "d8cc6d5f-f050-4381-826e-b22bca043be5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3216,
        1536
      ],
      "parameters": {
        "width": 816,
        "height": 320,
        "content": "## One-time database setup\n\nTriggered by a chat message, this cluster runs SQL queries to create the documents vector table, match function, document metadata table, and tabular data rows table in Pos"
      }
    },
    {
      "id": "8caf1911-051e-4d32-892c-012b891cc885",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3216,
        1952
      ],
      "parameters": {
        "width": null,
        "height": 560,
        "content": "## Google Drive file triggers\n\nTwo Google Drive triggers detect newly created or updated files and feed them into the batch loop for processing."
      }
    },
    {
      "id": "323c81bc-09d9-4a2e-9c10-bd54f34f6063",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3552,
        2016
      ],
      "parameters": {
        "width": null,
        "height": 400,
        "content": "## Batch loop entry point\n\nSplits the list of detected files into individual items so each file is processed sequentially. Also receives the completion signal from the vector store to advance to the n"
      }
    },
    {
      "id": "a95966ea-5bf9-4859-8059-df91f17d12cb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3824,
        2080
      ],
      "parameters": {
        "width": 544,
        "height": 496,
        "content": "## Set file identity and clean old data\n\nSets key file metadata fields (ID, type, title, URL), then deletes the file's existing document rows and vector data rows from Supabase so stale content is rem"
      }
    },
    {
      "id": "438dcd38-b6ed-415d-8821-e5c11c1a8962",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4400,
        2112
      ],
      "parameters": {
        "width": 496,
        "height": 320,
        "content": "## Upsert metadata and download file\n\nUpserts the document metadata record into Postgres, then downloads the actual file binary from Google Drive ready for text extraction."
      }
    },
    {
      "id": "6139a026-2aad-46d8-978f-cf4fabc2077e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4928,
        2032
      ],
      "parameters": {
        "width": null,
        "height": 432,
        "content": "## Route file by type\n\nInspects the file type and routes it to the correct extraction branch: PDF, Office document, Excel spreadsheet, or CSV."
      }
    },
    {
      "id": "428555eb-5882-45c5-9eb6-c279d4a32791",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5216,
        1744
      ],
      "parameters": {
        "width": null,
        "height": 880,
        "content": "## Extract text from PDF and documents\n\nExtracts plain text from PDF files and from generic office/word documents, producing text ready for direct vectorisation."
      }
    },
    {
      "id": "de9e0754-f10f-4c16-8e73-1c7730c068cb",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5488,
        2016
      ],
      "parameters": {
        "width": 832,
        "height": 544,
        "content": "## Extract and store tabular data\n\nExtracts rows from Excel and CSV files, inserts raw row data into a Postgres table, then aggregates all rows and summarises them for downstream vectorisation."
      }
    },
    {
      "id": "7a567ab6-749b-4ea8-ac85-02704a434353",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6832,
        1888
      ],
      "parameters": {
        "width": 544,
        "height": 720,
        "content": "## Embed and store in vector store\n\nUses OpenAI embeddings and a character text splitter to chunk and embed extracted text, then inserts the resulting vectors into the Supabase vector store. Sub-nodes"
      }
    },
    {
      "id": "9075b294-9e8b-488b-b062-31e732635572",
      "name": "Load Document Data",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        7120,
        2320
      ]
    },
    {
      "id": "18713d69-3d8a-4cb3-99ee-59b1b1cd862b",
      "name": "OpenAI Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        6880,
        2320
      ]
    },
    {
      "id": "4be45908-ebd7-4c7f-b660-580144afe62f",
      "name": "Download File from Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        4752,
        2272
      ]
    },
    {
      "id": "1f84d55b-6b29-4583-b191-be4e46390091",
      "name": "When Drive File Created",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        3264,
        2192
      ]
    },
    {
      "id": "cde9ebef-1b74-4264-b87f-167d437a2e49",
      "name": "When Drive File Updated",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        3264,
        2352
      ]
    },
    {
      "id": "f1acf69a-aa94-4ad9-b86b-2df94d658071",
      "name": "Extract Text from Document",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5264,
        2464
      ]
    },
    {
      "id": "23e8180a-f0c1-4bd2-ab1e-b3e065d356e8",
      "name": "Delete Old Doc Rows in Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        4064,
        2256
      ]
    },
    {
      "id": "58a8e3b9-0c0c-4576-8d70-273e00c2adc6",
      "name": "Set File Metadata Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        3872,
        2416
      ]
    },
    {
      "id": "af85c4ec-8d0e-497b-b984-abcbf1f2f52d",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5264,
        1984
      ]
    },
    {
      "id": "3e01040c-982e-4086-aee6-09d197944817",
      "name": "Aggregate Tabular Data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        5968,
        2160
      ]
    },
    {
      "id": "41c8cc7f-b4b0-4486-9e84-06c446ed2438",
      "name": "Split Text into Chunks",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        7024,
        2432
      ]
    },
    {
      "id": "26195379-8c3d-4374-ac3c-f52dccd858b6",
      "name": "Summarize Tabular Data",
      "type": "n8n-nodes-base.summarize",
      "position": [
        6176,
        2160
      ]
    },
    {
      "id": "b653c385-9f0e-4788-8256-5fa151959286",
      "name": "Route by File Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        4976,
        2240
      ]
    },
    {
      "id": "5cb57260-3097-4ea5-a1ef-b85da261147c",
      "name": "Insert Embeddings to Vectorstore",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        7040,
        2096
      ]
    },
    {
      "id": "b1cff829-93fa-4ae9-81ec-3bbc837255c2",
      "name": "Extract Data from Excel",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5536,
        2144
      ]
    },
    {
      "id": "ac206afa-d0b6-4a92-9b24-d98f775ed203",
      "name": "Build Schema and Data",
      "type": "n8n-nodes-base.set",
      "position": [
        6400,
        2144
      ]
    },
    {
      "id": "1cde953c-8543-4c50-8d13-eb79040a5375",
      "name": "Extract Data from CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5536,
        2304
      ]
    },
    {
      "id": "65e1b876-308f-4302-bcfd-28491095a5a1",
      "name": "Loop Over Drive Files",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        3600,
        2256
      ]
    },
    {
      "id": "2c1f573d-8e64-4528-b550-b67bb7d6795d",
      "name": "Delete Old Data Rows in Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        4224,
        2416
      ]
    },
    {
      "id": "a056a860-6824-44f8-9b40-71ff9265880f",
      "name": "Insert Document Metadata to DB",
      "type": "n8n-nodes-base.postgres",
      "position": [
        4448,
        2272
      ]
    },
    {
      "id": "3da25fe9-637b-4ca4-a337-8e498543af98",
      "name": "Insert Table Rows to DB",
      "type": "n8n-nodes-base.postgres",
      "position": [
        6016,
        2384
      ]
    },
    {
      "id": "809b6222-4b26-4f65-af47-844804024f94",
      "name": "Update Document Schema in DB",
      "type": "n8n-nodes-base.postgres",
      "position": [
        6640,
        2144
      ]
    },
    {
      "id": "0ec9c71b-e944-47b7-a081-c060c86b5f3f",
      "name": "Create Document Metadata Table",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3696,
        1696
      ]
    },
    {
      "id": "d958dd8f-1bf4-4e8b-834c-221bea7d7739",
      "name": "Create Document Rows Table",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3888,
        1696
      ]
    },
    {
      "id": "9b05e1cc-cb66-4c17-a048-e8cbfb47ea4d",
      "name": "Create Docs Table and Match Fn",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3472,
        1696
      ]
    },
    {
      "id": "bba201fe-1734-40ee-9fc0-05e2b8033b99",
      "name": "When Chat Message Received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        3264,
        1696
      ]
    },
    {
      "id": "dce2f1ce-984d-464c-a946-48cac48cd236",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6352,
        1984
      ],
      "parameters": {
        "width": 432,
        "height": 320,
        "content": "## Update tabular schema metadata\n\nAfter summarisation, sets the schema and data fields and upserts the inferred column schema back into the document metadata table in Postgres."
      }
    },
    {
      "id": "a0e1b511-1632-42ea-8129-26863852466d",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4560,
        1200
      ],
      "parameters": {
        "width": 816,
        "height": 336,
        "content": "## Need more advanced automation solutions? Contact us for custom enterprise workflows!\n\n# Growth-AI.fr\n\n## https://www.linkedin.com/in/allanvaccarizi/\n## https://www.linkedin.com/in/hugo-marinier-%F0"
      }
    },
    {
      "id": "5704ead4-1f7d-47df-b8f9-c5e1128ca0fd",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5408,
        1168
      ],
      "parameters": {
        "width": 1024,
        "height": 400,
        "content": "![Logo Growth AI](https://cdn.prod.website-files.com/6825df5b20329ba581df4914/68d413c43f8729fa336568a6_Logo_horizontal.png)"
      }
    }
  ],
  "connections": {
    "OpenAI Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Insert Embeddings to Vectorstore",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Load Document Data": {
      "ai_document": [
        [
          {
            "node": "Insert Embeddings to Vectorstore",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Route by File Type": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Data from Excel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Data from CSV",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Text from Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Schema and Data": {
      "main": [
        [
          {
            "node": "Update Document Schema in DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Data from CSV": {
      "main": [
        [
          {
            "node": "Aggregate Tabular Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Insert Embeddings to Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Drive Files": {
      "main": [
        [],
        [
          {
            "node": "Set File Metadata Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Tabular Data": {
      "main": [
        [
          {
            "node": "Summarize Tabular Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Text into Chunks": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Document Data",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Tabular Data": {
      "main": [
        [
          {
            "node": "Build Schema and Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Embeddings to Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Data from Excel": {
      "main": [
        [
          {
            "node": "Aggregate Tabular Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Drive File Created": {
      "main": [
        [
          {
            "node": "Loop Over Drive Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Drive File Updated": {
      "main": [
        [
          {
            "node": "Loop Over Drive Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File from Drive": {
      "main": [
        [
          {
            "node": "Route by File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set File Metadata Fields": {
      "main": [
        [
          {
            "node": "Delete Old Doc Rows in Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from Document": {
      "main": [
        [
          {
            "node": "Insert Embeddings to Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Chat Message Received": {
      "main": [
        [
          {
            "node": "Create Docs Table and Match Fn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Docs Table and Match Fn": {
      "main": [
        [
          {
            "node": "Create Document Metadata Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Document Metadata Table": {
      "main": [
        [
          {
            "node": "Create Document Rows Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Document Metadata to DB": {
      "main": [
        [
          {
            "node": "Download File from Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Doc Rows in Supabase": {
      "main": [
        [
          {
            "node": "Delete Old Data Rows in Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Data Rows in Supabase": {
      "main": [
        [
          {
            "node": "Insert Document Metadata to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Embeddings to Vectorstore": {
      "main": [
        [
          {
            "node": "Loop Over Drive Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}