8
n8n 中文网amn8n.com

使用Google Sheets、SerpAPI、Apify和GPT-4o提取本地企业联系人

高级

这是一个Lead Generation, AI Summarization领域的自动化工作流,包含 18 个节点。主要使用 Code, Filter, Summarize, SerpApi, HttpRequest 等节点。 使用Google Sheets、SerpAPI、Apify和GPT-4o提取本地企业联系人

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439"
  },
  "nodes": [
    {
      "id": "0377cde7-39de-4a27-9f57-2ac62ecae89c",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2520,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ac9d9f3b-db6c-4491-a1ce-ebfff9652ea3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -700,
        780
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a05ec908-7476-49ec-9b32-3355cec11dce",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -580,
        780
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"email\": \"emailaddress\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "f6bbdf13-a0c1-4d9e-9157-c1a55a06e16b",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        -1160,
        260
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "2003373e-cb00-4c74-b0bf-7ddb677ddb96",
      "name": "执行工作流",
      "type": "n8n-nodes-base.executeWorkflow",
      "onError": "continueRegularOutput",
      "position": [
        -640,
        200
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": false
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "SDMXLfMXOQ6TDfKq",
          "cachedResultName": "Email Extraction Project"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "17c39dd5-5c44-4b95-ad50-591224d5517c",
      "name": "提取搜索词",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -2300,
        400
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit#gid=0",
          "cachedResultName": "Searches"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit?usp=drivesdk",
          "cachedResultName": "Searches&Results"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.6
    },
    {
      "id": "4222fa4d-d0e0-4e91-90bf-dead1424ed2c",
      "name": "保留未处理的行",
      "type": "n8n-nodes-base.filter",
      "position": [
        -2080,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c295c5ea-1ec4-4c9f-bf12-f4c23c60543f",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Complete }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4de8ae34-2fea-4169-ada9-80cad9ee2e87",
      "name": "筛选到第一行",
      "type": "n8n-nodes-base.code",
      "position": [
        -1860,
        400
      ],
      "parameters": {
        "jsCode": "return [items[0]];"
      },
      "typeVersion": 2
    },
    {
      "id": "af38c3a1-1414-4dcf-932d-e4a1db059a91",
      "name": "将行标记为已完成",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1640,
        300
      ],
      "parameters": {
        "columns": {
          "value": {
            "Search": "={{ $json.Search }}",
            "Complete": "Yes"
          },
          "schema": [
            {
              "id": "Search",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Search",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Area",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Area",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Area Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Area Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Complete",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Complete",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Search"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit#gid=0",
          "cachedResultName": "Searches"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit?usp=drivesdk",
          "cachedResultName": "Searches&Results"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e0087b09-f158-4ce8-bb74-ce45b5d9dfa6",
      "name": "搜索 Google 地图",
      "type": "n8n-nodes-serpapi.serpApi",
      "onError": "continueRegularOutput",
      "position": [
        -1640,
        500
      ],
      "parameters": {
        "q": "={{ $json.Search }}",
        "ll": "={{ $json.Area }}",
        "operation": "google_maps",
        "requestOptions": {},
        "additionalFields": {}
      },
      "credentials": {
        "serpApi": {
          "id": "u6KGxSGJbtJANls7",
          "name": "SerpAPI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fc558eef-8092-42f7-ab51-41c7002cb50b",
      "name": "将输出格式化为表格",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        -1420,
        500
      ],
      "parameters": {
        "jsCode": "const results = items[0].json.local_results || [];\n\nconst parsedResults = results.map(entry => {\n  // Remove \"/url?q=\" if present in the website\n  let cleanWebsite = entry.website || null;\n  if (cleanWebsite && cleanWebsite.startsWith(\"/url?q=\")) {\n    cleanWebsite = cleanWebsite.replace(\"/url?q=\", \"\").split(\"&\")[0];\n  }\n\n  return {\n    title: entry.title || null,\n    website: cleanWebsite,\n    address: entry.address || null,\n    phone: entry.phone || null,\n  };\n});\n\n// Return each result as a separate item\nreturn parsedResults.map(result => ({ json: result }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2d3fa5a3-f338-4eb8-be95-c915ce3f189a",
      "name": "将电子邮件保存到表格",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        -940,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Area": "={{ $('Extract Search Terms').item.json.Area }}",
            "phone": "={{ $('Format output as table').item.json.phone }}",
            "title": "={{ $('Format output as table').item.json.title }}",
            "Search": "={{ $('Extract Search Terms').item.json.Search }}",
            "address": "={{ $('Format output as table').item.json.address }}",
            "website": "={{ $('Format output as table').item.json.website }}",
            "Search Name": "={{ $('Extract Search Terms').item.json['Area Name'] }}",
            "email (Manual Entry)": "={{ $json.output.email }}"
          },
          "schema": [
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Search",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Search",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Search Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Search Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Area",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Area",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email (Manual Entry)",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email (Manual Entry)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "title"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1470668196,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit#gid=1470668196",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nwgaTyp239ErzFS0IaDnJca-6LkIqvshmiHHs5bX77o/edit?usp=drivesdk",
          "cachedResultName": "Searches&Results"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "947fad74-dd81-4993-947e-a1e9264c1056",
      "name": "抓取网页",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -940,
        400
      ],
      "parameters": {
        "url": "=https://api.apify.com/v2/acts/6sigmag~fast-website-content-crawler/run-sync-get-dataset-items\n",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"startUrls\": [\n        \"{{ $json.website }}\"\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "yLUXsSPePLOGnHmf",
          "name": "Query Auth account"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "eaab5179-b3a7-4c94-b2b9-0db29509573f",
      "name": "提取电子邮件 - AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        -720,
        560
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "extract the email address from the text. if there is no email address, output null. "
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "4a9f36d4-fd8b-409c-a1af-6be7248ed671",
      "name": "减少到 1 行",
      "type": "n8n-nodes-base.summarize",
      "onError": "continueRegularOutput",
      "position": [
        -940,
        200
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "title"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0fa2b9a4-3e33-4830-86a5-5466f4b9ab1a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2380,
        20
      ],
      "parameters": {
        "width": 980,
        "content": "## n8n 工作流:本地企业联系人查找器与电子邮件提取"
      },
      "typeVersion": 1
    },
    {
      "id": "72de7718-1d85-47e4-ab0b-5e559323f6d4",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3360,
        -80
      ],
      "parameters": {
        "width": 780,
        "height": 1160,
        "content": "## 如何实施此 n8n 工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "c771ab3b-428f-46d9-be51-6ea1ce2a3659",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2560,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 2260,
        "height": 1160,
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "When clicking ‘Execute workflow’": [
      {}
    ]
  },
  "connections": {
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Save Emails to Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Reduce to 1 row",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Web Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reduce to 1 row": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Web Page": {
      "main": [
        [
          {
            "node": "Extract Email - AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Email - AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Search Google Maps": {
      "main": [
        [
          {
            "node": "Format output as table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter to first row": {
      "main": [
        [
          {
            "node": "Mark Row as Completed",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Search Terms": {
      "main": [
        [
          {
            "node": "Keep Unprocessed Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep Unprocessed Rows": {
      "main": [
        [
          {
            "node": "Filter to first row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format output as table": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Email - AI Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Extract Email - AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Extract Search Terms",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 潜在客户开发, AI 摘要总结

需要付费吗?

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

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

适合高级用户,包含 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 查看

分享此工作流