8
n8n 中文网amn8n.com

根据波兰NIP自动填充HubSpot公司

中级

这是一个Lead Generation领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Hubspot, HttpRequest, HubspotTrigger 等节点。 使用NIP标识符通过波兰CEIDG数据丰富HubSpot公司信息

前置要求
  • HubSpot API Key
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "KifsNxjgoHTGzDxt",
  "meta": {
    "instanceId": "a244e08ca65e768d1cee097a486ef066f1968b077e055f21a34efe4e78c40e76"
  },
  "name": "根据波兰 NIP 自动填充 HubSpot 公司",
  "tags": [
    {
      "id": "AOZlNztgqiOQKd6j",
      "name": "n8n Creators",
      "createdAt": "2025-09-28T11:02:15.227Z",
      "updatedAt": "2025-09-28T11:02:15.227Z"
    }
  ],
  "nodes": [
    {
      "id": "538bb51e-c5dd-4173-b0ca-a13934985a72",
      "name": "检查 NIP 是否存在",
      "type": "n8n-nodes-base.if",
      "position": [
        128,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.propertyValue }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6f3002a3-ba7f-43f0-801c-9aac9d30e538",
      "name": "当 NIP 属性更改时",
      "type": "n8n-nodes-base.hubspotTrigger",
      "position": [
        -96,
        432
      ],
      "webhookId": "7a4af938-f0f4-49cb-84f1-de35a042d791",
      "parameters": {
        "eventsUi": {
          "eventValues": [
            {
              "name": "company.propertyChange",
              "property": "nip"
            }
          ]
        },
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "d1ace6e8-5170-4093-94cc-04662969523b",
      "name": "在 HubSpot 中更新公司",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1056,
        304
      ],
      "parameters": {
        "resource": "company",
        "companyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Check if NIP exists').item.json.companyId }}"
        },
        "operation": "update",
        "updateFields": {
          "city": "={{ $json.properties.city }}",
          "name": "={{ $json.properties.name }}",
          "postalCode": "={{ $json.properties.zip }}",
          "websiteUrl": "={{ $json.properties.website }}",
          "phoneNumber": "={{ $json.properties.phone }}",
          "stateRegion": "={{ $json.properties.state }}",
          "countryRegion": "={{ $json.properties.country }}",
          "streetAddress": "={{ $json.properties.address }}",
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "value": "={{ $json.properties.description }}",
                "property": "ceidg_notes"
              }
            ]
          }
        },
        "authentication": "appToken"
      },
      "typeVersion": 2.2
    },
    {
      "id": "183aaa16-4d06-44c6-86a0-19b7332bf565",
      "name": "从 CEIDG 获取公司数据",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        352,
        320
      ],
      "parameters": {
        "url": "=https://dane.biznes.gov.pl/api/ceidg/v3/firmy",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "nip",
              "value": "={{ $json.propertyValue }}"
            }
          ]
        },
        "nodeCredentialType": "httpBearerAuth"
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "6abd961a-2c92-44dc-96a6-cf094b36e01a",
      "name": "为 HubSpot 转换数据",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        304
      ],
      "parameters": {
        "jsCode": "// Input: single item from \"Fetch company data from CEIDG\" node (CEIDG v3 API)\n// Structure: { firmy: [ { nazwa, adresDzialalnosci:{...}, wlasciciel:{ nip, regon }, ... } ], ... }\n\nconst data = $input.item.json;\n\n// Validation\nif (!data || !Array.isArray(data.firmy) || data.firmy.length === 0) {\n  throw new Error('No company found in CEIDG response');\n}\n\n// First company from the list\nconst company = data.firmy[0];\n\n// Get companyId from HubSpot Trigger\nconst hubspotPayload = $item(0).$node[\"When NIP property changes\"].json;\nconst companyId = hubspotPayload.companyid || hubspotPayload.objectId;\n\n// CEIDG v3: address is in \"adresDzialalnosci\"\nconst addr = company.adresDzialalnosci || {};\n\nconst street = [\n  addr.ulica,\n  addr.budynek,\n  addr.lokal ? `/${addr.lokal}` : ''\n]\n.filter(Boolean)\n.join(' ');\n\n// Owner → NIP/REGON\nconst owner = company.wlasciciel || {};\nconst nip = owner.nip || '';\nconst regon = owner.regon || '';\n\n// Return format ready for HubSpot Company → Update\nreturn {\n  json: {\n    companyId: companyId,\n    properties: {\n      name: company.nazwa || '',\n      address: street || '',\n      city: addr.miasto || '',\n      zip: addr.kod || '',\n      state: addr.wojewodztwo || '',\n      country: 'Poland',\n      phone: company.telefon || '',\n      website: company.www || '',\n      description: `Auto-populated from CEIDG. NIP: ${nip || '—'}, REGON: ${regon || '—'}. Start: ${company.dataRozpoczecia || 'N/A'}`,\n    },\n  },\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "03b138e2-84c9-4fcd-87b3-34e97a639484",
      "name": "在 HubSpot 中标记错误",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1056,
        896
      ],
      "parameters": {
        "resource": "company",
        "companyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Check if NIP exists').item.json.companyId }}"
        },
        "operation": "update",
        "updateFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "value": "=Invalid NIP / No data found in CEIDG database",
                "property": "ceidg_notes"
              }
            ]
          }
        },
        "authentication": "appToken"
      },
      "typeVersion": 2.2
    },
    {
      "id": "641f0344-7de8-46de-b7ea-29a67c1b1946",
      "name": "检查是否已检索数据",
      "type": "n8n-nodes-base.if",
      "position": [
        576,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "05aca5e7-3131-4e58-9e38-a5caa08f93a9",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.count }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "52855cc7-4754-4582-b0ef-803f31f9db06",
      "name": "工作流描述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -64
      ],
      "parameters": {
        "color": 4,
        "width": 678.2462538708118,
        "height": 1181.1692474064032,
        "content": "## 根据波兰 NIP 自动填充 HubSpot 公司"
      },
      "typeVersion": 1
    },
    {
      "id": "3104719e-08b1-4a4a-916e-11976d4ea6ed",
      "name": "步骤 1:HubSpot 触发器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        80
      ],
      "parameters": {
        "width": 217,
        "height": 525,
        "content": "## 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "a8758064-a305-4d97-9481-406261c56462",
      "name": "步骤 2:验证输入",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        80
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## 验证"
      },
      "typeVersion": 1
    },
    {
      "id": "cdcc5ce1-0b8b-4243-817c-fe5521273dad",
      "name": "步骤 3:获取数据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -32
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## CEIDG API 查询"
      },
      "typeVersion": 1
    },
    {
      "id": "eb23700a-c13a-4a0b-aadc-374b4558259c",
      "name": "步骤 4:验证响应",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -32
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## 数据验证"
      },
      "typeVersion": 1
    },
    {
      "id": "d176a34a-25db-46d9-9605-9111608faf53",
      "name": "步骤 5:映射字段",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -32
      ],
      "parameters": {
        "width": 217,
        "height": 525,
        "content": "## 转换数据"
      },
      "typeVersion": 1
    },
    {
      "id": "97f97f48-e594-4a81-a97f-827434f46ff1",
      "name": "步骤 6:更新成功",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        -32
      ],
      "parameters": {
        "width": 265,
        "height": 525,
        "content": "## 成功路径"
      },
      "typeVersion": 1
    },
    {
      "id": "5daf227a-3112-4812-9d92-442ec883d08b",
      "name": "错误处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        528
      ],
      "parameters": {
        "width": 265,
        "height": 525,
        "content": "## 错误路径"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5599e99c-c3b9-4cc1-97a8-0af7dee05ac0",
  "connections": {
    "Check if NIP exists": {
      "main": [
        [
          {
            "node": "Fetch company data from CEIDG",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark error in HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if data retrieved": {
      "main": [
        [
          {
            "node": "Transform data for HubSpot",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark error in HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When NIP property changes": {
      "main": [
        [
          {
            "node": "Check if NIP exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform data for HubSpot": {
      "main": [
        [
          {
            "node": "Update company in HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch company data from CEIDG": {
      "main": [
        [
          {
            "node": "Check if data retrieved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 潜在客户开发

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流