{
  "name": "Enrich HubSpot companies with Polish CEIDG data using NIP identifiers",
  "nodes": [
    {
      "id": "538bb51e-c5dd-4173-b0ca-a13934985a72",
      "name": "Check if NIP exists",
      "type": "n8n-nodes-base.if",
      "position": [
        128,
        432
      ]
    },
    {
      "id": "6f3002a3-ba7f-43f0-801c-9aac9d30e538",
      "name": "When NIP property changes",
      "type": "n8n-nodes-base.hubspotTrigger",
      "position": [
        -96,
        432
      ]
    },
    {
      "id": "d1ace6e8-5170-4093-94cc-04662969523b",
      "name": "Update company in HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1056,
        304
      ]
    },
    {
      "id": "183aaa16-4d06-44c6-86a0-19b7332bf565",
      "name": "Fetch company data from CEIDG",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        352,
        320
      ]
    },
    {
      "id": "6abd961a-2c92-44dc-96a6-cf094b36e01a",
      "name": "Transform data for HubSpot",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        304
      ]
    },
    {
      "id": "03b138e2-84c9-4fcd-87b3-34e97a639484",
      "name": "Mark error in HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1056,
        896
      ]
    },
    {
      "id": "641f0344-7de8-46de-b7ea-29a67c1b1946",
      "name": "Check if data retrieved",
      "type": "n8n-nodes-base.if",
      "position": [
        576,
        320
      ]
    },
    {
      "id": "52855cc7-4754-4582-b0ef-803f31f9db06",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -64
      ],
      "parameters": {
        "width": 678.2462538708118,
        "height": 1181.1692474064032,
        "content": "## Auto-populate HubSpot company from Polish NIP\n\nThis workflow automatically enriches HubSpot company records with official data from the Polish CEIDG (Central Register and Information on Economic Ac"
      }
    },
    {
      "id": "3104719e-08b1-4a4a-916e-11976d4ea6ed",
      "name": "Step 1: HubSpot Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        80
      ],
      "parameters": {
        "width": 217,
        "height": 525,
        "content": "## Trigger\n\nMonitors HubSpot for changes to the NIP property on company records.\n\nWhen a NIP is added or updated, the workflow starts automatically."
      }
    },
    {
      "id": "a8758064-a305-4d97-9481-406261c56462",
      "name": "Step 2: Validate Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        80
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## Validation\n\nChecks if the NIP field has a value.\n\nIf empty, the workflow ends here to avoid unnecessary API calls."
      }
    },
    {
      "id": "cdcc5ce1-0b8b-4243-817c-fe5521273dad",
      "name": "Step 3: Fetch Data",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -32
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## CEIDG API Query\n\nFetches official company data from the Polish government database.\n\nRequires a free API token from dane.biznes.gov.pl"
      }
    },
    {
      "id": "eb23700a-c13a-4a0b-aadc-374b4558259c",
      "name": "Step 4: Verify Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -32
      ],
      "parameters": {
        "width": 201,
        "height": 525,
        "content": "## Data Verification\n\nChecks if the API returned any company records.\n\nIf count > 0, proceeds to update HubSpot.\nIf count = 0, marks an error."
      }
    },
    {
      "id": "d176a34a-25db-46d9-9605-9111608faf53",
      "name": "Step 5: Map Fields",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -32
      ],
      "parameters": {
        "width": 217,
        "height": 525,
        "content": "## Transform Data\n\nMaps CEIDG API response to HubSpot company properties.\n\nExtracts:\n- Company name\n- Address components\n- Contact details\n- NIP/REGON numbers"
      }
    },
    {
      "id": "97f97f48-e594-4a81-a97f-827434f46ff1",
      "name": "Step 6: Update Success",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        -32
      ],
      "parameters": {
        "width": 265,
        "height": 525,
        "content": "## Success Path\n\nUpdates the HubSpot company record with all enriched data from CEIDG.\n\nIncludes company name, address, phone, website, and notes."
      }
    },
    {
      "id": "5daf227a-3112-4812-9d92-442ec883d08b",
      "name": "Error Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        528
      ],
      "parameters": {
        "width": 265,
        "height": 525,
        "content": "## Error Path\n\nIf NIP is invalid or not found in CEIDG, this node adds a note to the HubSpot company.\n\nHelps identify problematic records."
      }
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}