Construcción de un pipeline de procesamiento de documentos RAG de múltiples clientes para agentes con la base de datos vectorial de Supabase

Avanzado

Este es unContent Creation, Multimodal AIflujo de automatización del dominio deautomatización que contiene 38 nodos.Utiliza principalmente nodos como Set, Switch, Postgres, Supabase, Aggregate. Construir un pipeline de procesamiento de documentos RAG multiagente usando la base de datos vectorial Supabase

Requisitos previos
  • Información de conexión de la base de datos PostgreSQL
  • URL y Clave de API de Supabase
  • Credenciales de API de Google Drive
  • Clave de API de OpenAI
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "393ca9e36a1f81b0f643c72792946a5fe5e49eb4864181ba4032e5a408278263",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "8dcb88e1-3482-41a1-9637-b216806a2613",
      "name": "Cargador de datos predeterminado",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        2368,
        736
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "=file_id",
                "value": "={{ $('Set File ID').first().json.file_id }}"
              },
              {
                "name": "file_title",
                "value": "={{ $('Set File ID').first().json.file_title }}"
              }
            ]
          }
        },
        "jsonData": "={{ $json.data || $json.text || $json.concatenated_data }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "e54ed2cc-2648-4e86-8f10-1ae805e09b97",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        2128,
        736
      ],
      "parameters": {
        "model": "text-embedding-3-small",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Wk5dyBYFy6HDwml2",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a3763844-f816-4fb8-bb77-90e4e92a035b",
      "name": "Descargar archivo",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -384,
        720
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set File ID').item.json.file_id }}"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "text/plain"
            }
          }
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "executeOnce": true,
      "typeVersion": 3
    },
    {
      "id": "1727e391-12b9-4daf-be02-ed259f203183",
      "name": "Archivo creado",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1584,
        688
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "url",
          "value": "https://drive.google.com/drive/u/0/folders/195OWvKSKZjsdyAIXeqoC9z__QKCRHC8i"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0ecf4c2d-a8e7-4bc1-9568-4e91761b5975",
      "name": "Archivo actualizado",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1584,
        848
      ],
      "parameters": {
        "event": "fileUpdated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "url",
          "value": "https://drive.google.com/drive/u/0/folders/195OWvKSKZjsdyAIXeqoC9z__QKCRHC8i"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "302e3d68-af63-4ca8-8581-4052a2c41a57",
      "name": "Extraer texto del documento",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        880
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "ee1782c4-a0e9-4e2c-91d5-0637f2eb116c",
      "name": "Eliminar filas antiguas del documento",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1008,
        704
      ],
      "parameters": {
        "tableId": "documents",
        "operation": "delete",
        "filterType": "string",
        "filterString": "=metadata->>file_id=like.*{{ $json.file_id }}*"
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "beb679e2-5d1b-4057-8336-b88a120e14c0",
      "name": "Establecer ID de archivo",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "10646eae-ae46-4327-a4dc-9987c2d76173",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "f4536df5-d0b1-4392-bf17-b8137fb31a44",
              "name": "file_type",
              "type": "string",
              "value": "={{ $json.mimeType }}"
            },
            {
              "id": "77d782de-169d-4a46-8a8e-a3831c04d90f",
              "name": "file_title",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "9bde4d7f-e4f3-4ebd-9338-dce1350f9eab",
              "name": "file_url",
              "type": "string",
              "value": "={{ $json.webViewLink }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6af75b7c-ec0e-4b77-85ba-2a2ee19036c3",
      "name": "Extraer texto de PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        400
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "6aa55864-a508-40c9-89d3-688dee81f0b5",
      "name": "Agregar",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        944,
        576
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "7ce461dd-995b-4bf5-82c2-1c6715eea4d9",
      "name": "Separador de texto por caracteres",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        2272,
        848
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "88f0b762-bffe-4009-aa05-9731e42eab19",
      "name": "Resumir",
      "type": "n8n-nodes-base.summarize",
      "position": [
        1152,
        576
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "data",
              "aggregation": "concatenate"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9af99c48-af67-43e2-bc90-652200c29dc4",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -64,
        688
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/pdf"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2ae7faa7-a936-4621-a680-60c512163034",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fc193b06-363b-4699-a97d-e5a850138b0e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "=application/vnd.google-apps.spreadsheet"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b69f5605-0179-4b02-9a32-e34bb085f82d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/vnd.google-apps.document"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": 3
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
      "name": "Insertar en vectorstore Supabase",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        2288,
        512
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "queryName": "match_documents"
        },
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a39e26de-40c4-479f-a4a1-0cc694273d10",
      "name": "Extraer de Excel",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        560
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1
    },
    {
      "id": "1bf5cdce-144c-432d-a887-77a380ae9af2",
      "name": "Establecer esquema",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f422e2e0-381c-46ea-8f38-3f58c501d8b9",
              "name": "schema",
              "type": "string",
              "value": "={{ $('Extract from Excel').isExecuted ? $('Extract from Excel').first().json.keys().toJsonString() : $('Extract from CSV').first().json.keys().toJsonString() }}"
            },
            {
              "id": "bb07c71e-5b60-4795-864c-cc3845b6bc46",
              "name": "data",
              "type": "string",
              "value": "={{ $json.concatenated_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9a3f6aa6-f35d-4a31-bd97-e9dd10bf8b36",
      "name": "Extraer de CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        720
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "183a8c77-15b9-4624-ba79-2c6117ab25c0",
      "name": "Iterar sobre elementos",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1376,
        704
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c8ba6c05-5779-4149-b5a5-c1eb0007f3c0",
      "name": "Eliminar filas de datos antiguas",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -848,
        864
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "dataset_id",
              "keyValue": "={{ $('Set File ID').item.json.file_id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "document_rows",
        "operation": "delete"
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "executeOnce": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "bc67ba0a-5e5c-4c8e-bb0f-3bbea9b1a238",
      "name": "Insertar metadatos del documento",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -688,
        720
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_metadata",
          "cachedResultName": "document_metadata"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "id": "={{ $('Set File ID').item.json.file_id }}",
            "url": "={{ $('Set File ID').item.json.file_url }}",
            "title": "={{ $('Set File ID').item.json.file_title }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "created_at",
              "type": "dateTime",
              "display": true,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "schema",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "schema",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.5
    },
    {
      "id": "b73735e9-7a14-4857-80c5-c27a27916a24",
      "name": "Insertar filas de tabla",
      "type": "n8n-nodes-base.postgres",
      "position": [
        992,
        800
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_rows",
          "cachedResultName": "document_rows"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "row_data": "={{ $json.toJsonString().replaceAll(/'/g, \"''\") }}",
            "dataset_id": "={{ $('Set File ID').item.json.file_id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "number",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "dataset_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "dataset_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_data",
              "type": "object",
              "display": true,
              "required": false,
              "displayName": "row_data",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "af533d64-bab2-446a-855c-718551ac0ac3",
      "name": "Actualizar esquema para metadatos del documento",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1680,
        560
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_metadata",
          "cachedResultName": "document_metadata"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "id": "={{ $('Set File ID').item.json.file_id }}",
            "schema": "={{ $json.schema }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "created_at",
              "type": "dateTime",
              "display": true,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "schema",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "schema",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "97d27ff3-7682-4119-9ba6-f5303a3a83a6",
      "name": "Crear tabla de metadatos de documento1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2272,
        768
      ],
      "parameters": {
        "query": "CREATE TABLE {{ $('When chat message received').item.json.chatInput }}_document_metadata (\n    id TEXT PRIMARY KEY,\n    title TEXT,\n    url TEXT,\n    created_at TIMESTAMP DEFAULT NOW(),\n    schema TEXT\n);",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "executeOnce": false,
      "typeVersion": 2.5,
      "alwaysOutputData": false
    },
    {
      "id": "57a81189-6b1b-4375-b974-f47732fcf556",
      "name": "Crear tabla de filas de documento (para datos tabulares)1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2080,
        768
      ],
      "parameters": {
        "query": "CREATE TABLE {{ $('When chat message received').item.json.chatInput }}_document_rows (\n    id SERIAL PRIMARY KEY,\n    dataset_id TEXT REFERENCES {{ $('When chat message received').item.json.chatInput }}_document_metadata(id),\n    row_data JSONB  -- Store the actual row data\n);",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "c792cc00-c762-4f15-8646-ab38880d5abb",
      "name": "Crear tabla de documentos y función de coincidencia1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2496,
        768
      ],
      "parameters": {
        "query": "-- Create a table to store your documents\nCREATE TABLE {{ $json.chatInput }}_documents (\n  id bigserial primary key,\n  content text, -- corresponds to Document.pageContent\n  metadata jsonb, -- corresponds to Document.metadata\n  embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed\n);\n\n-- Create an index for better performance\nCREATE INDEX {{ $json.chatInput }}_documents_embedding_idx \nON {{ $json.chatInput }}_documents \nUSING ivfflat (embedding vector_cosine_ops);\n\n-- Create a function to search for documents\nCREATE OR REPLACE FUNCTION match_{{ $json.chatInput }}_documents (\n  query_embedding vector(1536),\n  match_count int DEFAULT 10,\n  filter jsonb DEFAULT '{}'\n)\nRETURNS TABLE (\n  id bigint,\n  content text,\n  metadata jsonb,\n  similarity float\n)\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  RETURN QUERY\n  SELECT\n    doc.id,\n    doc.content,\n    doc.metadata,\n    1 - (doc.embedding <=> query_embedding) as similarity\n  FROM {{ $('Chercher nom dernier client').item.json['Dernier client'] }}_documents doc\n  WHERE \n    CASE \n      WHEN filter != '{}' THEN doc.metadata @> filter\n      ELSE TRUE\n    END\n  ORDER BY doc.embedding <=> query_embedding\n  LIMIT match_count;\nEND;\n$$;\n\n-- Grant permissions\nGRANT EXECUTE ON FUNCTION match_{{ $json.chatInput }}_documents TO authenticated;\nGRANT EXECUTE ON FUNCTION match_{{ $json.chatInput }}_documents TO anon;",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "f47597d0-fbee-4a6b-8c05-c2173c7c677a",
      "name": "Cuando se recibe mensaje de chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -2704,
        768
      ],
      "webhookId": "d1a1c40a-f780-45de-82cd-7e1edbc030e2",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "f90f3329-854c-4764-a9a4-3260eb2566ef",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2784,
        608
      ],
      "parameters": {
        "width": 928,
        "height": 352,
        "content": "# Phase 1: Client-Specific Database Infrastructure Creation"
      },
      "typeVersion": 1
    },
    {
      "id": "d069eb31-d6d9-44b0-b6ba-d7ad638a228a",
      "name": "Nota adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2784,
        1008
      ],
      "parameters": {
        "width": 928,
        "height": 384,
        "content": "### What you do:\nProvide the client name or identifier via chat interface to initialize their dedicated database tables\nEnsure the client name follows proper naming conventions (no spaces, special characters)\nConfirm the client requires a separate vector database instance for data isolation\n\n### What the system does:\nCreates client-specific PostgreSQL tables with pgvector extension for isolated vector storage\nEstablishes dedicated document metadata table with client-specific naming convention\nSets up client-specific document rows table for tabular data storage (spreadsheets, CSV files)\nCreates custom match function for similarity search operations using client-specific table names\nConfigures separate Supabase integration for each client's vector storage and retrieval operations\n\n**Database Tables Created:**\n- `[client_name]_documents`: Vector storage with embeddings and metadata\n- `[client_name]_document_metadata`: Document tracking with titles, URLs, schemas\n- `[client_name]_document_rows`: Tabular data storage for spreadsheets/CSV files\n- `match_[client_name]_documents()`: Custom search function for semantic queries\n\n### Result:\n✅ Isolated vector database infrastructure established per client\n✅ Complete data separation ensuring client confidentiality\n✅ Multi-format document support enabled for each client instance\n✅ Custom search capabilities activated per client database\n✅ Scalable multi-tenant architecture ready for document processing"
      },
      "typeVersion": 1
    },
    {
      "id": "2b4bd032-c5ed-4dd1-979c-d8d783a46ffe",
      "name": "Nota adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        544
      ],
      "parameters": {
        "color": 2,
        "width": 1264,
        "height": 480,
        "content": "# Phase 2: Google Drive Folder Monitoring Configuration"
      },
      "typeVersion": 1
    },
    {
      "id": "7581238d-621d-46e0-bffd-2d5f79ce419b",
      "name": "Nota adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        1072
      ],
      "parameters": {
        "color": 2,
        "width": 1264,
        "height": 752,
        "content": "### What you do:\nConfigure the Google Drive folder URL for monitoring specific client document repositories\nUpdate the folder path in both \"File Created\" and \"File Updated\" trigger nodes\nEnsure proper Google Drive API permissions for file access and monitoring\nVerify the Supabase vector store node points to the correct client-specific table name\n\n### What the system does:\nMonitors specified Google Drive folder for new file uploads and existing file updates\nTriggers workflow execution automatically when documents are created or modified\nHandles multiple file types including PDF, Google Docs, Sheets, Excel, and CSV files\nImplements dual triggers for both file creation and update events ensuring comprehensive coverage\nProcesses files individually to maintain data integrity and prevent cross-client contamination\n\n**Critical Configuration Requirements:**\n- Update folder URL in both trigger nodes to match client's document repository\n- Modify \"Insert into Supabase Vectorstore\" node table name to `[client_name]_documents`\n- Ensure all database operations reference correct client-specific table names\n\n### Result:\n✅ Real-time document monitoring for client-specific Google Drive folders\n✅ Automatic processing of new and updated documents with proper client isolation\n✅ Multi-format file support for comprehensive document management\n✅ Reliable trigger system ensuring no client documents are missed\n✅ Scalable monitoring infrastructure supporting multiple client instances\n"
      },
      "typeVersion": 1
    },
    {
      "id": "226700d4-3476-4412-b262-fc7cc6eed359",
      "name": "Nota adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        352
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 672,
        "content": "# Phase 3: Document Processing and Content Extraction"
      },
      "typeVersion": 1
    },
    {
      "id": "b39dacf6-d438-42ea-baf7-8a107de0d8a5",
      "name": "Nota adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        1072
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 464,
        "content": "### What the system does:\nDownloads documents from Google Drive using secure API connections with client context\nIdentifies file types automatically and routes to appropriate extraction methods\nProcesses PDF files with text extraction preserving structure and formatting\nHandles Google Docs conversion to plain text format for optimal AI processing\nExtracts data from Excel and CSV files with schema detection and preservation\nImplements comprehensive error handling for corrupted or inaccessible documents\n\n**Multi-Format Processing Capabilities:**\n- PDF documents: Full text extraction with formatting preservation\n- Google Docs: Native conversion to structured text format\n- Excel/Google Sheets: Data extraction with automatic column schema detection\n- CSV files: Structured data processing with intelligent delimiter detection\n\n### Result:\n✅ Comprehensive content extraction across all major document formats\n✅ Structured data preservation for spreadsheets and tabular client content\n✅ Clean text formatting optimized for AI processing and vector embedding generation\n✅ Robust error handling ensuring workflow stability across diverse document types\n✅ Schema detection enabling intelligent data organization for each client"
      },
      "typeVersion": 1
    },
    {
      "id": "8e3a496d-a4be-4b86-a605-b9bade310350",
      "name": "Nota adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        352
      ],
      "parameters": {
        "color": 4,
        "width": 1072,
        "height": 672,
        "content": "# Phase 4: Data Aggregation and Schema Management"
      },
      "typeVersion": 1
    },
    {
      "id": "811f442d-439a-473a-9e15-5156860a6d7c",
      "name": "Nota adhesiva7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        1072
      ],
      "parameters": {
        "color": 4,
        "width": 1072,
        "height": 464,
        "content": "### What the system does:\nAggregates extracted data from Excel and CSV files for comprehensive processing\nConcatenates structured data while preserving individual record integrity\nSummarizes tabular data by combining all rows into a unified format for vector processing\nStores individual table rows in client-specific PostgreSQL database for structured queries\nCreates and updates schema metadata for spreadsheet and CSV file structures\nMaps column structures and data types for intelligent data organization per client\n\n**Data Processing Operations:**\n- \"Aggregate\": Combines all extracted data items into consolidated format\n- \"Summarize\": Concatenates field data while maintaining structure\n- \"Insert Table Rows\": Stores individual rows in `[client_name]_document_rows` table\n- \"Set Schema\": Captures column structure and data types from spreadsheets/CSV\n- \"Update Schema for Document Metadata\": Updates client metadata with schema information\n\n### Result:\n✅ Structured data properly aggregated for vector embedding processing\n✅ Individual table rows preserved for detailed structured queries\n✅ Schema information captured enabling intelligent data organization\n✅ Client-specific tabular data storage with full query capabilities\n✅ Data structure metadata maintained for enhanced search and filtering\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b80cc540-8d1d-49d1-b30f-be387dba08f8",
      "name": "Nota adhesiva8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        352
      ],
      "parameters": {
        "color": 5,
        "width": 848,
        "height": 672,
        "content": "# Phase 5: Advanced Vector Embedding and Text Processing"
      },
      "typeVersion": 1
    },
    {
      "id": "7ccf7914-52a0-439a-8560-e7fa3282d17e",
      "name": "Nota adhesiva10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        1072
      ],
      "parameters": {
        "color": 5,
        "width": 848,
        "height": 432,
        "content": "### What the system does:\nProcesses aggregated text content using OpenAI embeddings for semantic search capabilities\nImplements character-based text splitting to maintain context while optimizing chunk sizes\nGenerates high-dimensional vector representations (1536 dimensions) for similarity search\nLoads processed documents with proper metadata attribution for client identification\nConfigures embedding model parameters optimized for document content and search performance\n\n**Vector Processing Components:**\n- \"Embeddings OpenAI\": Generates semantic embeddings using text-embedding-3-small model\n- \"Character Text Splitter\": Intelligently segments text maintaining contextual coherence\n- \"Default Data Loader\": Loads processed content with client-specific metadata tags\n- Metadata preservation including file_id and file_title for document traceability\n\n### Result:\n✅ High-quality semantic embeddings optimized for client-specific document search\n✅ Intelligent text segmentation preserving document meaning and context\n✅ Proper metadata attribution enabling document traceability and client isolation\n✅ Search-optimized vector representations supporting similarity queries\n✅ Scalable embedding generation supporting large document collections per client\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b3caa235-e98b-40a6-a65c-5b1da8334e6b",
      "name": "Nota adhesiva11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        464
      ],
      "parameters": {
        "color": 6,
        "width": 928,
        "height": 576,
        "content": "# Phase 6: Client-Specific Vector Database Storage and Workflow Completion\n\n### What the system does:\nStores processed vector embeddings in client-specific Supabase database tables\nInserts document vectors with associated metadata into `[client_name]_documents` table\nCompletes the document processing cycle and returns to monitoring loop for additional files\nMaintains data integrity through proper client-specific table targeting\nEnables immediate semantic search capabilities within client's isolated vector database\n\n**Critical Configuration Requirement:**\n- **IMPORTANT**: Update \"Insert into Supabase Vectorstore\" node to reference correct client table name\n- Change table name from generic \"documents\" to `[client_name]_documents`\n- Ensure vector storage targets the client-specific table created in Phase 1\n\n### Result:\n✅ Vector embeddings securely stored in client-specific database tables\n✅ Immediate semantic search capabilities activated for client document collection\n✅ Complete workflow cycle enabling continuous document processing and monitoring\n✅ Client data isolation maintained through proper table targeting\n✅ Scalable vector storage supporting unlimited document processing per client instance"
      },
      "typeVersion": 1
    },
    {
      "id": "6e276b1a-8a09-4e6e-9581-5bca83043698",
      "name": "Nota adhesiva9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4112,
        640
      ],
      "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%9F%A7%B2-6537b633/"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "9af99c48-af67-43e2-bc90-652200c29dc4": {
      "main": [
        [
          {
            "node": "6af75b7c-ec0e-4b77-85ba-2a2ee19036c3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a39e26de-40c4-479f-a4a1-0cc694273d10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9a3f6aa6-f35d-4a31-bd97-e9dd10bf8b36",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "302e3d68-af63-4ca8-8581-4052a2c41a57",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6aa55864-a508-40c9-89d3-688dee81f0b5": {
      "main": [
        [
          {
            "node": "88f0b762-bffe-4009-aa05-9731e42eab19",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "88f0b762-bffe-4009-aa05-9731e42eab19": {
      "main": [
        [
          {
            "node": "1bf5cdce-144c-432d-a887-77a380ae9af2",
            "type": "main",
            "index": 0
          },
          {
            "node": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1bf5cdce-144c-432d-a887-77a380ae9af2": {
      "main": [
        [
          {
            "node": "af533d64-bab2-446a-855c-718551ac0ac3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "beb679e2-5d1b-4057-8336-b88a120e14c0": {
      "main": [
        [
          {
            "node": "ee1782c4-a0e9-4e2c-91d5-0637f2eb116c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1727e391-12b9-4daf-be02-ed259f203183": {
      "main": [
        [
          {
            "node": "183a8c77-15b9-4624-ba79-2c6117ab25c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0ecf4c2d-a8e7-4bc1-9568-4e91761b5975": {
      "main": [
        [
          {
            "node": "183a8c77-15b9-4624-ba79-2c6117ab25c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a3763844-f816-4fb8-bb77-90e4e92a035b": {
      "main": [
        [
          {
            "node": "9af99c48-af67-43e2-bc90-652200c29dc4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "183a8c77-15b9-4624-ba79-2c6117ab25c0": {
      "main": [
        [],
        [
          {
            "node": "beb679e2-5d1b-4057-8336-b88a120e14c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6af75b7c-ec0e-4b77-85ba-2a2ee19036c3": {
      "main": [
        [
          {
            "node": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9a3f6aa6-f35d-4a31-bd97-e9dd10bf8b36": {
      "main": [
        [
          {
            "node": "6aa55864-a508-40c9-89d3-688dee81f0b5",
            "type": "main",
            "index": 0
          },
          {
            "node": "b73735e9-7a14-4857-80c5-c27a27916a24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e54ed2cc-2648-4e86-8f10-1ae805e09b97": {
      "ai_embedding": [
        [
          {
            "node": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "a39e26de-40c4-479f-a4a1-0cc694273d10": {
      "main": [
        [
          {
            "node": "6aa55864-a508-40c9-89d3-688dee81f0b5",
            "type": "main",
            "index": 0
          },
          {
            "node": "b73735e9-7a14-4857-80c5-c27a27916a24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8dcb88e1-3482-41a1-9637-b216806a2613": {
      "ai_document": [
        [
          {
            "node": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "ee1782c4-a0e9-4e2c-91d5-0637f2eb116c": {
      "main": [
        [
          {
            "node": "c8ba6c05-5779-4149-b5a5-c1eb0007f3c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c8ba6c05-5779-4149-b5a5-c1eb0007f3c0": {
      "main": [
        [
          {
            "node": "bc67ba0a-5e5c-4c8e-bb0f-3bbea9b1a238",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "302e3d68-af63-4ca8-8581-4052a2c41a57": {
      "main": [
        [
          {
            "node": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7ce461dd-995b-4bf5-82c2-1c6715eea4d9": {
      "ai_textSplitter": [
        [
          {
            "node": "8dcb88e1-3482-41a1-9637-b216806a2613",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "bc67ba0a-5e5c-4c8e-bb0f-3bbea9b1a238": {
      "main": [
        [
          {
            "node": "a3763844-f816-4fb8-bb77-90e4e92a035b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f47597d0-fbee-4a6b-8c05-c2173c7c677a": {
      "main": [
        [
          {
            "node": "c792cc00-c762-4f15-8646-ab38880d5abb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "97d27ff3-7682-4119-9ba6-f5303a3a83a6": {
      "main": [
        [
          {
            "node": "57a81189-6b1b-4375-b974-f47732fcf556",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577": {
      "main": [
        [
          {
            "node": "183a8c77-15b9-4624-ba79-2c6117ab25c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c792cc00-c762-4f15-8646-ab38880d5abb": {
      "main": [
        [
          {
            "node": "97d27ff3-7682-4119-9ba6-f5303a3a83a6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Creación de contenido, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos38
Categoría2
Tipos de nodos16
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34