8
n8n 中文网amn8n.com

Google Drive文件摄取至Supabase知识库

高级

这是一个Support, AI领域的自动化工作流,包含 46 个节点。主要使用 If, Set, Gmail, Switch, Postgres 等节点,结合人工智能技术实现智能自动化。 基于Supabase RAG和GPT-4o-mini的交互式知识库聊天

前置要求
  • Google 账号和 Gmail API 凭证
  • PostgreSQL 数据库连接信息
  • Supabase URL 和 API Key
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "6fZffoKqrzLAmbHc",
  "meta": {
    "instanceId": "3aaeb6eaba3494bbdbe57e25fa3d02783cfbc460b1e823f7b741cf26edc7ca3d"
  },
  "name": "Google Drive 文件摄取至 Supabase 知识库",
  "tags": [],
  "nodes": [
    {
      "id": "eff80cb0-26e5-4a19-a4d6-671a11fe26b6",
      "name": "文件已创建",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -80,
        880
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a78ad8a2-93a9-4c71-8916-e6247d408d82",
      "name": "更新文件",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -80,
        680
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f8a528ba-9638-4a32-a2e2-596c4a63da0c",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        140,
        780
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "bf8e763f-fff5-4fa4-a0ec-4b13bdeb498d",
      "name": "设置文件 ID",
      "type": "n8n-nodes-base.set",
      "position": [
        360,
        640
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "47bc2891-8f9f-416d-b2ce-8fd656796348",
      "name": "检查重复项",
      "type": "n8n-nodes-base.postgres",
      "position": [
        800,
        540
      ],
      "parameters": {},
      "typeVersion": 2.6,
      "alwaysOutputData": true
    },
    {
      "id": "71dd64ed-9c40-4ef0-bf24-5243b2cff499",
      "name": "插入元数据",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1900,
        740
      ],
      "parameters": {},
      "typeVersion": 2.6
    },
    {
      "id": "6a66a187-30c1-46b0-830f-484add803b1d",
      "name": "从 PDF 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ebc02b0a-0481-42e8-8043-e9bcd6c0f02e",
      "name": "从 CSV 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2560,
        580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8bb13f35-03c3-413a-9dcc-1526f40325d3",
      "name": "从 XLSX 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2560,
        980
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a598e49c-d9bc-4305-b917-ccc64feb4c68",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2780,
        740
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e1c0c059-66f5-4a1b-b76a-8db1823c25e1",
      "name": "摘要",
      "type": "n8n-nodes-base.summarize",
      "position": [
        3000,
        740
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "cb46dfca-96ce-478a-98cb-5c94fd48e104",
      "name": "从 RTF 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        1160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9832240d-7cea-465e-b167-17fcf254f5f7",
      "name": "错误记录器",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1240,
        1380
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "01b5f966-e5b7-436e-9551-c31f6b9d4eac",
      "name": "验证文件",
      "type": "n8n-nodes-base.if",
      "position": [
        580,
        640
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "466e1cc8-25e7-462c-b19f-467c66eb1d77",
      "name": "重复检查条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        1020,
        540
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "0dd9891e-7dd3-4f2d-8a2e-094ab3cecec6",
      "name": "记录重复项",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1240,
        440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7d05de17-7909-4da3-bba3-c7f512af1708",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        3240,
        440
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "a764be2e-110f-4320-8bae-f04a749a3ac5",
      "name": "OpenAI嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3220,
        660
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "0ef91d4c-7d6b-4544-9ef5-09a0bdb6dd7c",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        3340,
        660
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "86c648a9-4b9d-4afb-9e2e-f4fff12a1ce0",
      "name": "调试文件 ID",
      "type": "n8n-nodes-base.set",
      "position": [
        1240,
        740
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "392916f3-2265-4c57-abfd-37054da9e741",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2120,
        740
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "a7367c0f-6f22-4099-ac6c-8511081b79f6",
      "name": "设置模式",
      "type": "n8n-nodes-base.set",
      "position": [
        3360,
        1160
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "7051505f-4da8-44c0-90c4-c522d3a2f6d3",
      "name": "文档元数据模式",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3600,
        1160
      ],
      "parameters": {},
      "typeVersion": 2.6
    },
    {
      "id": "6f76fa9d-d1f9-4e05-80af-ec78fed5416c",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        2340,
        680
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "f62efcf8-bb87-4e4e-9c73-0c86ec1c55fd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "82015f8b-1456-4b04-bf38-2735e7f416f6",
      "name": "从 DOC 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        1360
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7af0771c-bed1-4cbb-8122-01ec2d8b4664",
      "name": "Slack 重复通知",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1460,
        440
      ],
      "webhookId": "b530b409-ce3a-44eb-9efc-ab091105fa54",
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "a5ef8a35-ea86-466a-bb6b-2f3ef72acab7",
      "name": "错误通知",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1460,
        1400
      ],
      "webhookId": "b530b409-ce3a-44eb-9efc-ab091105fa54",
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "6ca4d2d7-536c-4229-ac19-39dcb0853c4c",
      "name": "删除旧文档",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1460,
        740
      ],
      "parameters": {},
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "98d0c000-5d9b-419b-aa7c-e98a9f0a90e2",
      "name": "从 TXT 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        3000,
        380
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a53ca5ed-b9f0-4f9e-bb55-017dc5ed1451",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a1c76c00-0bed-48f0-ad8c-f686d5186222",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1620,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "71f8678a-ef8b-40ef-a3ef-3ee90afe65dc",
      "name": "RAG AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -880,
        700
      ],
      "parameters": {},
      "typeVersion": 1.8
    },
    {
      "id": "7c7ebb71-1699-46a5-a756-cf2589815dc8",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1460,
        1180
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "510482ba-030b-4777-9740-bf8993dce021",
      "name": "Postgres 聊天记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -1280,
        1180
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "223791e6-5148-47cd-aab6-ca9cb20b7017",
      "name": "列出文档",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -1060,
        1180
      ],
      "parameters": {},
      "typeVersion": 2.6
    },
    {
      "id": "25cc4ca1-4910-4ae7-a755-c5611946c325",
      "name": "查询文档行",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -620,
        1180
      ],
      "parameters": {},
      "typeVersion": 2.6
    },
    {
      "id": "194c1ee8-1c21-4a1d-b8d2-9991dc8133fd",
      "name": "字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        3440,
        860
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f311ab63-88fa-413a-8ba9-aa866e1fb5f0",
      "name": "插入表行",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2780,
        940
      ],
      "parameters": {},
      "typeVersion": 2.6
    },
    {
      "id": "529e05ca-0494-4eb3-b0f4-275ba252f646",
      "name": "删除旧数据行",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1680,
        740
      ],
      "parameters": {},
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d1702791-fe65-4068-982b-8b378f9c2e0a",
      "name": "设置错误类型",
      "type": "n8n-nodes-base.set",
      "position": [
        1020,
        1200
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "23a05be3-2b40-400b-b8d4-21ee6db78ac4",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1440,
        720
      ],
      "webhookId": "db7e7558-fd4c-4743-b42c-d3b3a38e4d19",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "89262c14-2910-4a9d-b86a-84c015e0daa5",
      "name": "编辑字段2",
      "type": "n8n-nodes-base.set",
      "position": [
        -1180,
        700
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "2325e26f-6237-4128-bead-17e0a9ccb50d",
      "name": "Supabase 向量存储2",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        -460,
        840
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "1289b037-7bc9-4d13-9516-328f1f781c14",
      "name": "OpenAI 嵌入2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -240,
        1060
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "3d15f7db-e7b7-4bb7-a5f7-9962f3a81051",
      "name": "获取完整文档文本 - 获取文件内容",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        -820,
        1180
      ],
      "parameters": {},
      "typeVersion": 2.6
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0c6700ed-433f-46ca-8907-c2f4f94adfda",
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客户支持, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量46
分类2
节点类型22
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流