Neighbourhood | HubSpot Hacks

Creating Records from Webhooks

Written by Sophie Costello | Oct 17, 2024 1:03:26 AM

Why is this hack helpful?

Note: Operations Hub Pro or Enterprise subscriptions required

If you're not a full-fledged developer but still want to connect HubSpot to another platform, webhooks are your best friend.

As long as the other system allows you to push data via webhook, you can instantly transfer data or trigger other actions via workflows in HubSpot, with one big exception - because workflows are centred on a specific record (i.e a Contact enrols in a Contact workflow, a Deal enrols in a Deal workflow), the webhook can’t trigger a workflow if the record doesn’t already exist - so a new contact in one system won’t create a new one in HubSpot without getting a little creative.

Let's get into it!

Solution

Depending on the action you’re trying to take and what data you’re able to get from the webhook, you can get around this limitation using another object type to create the contact (or other record). 

Scenario

We needed to create or update a contact in HubSpot when they were created or updated in another system (a clinic management system, in our case).

We used Companies as the trigger object, as this wasn’t often in use in this HubSpot portal, but it could be any object you have available, like tickets or contacts.

Importantly, you’ll need one of the data points in the webhook payload to be the same each time - in our scenario, we had a data point called “EventType”, which is always “ContactUpdated” for this specific webhook.

Once you know which data point will be consistently the same, create a property on the object you’ll be using, and make sure you set it as a Unique Value property.

In our case, we created a Company property called “Webhook Trigger”.

- Once your property is created, create a new record and set the unique value to whichever data point will be coming through from the webhook (so in our case, we created a Company and set the “Webhook Trigger” property to “ContactUpdated”).

With this done, you’re ready to set up a workflow that will create the Contact record.

Create the Company (or other object) record and use ‘webhook trigger’ as the enrollment type. 

Set up the webhook, and connect the relevant data point to your unique identifier property. 

Once your webhook is connected, add an action to create a contact record, and copy the relevant data points from your webhook into whichever properties are required.

You’ll also need to create a contact workflow for when contacts do exist in HubSpot, and connect this to the webhook to update the relevant contact properties as needed.

A single event will trigger both the company and contact workflows, but the company workflow won’t create a new contact if one already exists with the same email address, so you won’t end up with duplicates.

Based on some of the properties updated or set by the webhook, we then triggered another workflow to create a deal from the contact - but you can expand on this as needed to fit your processes.

 

Note: Webhook trigger frequency

As we’re using a single object record and continuously re-enrolling it in the same workflow, you’ll run into issues if the webhook is triggered too frequently. For best results, you won’t want the same webhook to fire more than once a minute, as the record has to finish the workflow before it can re-enrol from a new webhook trigger.

In our scenario, we discovered in testing that the webhook was sometimes triggered multiple times at once, from various users of their other system. To combat this, we ended up using another data point “ClinicName” as our unique identifier, which allowed us to split the workflow enrolments across a few more records. There were 6 possible options for the ClinicName field, and so we created a new Company record for each one, adding the relevant clinic name into the unique “Webhook Trigger” property.

This solved the problem for us, though you could also duplicate your company workflow with other filters if you find things are still being bottlenecked and need to split it up further.

 

With this setup, your data will flow smoothly, and you'll be the integration hero—no cape required!