{
  "id": "cVd6mI56A2ruupJ7",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Enrich Hubspot Companies",
  "tags": [],
  "nodes": [
    {
      "id": "841f4da5-7a5f-4d54-ac48-4c37d7437beb",
      "name": "Hubspot - Company - Enrichment request",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -16,
        0
      ],
      "parameters": {
        "path": "b5e3e64f-f57a-4d08-8631-9bc61416193d",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "483ba532-1775-42b8-95c3-189170052ebf",
      "name": "Get TEST Company Data",
      "type": "n8n-nodes-base.hubspot",
      "onError": "continueErrorOutput",
      "position": [
        496,
        32
      ],
      "parameters": {
        "resource": "company",
        "companyId": {
          "__rl": true,
          "mode": "list",
          "value": 7611838964,
          "cachedResultName": "TEST COMPANY"
        },
        "operation": "get",
        "authentication": "oAuth2",
        "additionalFields": {}
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": false
    },
    {
      "id": "87781cab-5d7a-46b8-af7f-20efddf33236",
      "name": "Is TEST Mode?",
      "type": "n8n-nodes-base.if",
      "position": [
        496,
        -112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c3ddf742-0db2-42c2-a021-220636a7215a",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body[0].objectId }}",
              "rightValue": 123
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9600d2e3-d397-4f2f-aa1f-3937055d0420",
      "name": "Validate Incoming Data",
      "type": "n8n-nodes-base.if",
      "position": [
        240,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "547f3272-86e1-4d04-9182-4aa05d5aacdf",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ !!$json.body[0].objectId }}",
              "rightValue": ""
            },
            {
              "id": "1143d9d4-385c-4fc9-98ba-a5a454e2b7ef",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body[0].portalId }}",
              "rightValue": 139601726
            },
            {
              "id": "21398e1b-dd3f-47ec-bea0-3b5ebe2a34e3",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body[0].subscriptionType }}",
              "rightValue": "company.propertyChange"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ad1b73d5-bd6f-4207-b18d-c2cfb3e73834",
      "name": "Enrich company data",
      "type": "@bedrijfsdatanl/n8n-nodes-bedrijfsdata.bedrijfsdata",
      "onError": "continueErrorOutput",
      "position": [
        1184,
        32
      ],
      "parameters": {
        "url": "={{ $json.properties.domain.value }}",
        "city": "={{ $json.properties.city.value}}",
        "name": "={{ $json.properties.name.value }}",
        "details": true,
        "resource": "enrich",
        "requestOptions": {}
      },
      "credentials": {
        "bedrijfsdataApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "53635275-968e-4f70-81ab-b67c4064b1fb",
      "name": "Has Known Bedrijfsdata ID",
      "type": "n8n-nodes-base.if",
      "position": [
        960,
        32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a2b1940e-eebd-4337-b5c6-2d1f3a8cba4e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ !!$json.properties.prospectpro_id.value && $json.properties.prospectpro_id.value !== '' }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0c370c1f-7e68-48f5-aa10-c004c619c74e",
      "name": "Get company",
      "type": "@bedrijfsdatanl/n8n-nodes-bedrijfsdata.bedrijfsdata",
      "onError": "continueErrorOutput",
      "position": [
        1184,
        -304
      ],
      "parameters": {
        "id": "={{ $json.properties.prospectpro_id.value }}",
        "details": true,
        "operation": "get",
        "requestOptions": {}
      },
      "credentials": {
        "bedrijfsdataApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "cc4a6457-d12f-48d7-b0b7-deffcdf281a8",
      "name": "Update a company",
      "type": "n8n-nodes-base.hubspot",
      "onError": "continueErrorOutput",
      "position": [
        1936,
        16
      ],
      "parameters": {
        "resource": "company",
        "companyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Hubspot - Company - Enrichment request').first().json.body[0].objectId !== 123 ? $('Hubspot - Company - Enrichment request').first().json.body[0].objectId : $('Get TEST Company Data').first().json.companyId }}"
        },
        "operation": "update",
        "updateFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "value": "={{ $json.id }}",
                "property": "prospectpro_id"
              },
              {
                "value": "={{ $json.coc }}",
                "property": "kvk"
              },
              {
                "value": "={{ Array.isArray($json.linkedin_link) ?$json.linkedin_link[0] : $json.linkedin_link }}",
                "property": "linkedin_link"
              }
            ]
          }
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8a39e467-3b25-4e5c-9821-2bcb748d9c7a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -448
      ],
      "parameters": {
        "color": 2,
        "height": 640,
        "content": "## Hubspot Trigger\nAs the Hubspot's n8n trigger requires setting up a developer account and creating a public app, it's often easier to use n8n's Webhook Trigger. This allows you to use a [Hubspot private app](https://developers.hubspot.com/docs/guides/apps/private-apps/overview) instead. After creating a private app, [add the n8n webhook](https://developers.hubspot.com/docs/guides/apps/private-apps/create-and-edit-webhook-subscriptions-in-private-apps) and make sure it subscribes to **company.propertyChange** events.\n\n**Check out** the screenshots (left bottom) for details on the required Hubspot Private App setup."
      },
      "typeVersion": 1
    },
    {
      "id": "8becaa25-6fdd-4e75-ae7b-6786b962fb3e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -448
      ],
      "parameters": {
        "color": 4,
        "height": 640,
        "content": "## Event filtering & security\nAs Hubspot private apps allow you to listen for an array of events, you need to make sure this workflow only runs on to appropriate events.\n\nAdditionally, you need to ensure a Hubspot Company ID is provided.\n\n**Extra:** as your n8n webhook is publicly available, you may want to add an additional check for the correct Hubspot Portal ID as an layer of protection."
      },
      "typeVersion": 1
    },
    {
      "id": "30b20d79-d54e-4a87-a6d6-51c2e9458b09",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -448
      ],
      "parameters": {
        "color": 6,
        "height": 640,
        "content": "## Testing your webhook in Hubspot\nWhen testing your connection between Hubspot and n8n, Hubspot will provide a non-existing Company ID. As you need an existing ID to test your workflow properly, we've added an extra step to filter this scenario and select a test-company of your choosing."
      },
      "typeVersion": 1
    },
    {
      "id": "2f48cf70-93da-40d4-93da-56c31229bd0d",
      "name": "Get Company Data",
      "type": "n8n-nodes-base.hubspot",
      "onError": "continueErrorOutput",
      "position": [
        768,
        -96
      ],
      "parameters": {
        "resource": "company",
        "companyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.body[0].objectId }}"
        },
        "operation": "get",
        "authentication": "oAuth2",
        "additionalFields": {}
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": false
    },
    {
      "id": "91ff90e3-bfd8-47f5-9277-37faf941d595",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -448
      ],
      "parameters": {
        "width": 432,
        "height": 640,
        "content": "## Select the appropriate sub-flow \nBedrijfsdata.nl has multiple options for retrieving company information. When we need to retrieve a specific company, we have two options:\n\n1. Search by Bedrijfsdata.nl ID (Get company)\n2. Let Bedrijfsdata.nl retrieve the appropriate profile based on available data (Enrich company data)\n\n\nAs your CRM may contain limited data, as well as typo's, it's always best to retrieve company data by ID. As this is not provided by Hubspot when the webhook is called, we need to retrieve this data from Hubspot separately.\n\n**Note:** As the Bedrijfsdata ID is set by this workflow, it will always be available in a second updating cycle."
      },
      "typeVersion": 1
    },
    {
      "id": "4cb536da-e973-4bcc-9541-f9b4631f4805",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -448
      ],
      "parameters": {
        "color": 5,
        "width": 704,
        "height": 304,
        "content": "## Retrieve company data by Bedrijfsdata.nl ID\nBedrijfsdata.nl ID's are persistent and should always be stored wherever you save our data (for updating purposes). In addition to our API's, such ID's can be obtained when purchasing a dataset from our website or by using [ProspectPro](https://www.prospectpro.nl) (our B2B prospecting software)."
      },
      "typeVersion": 1
    },
    {
      "id": "652beaaf-b397-47ab-a38f-5e58bdca30eb",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 704,
        "height": 320,
        "content": "## Retrieve company data by whatever information you have available in Hubspot\nOur advanced matching algoritmes can retrieve the appropriate company profiles by a combination of company names, websites, cities, and more. Simply provide whatever you have and let us do the heavy lifting."
      },
      "typeVersion": 1
    },
    {
      "id": "2fa753b1-6c5a-49b8-ac41-2ae26f5446cb",
      "name": "If the company profile is found..",
      "type": "n8n-nodes-base.if",
      "position": [
        1440,
        -320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "56f2c326-40f7-4130-be1d-63731bd437c5",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.total }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4920639e-4353-49dd-93e2-e2e19c82f741",
      "name": "If your data can be matched..",
      "type": "n8n-nodes-base.if",
      "position": [
        1440,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6de0a669-92b2-436f-a80f-32070367fda7",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{$json.found}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "23c4d33b-a20f-46ff-98c7-78a1f5c231a2",
      "name": "Output only the best match",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        -336
      ],
      "parameters": {
        "jsCode": "const input = items[0].json;\nconst firstCompany = input.companies?.[0];\n\nreturn [\n  {\n    json: firstCompany\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "ac8c797e-0dc5-4f7c-9bf0-96e57943e606",
      "name": "Reformat for processing",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        0
      ],
      "parameters": {
        "jsCode": "const input = items[0].json;\nconst company = input.company;\n\nreturn [\n  {\n    json: company\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "666fcb21-9f42-4b69-94ad-086bef496bdf",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1856,
        -448
      ],
      "parameters": {
        "color": 2,
        "height": 640,
        "content": "## Update in Hubspot\nNow it's time to map whatever data you need from our company profiles to the fields you want to put them in in Hubspot.\n\n**Please note** we have dozens of data points available. Check our [documentation](https://docs.bedrijfsdata.nl) for more information."
      },
      "typeVersion": 1
    },
    {
      "id": "f922001d-9efa-4a09-aed6-761376589633",
      "name": "Error type 1: Invalid request from Hubspot",
      "type": "n8n-nodes-base.noOp",
      "position": [
        496,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3472ce79-ef9b-4820-b521-dd858a44425d",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        320
      ],
      "parameters": {
        "color": 3,
        "width": 2432,
        "height": 192,
        "content": "## Error handling\nPlease always handle potential errors properly.\n\n**For example**: log in Google Sheet, send Slack/Telegram/email notification."
      },
      "typeVersion": 1
    },
    {
      "id": "659f5b89-eb7f-48c7-94c1-96c8a02e7d6e",
      "name": "Error type 3: Bedrijfsdata.nl API (like insufficient credits)",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1440,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "accd448b-f196-49d4-a26e-c026a77c6797",
      "name": "Error type 4 - No company found",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1680,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "277d506a-65b3-4e38-af64-6f9e471d9fc9",
      "name": "Error type 2 - Hubspot error",
      "type": "n8n-nodes-base.noOp",
      "position": [
        960,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "61154913-14ac-4924-a5ab-5c685c3fb242",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        -448
      ],
      "parameters": {
        "color": 7,
        "height": 640,
        "content": "## Enrichment completed!\n**Optionally** create a log or trigger another workflow (like searching for decision makers, scraping website data, creating a task or composing outreach messages)"
      },
      "typeVersion": 1
    },
    {
      "id": "9a9521c9-8ce2-4897-b5e3-1783a8185c4d",
      "name": "Do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2176,
        16
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "03389ade-eb32-4515-983e-20724790ad8d",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        -448
      ],
      "parameters": {
        "width": 896,
        "height": 704,
        "content": "## Template: Enrich Company Records in Hubspot with the Bedrijfsdata.nl API\nBedrijfsdata.nl Developers Platform: https://developers.bedrijfsdata.nl\nBedrijfsdata.nl API docs: https://www.bedrijfsdata.nl\n\n### Before enrichment:\n![Before enrichment](https://www.bedrijfsdata.nl/wp-content/uploads/2025/07/Schermafbeelding-2025-07-28-om-13.00.55.png#full-width)\n\n### After (minimal) enrichment:\n![Before enrichment](https://www.bedrijfsdata.nl/wp-content/uploads/2025/07/Schermafbeelding-2025-07-28-om-13.03.47.png#full-width)\n\n**Please note** this is merely example data, there's much, much more available."
      },
      "typeVersion": 1
    },
    {
      "id": "bb61107e-6517-4db8-a3c6-1d15131b8312",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        288
      ],
      "parameters": {
        "color": 2,
        "width": 896,
        "height": 1120,
        "content": "## Hubspot Private App Setup\n\n### 1. Scopes:\n![Before enrichment](https://www.bedrijfsdata.nl/wp-content/uploads/2025/07/Schermafbeelding-2025-07-28-om-13.40.55.png#full-width)\n\n### 2. Webhook & Events:\n![Before enrichment](https://www.bedrijfsdata.nl/wp-content/uploads/2025/07/Schermafbeelding-2025-07-28-om-13.41.09.png)\n\n**Please note** you'll need to customize the actual event that triggers your workflow. Listening for updates on the \"domain\" field is great for triggering enrichment upon record creation, but you'll need a custom trigger if you want to enrich, for example, periodically."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5acfcff5-ceef-4bb6-9e9e-45bec211b4c6",
  "connections": {
    "Get company": {
      "main": [
        [
          {
            "node": "If the company profile is found..",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 3: Bedrijfsdata.nl API (like insufficient credits)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is TEST Mode?": {
      "main": [
        [
          {
            "node": "Get TEST Company Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Company Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Company Data": {
      "main": [
        [
          {
            "node": "Has Known Bedrijfsdata ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 2 - Hubspot error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a company": {
      "main": [
        [
          {
            "node": "Do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 2 - Hubspot error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich company data": {
      "main": [
        [
          {
            "node": "If your data can be matched..",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 3: Bedrijfsdata.nl API (like insufficient credits)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get TEST Company Data": {
      "main": [
        [
          {
            "node": "Has Known Bedrijfsdata ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 2 - Hubspot error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Incoming Data": {
      "main": [
        [
          {
            "node": "Is TEST Mode?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 1: Invalid request from Hubspot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reformat for processing": {
      "main": [
        [
          {
            "node": "Update a company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Known Bedrijfsdata ID": {
      "main": [
        [
          {
            "node": "Get company",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enrich company data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Output only the best match": {
      "main": [
        [
          {
            "node": "Update a company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If your data can be matched..": {
      "main": [
        [
          {
            "node": "Reformat for processing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 4 - No company found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If the company profile is found..": {
      "main": [
        [
          {
            "node": "Output only the best match",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error type 4 - No company found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hubspot - Company - Enrichment request": {
      "main": [
        [
          {
            "node": "Validate Incoming Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}