初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总

高级

这是一个Document Extraction、AI Summarization领域的自动化工作流,包含 21 个节点。主要使用 If、Set、Code、Merge、Filter 等节点。 初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总

前置要求
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "a241764c-eb51-4d7a-b5d4-3aa517a9195f",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -160,
        280
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 173686600,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=173686600",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
          "cachedResultName": "Sample Marketing Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "d7b9ee1a-f87d-42f6-b480-8ee687612f33",
      "name": "过滤器",
      "type": "n8n-nodes-base.filter",
      "position": [
        340,
        120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "65acf956-5912-4070-8896-923b74548a5e",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.Clicks }}",
              "rightValue": 5
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "872dd275-ca9a-4d30-8ac1-e1e921f5e6fd",
      "name": "将表名和列名转换为代理可读的单一文本",
      "type": "n8n-nodes-base.code",
      "position": [
        1380,
        280
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      text: items.map(item => JSON.stringify(item.json)).join('\\n'),\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "4b8595d1-d975-49f6-bff0-265aef52042f",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1620,
        500
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c83d8a13-b2da-42f5-b137-763fa06e22e4",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1800,
        500
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"paragraph\": \"full paragraph\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "c1ad3e75-1964-4f3b-b60c-a9531f8770f7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -200
      ],
      "parameters": {
        "width": 700,
        "height": 880,
        "content": "### 📌 合并多个数据集"
      },
      "typeVersion": 1
    },
    {
      "id": "9de427fa-c2e0-4de0-8e7b-35d4566f3d6e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 380,
        "height": 880,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "8aa28836-07db-42f7-b2da-0b2e656e92c7",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -200
      ],
      "parameters": {
        "color": 3,
        "width": 380,
        "height": 880,
        "content": "### 📌 汇总和设置步骤"
      },
      "typeVersion": 1
    },
    {
      "id": "1fb89d3c-a10e-490d-998a-42436a1d05d0",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -200
      ],
      "parameters": {
        "color": 2,
        "width": 860,
        "height": 880,
        "content": "### 📌 使用 AI 代理分析结果"
      },
      "typeVersion": 1
    },
    {
      "id": "02854b46-8baf-438e-b110-92ce4e96dd6b",
      "name": "营销数据示例",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -160,
        80
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
          "cachedResultName": "Sample Marketing Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "cf5b6397-fe1a-46db-928a-5903507ef424",
      "name": "启动工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -380,
        180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "58039c62-8b23-4114-9e86-5502c82719ee",
      "name": "基于渠道字段合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        60,
        180
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "fieldsToMatchString": "Channel"
      },
      "typeVersion": 3.2
    },
    {
      "id": "7ed757ca-05b7-41af-9f70-f88b9aba4981",
      "name": "检查支出是否超过 350 美元",
      "type": "n8n-nodes-base.if",
      "position": [
        460,
        340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c0cba05b-63ba-420e-851a-caf2bf9b9914",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json['Spend ($)'] }}",
              "rightValue": 350
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "73aeb996-58d7-4492-a948-bc6f9f92cb46",
      "name": "统计差评天数",
      "type": "n8n-nodes-base.summarize",
      "position": [
        740,
        100
      ],
      "parameters": {
        "options": {},
        "fieldsToSplitBy": "Leader",
        "fieldsToSummarize": {
          "values": [
            {
              "field": "row_number"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "af21446e-d779-4937-bee4-d650dccd8f32",
      "name": "统计好评天数",
      "type": "n8n-nodes-base.summarize",
      "position": [
        760,
        300
      ],
      "parameters": {
        "options": {},
        "fieldsToSplitBy": "Leader",
        "fieldsToSummarize": {
          "values": [
            {
              "field": "row_number"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "9b6bb3eb-aae2-4317-8551-78fb81312765",
      "name": "将字段组织成表格",
      "type": "n8n-nodes-base.set",
      "position": [
        920,
        120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e2f52c05-13a5-4692-bbea-87642535145e",
              "name": "Outcome",
              "type": "string",
              "value": "Poor"
            },
            {
              "id": "8c353e0a-409f-4cff-a1b9-17259cc3a1dd",
              "name": "# of Days",
              "type": "number",
              "value": "={{ $json.count_row_number }}"
            },
            {
              "id": "82d2f8dd-54b8-42c8-b502-6ae1fc76e1fe",
              "name": "Leader",
              "type": "string",
              "value": "={{ $json.Leader }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b5780191-2068-4595-b18c-16626003145d",
      "name": "将第二组数据组织成表格",
      "type": "n8n-nodes-base.set",
      "position": [
        920,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f3f79a06-acb9-4b89-a7ab-438358b4395e",
              "name": "Outcome",
              "type": "string",
              "value": "Great"
            },
            {
              "id": "e79913fa-a2ec-459c-a00d-df23bb1a2a25",
              "name": "# of Days",
              "type": "number",
              "value": "={{ $json.count_row_number }}"
            },
            {
              "id": "a6b563e3-0776-4916-a9f3-05d38a67330a",
              "name": "Leader",
              "type": "string",
              "value": "={{ $json.Leader }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "097dc227-3999-427c-9900-008845b00131",
      "name": "合并数据源",
      "type": "n8n-nodes-base.merge",
      "position": [
        1180,
        220
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "1ec5183b-be3f-447a-b312-56420ac5c706",
      "name": "AI 代理 - 总结负责人绩效",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1600,
        180
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are given a list of outcomes by leader. write a summary of the outcomes and identify who is doing the best and worst, and why. \n\noutput as one paragraph. \n\nOutput like this. \n\n{\n\t\"paragraph\": \"full paragraph\"\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "0a53ca1a-53f0-4d68-b70f-e5fff251af5f",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -400
      ],
      "parameters": {
        "color": 4,
        "width": 1100,
        "content": "### 📌 设置说明"
      },
      "typeVersion": 1
    },
    {
      "id": "4dffd2eb-9a06-4103-97a5-47aeccdca95c",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -400
      ],
      "parameters": {
        "color": 2,
        "width": 1280,
        "content": "### 👋 有问题或反馈?"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Filter": {
      "main": [
        [
          {
            "node": "Check if spend over $350",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count bad days": {
      "main": [
        [
          {
            "node": "Organize fields into table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Merge on Channel Field",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Start Workflow": {
      "main": [
        [
          {
            "node": "Sample Marketing Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count good days": {
      "main": [
        [
          {
            "node": "Organize second data into table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Summarize Leader Performance",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sample Marketing Data": {
      "main": [
        [
          {
            "node": "Merge on Channel Field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge on Channel Field": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if spend over $350": {
      "main": [
        [
          {
            "node": "Count bad days",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Count good days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent - Summarize Leader Performance",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Organize fields into table": {
      "main": [
        [
          {
            "node": "Append datasources together",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append datasources together": {
      "main": [
        [
          {
            "node": "Convert table names and columns into single text for agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Organize second data into table": {
      "main": [
        [
          {
            "node": "Append datasources together",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "AI Agent - Summarize Leader Performance": {
      "main": [
        []
      ]
    },
    "Convert table names and columns into single text for agent": {
      "main": [
        [
          {
            "node": "AI Agent - Summarize Leader Performance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Document Extraction、AI Summarization等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

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

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

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 上查看 →

分享此工作流