8
n8n 中文网amn8n.com

使用Perplexity AI和Google Sheets通过业务数据丰富公司域名

中级

这是一个Lead Generation, AI Summarization领域的自动化工作流,包含 9 个节点。主要使用 Code, HttpRequest, GoogleSheets, ManualTrigger, SplitInBatches 等节点。 使用Perplexity AI和Google Sheets通过业务数据丰富公司域名

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "aff7017841e089b12fdff439d182db1ce6e6151977703d9243f6be0543724481",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "bffa5202-a56e-4f05-8b01-e8c4329915f3",
      "name": "手动触发器",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -480,
        56
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bc1ce2a3-f4b0-4cbe-a406-49ac2e339924",
      "name": "获取未处理域名",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -256,
        56
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "=",
              "lookupColumn": "processed"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1737567569,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY/edit#gid=1737567569",
          "cachedResultName": "Data"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY/edit?usp=drivesdk",
          "cachedResultName": "Get Addresses"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Y43YNvASDhLxJg65",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e8d61653-67ef-45bd-8640-f3317c859516",
      "name": "批量处理域名",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -32,
        56
      ],
      "parameters": {
        "options": {},
        "batchSize": 10
      },
      "typeVersion": 3
    },
    {
      "id": "4946ef7e-852b-4860-bef0-aa44bc0c5221",
      "name": "Perplexity AI 研究",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        192,
        -16
      ],
      "parameters": {
        "url": "https://api.perplexity.ai/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"sonar\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"For each of the following 10 companies, return only German addresses and provide: address split as \\\"address\\\", \\\"city\\\", \\\"state\\\", \\\"postal_code\\\", \\\"country\\\"; phone (international format); latest employee count; latest annual revenue (numbers only in USD); industry (e.g., LinkedIn industry category if available); company LinkedIn URL; and a reliable source URL as \\\"source_url\\\". Output results as an array of 10 JSON objects. If any field can't be found reliably, set it to null and don't make things. Companies: ={{ $input.all().map(item => item.json.domain) }}\"\n    }\n  ],\n  \"response_format\": {\n    \"type\": \"json_schema\",\n    \"json_schema\": {\n      \"schema\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"companies\": {\n            \"type\": \"array\",\n            \"items\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"domain\": { \"type\": \"string\" },\n                \"company\": { \"type\": \"string\" },\n                \"address\": { \"type\": \"string\" },\n                \"city\": { \"type\": \"string\" },\n                \"state\": { \"type\": \"string\" },\n                \"postal_code\": { \"type\": \"string\" },\n                \"country\": { \"type\": \"string\" },\n                \"phone\": { \"type\": \"string\" },\n                \"employees\": { \"type\": \"integer\", \"nullable\": true },\n                \"revenue\": { \"type\": \"number\", \"nullable\": true },\n                \"industry\": { \"type\": \"string\", \"nullable\": true },\n                \"linkedin_url\": { \"type\": \"string\", \"nullable\": true },\n                \"source_url\": { \"type\": \"string\" }\n              },\n              \"required\": [\n                \"domain\",\n                \"company\",\n                \"address\",\n                \"city\",\n                \"state\",\n                \"postal_code\",\n                \"country\",\n                \"phone\",\n                \"employees\",\n                \"revenue\",\n                \"industry\",\n                \"linkedin_url\",\n                \"source_url\"\n              ]\n            }\n          }\n        },\n        \"required\": [\"companies\"]\n      }\n    }\n  }\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "perplexityApi"
      },
      "credentials": {
        "perplexityApi": {
          "id": "IRlUSoKLmF6KUhug",
          "name": "Perplexity account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9b4c6512-e43b-4568-8bbb-144ef684bb5a",
      "name": "解析AI响应",
      "type": "n8n-nodes-base.code",
      "position": [
        416,
        -16
      ],
      "parameters": {
        "jsCode": "// Step 1: Get the raw content string\nlet rawContent = $input.first().json.choices[0].message.content;\n\n// Step 2: Try to extract JSON block inside ```json ... ```\nconst match = rawContent.match(/```json\\s*([\\s\\S]*?)\\s*```/i);\n\nif (match) {\n  rawContent = match[1];\n}\n\n// Step 3: Try to parse first-level JSON\nlet parsed;\ntry {\n  parsed = JSON.parse(rawContent);\n\n  // If it's an object with a \"companies\" key, extract the array\n  if (parsed && parsed.companies && Array.isArray(parsed.companies)) {\n    parsed = parsed.companies;\n  }\n  \n  // If it's still a string (stringified JSON inside JSON), parse again\n  if (typeof parsed === 'string') {\n    parsed = JSON.parse(parsed);\n\n    if (parsed && parsed.companies && Array.isArray(parsed.companies)) {\n      parsed = parsed.companies;\n    }\n  }\n\n  // If it's not an array at this point, return warning\n  if (!Array.isArray(parsed)) {\n    return [{\n      json: {\n        warning: \"Parsed result is not an array.\",\n        type: typeof parsed,\n        preview: JSON.stringify(parsed).slice(0, 300)\n      }\n    }];\n  }\n\n} catch (err) {\n  const message = err instanceof Error ? err.message : String(err);\n  return [{\n    json: {\n      error: \"Failed to parse JSON\",\n      message,\n      preview: rawContent.slice(0, 300),\n      rawLength: rawContent.length\n    }\n  }];\n}\n\n// Step 4: Return each company as a separate item\nreturn parsed.map(company => ({ json: company }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7d2016fd-3385-4c78-a8f0-37b4dd5df146",
      "name": "保存增强数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        640,
        56
      ],
      "parameters": {
        "columns": {
          "value": {
            "city": "={{ $json.city }}",
            "phone": "={{ $json.phone.replace(\"+\", \"'+\") }}",
            "state": "={{ $json.state }}",
            "domain": "={{ $json.domain }}",
            "address": "={{ $json.address }}",
            "company": "={{ $json.company }}",
            "country": "={{ $json.country }}",
            "revenue": "={{ $json.revenue }}",
            "industry": "={{ $json.industry }}",
            "postCode": "={{ $json.postal_code }}",
            "employees": "={{ $json.employees }}",
            "processed": "true",
            "source_url": "={{ $json.source_url }}",
            "companyLinkedinUrl": "={{ $json.linkedin_url }}"
          },
          "schema": [
            {
              "id": "domain",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "city",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "city",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "state",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "state",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "postCode",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "postCode",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "country",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "employees",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "employees",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "revenue",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "revenue",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "companyLinkedinUrl",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "companyLinkedinUrl",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "source_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "source_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "processed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "processed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "domain"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1737567569,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY/edit#gid=1737567569",
          "cachedResultName": "Data"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bdK8xskt-qfLlDwdzolM0zFyo9KxZ-HHpTVxcEw3ZMY/edit?usp=drivesdk",
          "cachedResultName": "Get Addresses"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Y43YNvASDhLxJg65",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6,
      "alwaysOutputData": true
    },
    {
      "id": "5ea0a567-0a88-4724-acc7-f654930c3ae7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -352
      ],
      "parameters": {
        "width": 896,
        "height": 656,
        "content": "🏢 公司数据增强系统"
      },
      "typeVersion": 1
    },
    {
      "id": "00024d69-8567-4c12-bf92-d54bb5686bd6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        -352
      ],
      "parameters": {
        "color": 5,
        "width": 544,
        "height": 656,
        "content": "🚀 设置检查清单"
      },
      "typeVersion": 1
    },
    {
      "id": "0609a728-9743-4a92-b64d-a63eec993333",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -352
      ],
      "parameters": {
        "color": 4,
        "width": 544,
        "height": 656,
        "content": "📊 输出数据字段"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Fetch Unprocessed Domains",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Save Enriched Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Enriched Data": {
      "main": [
        [
          {
            "node": "Batch Process Domains",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Process Domains": {
      "main": [
        [],
        [
          {
            "node": "Perplexity AI Research",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perplexity AI Research": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Unprocessed Domains": {
      "main": [
        [
          {
            "node": "Batch Process Domains",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量9
分类2
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Naveen Choudhary

Naveen Choudhary

@n8nstein

I create AI-driven n8n workflows that turn repetitive tasks into smooth, hands-off automations. Want to explore an idea? Book a quick consult: https://cal.com/nickchoudhary/30min

外部链接
在 n8n.io 查看

分享此工作流