Historical Challenges:
Working with HubSpot Custom Objects and Zapier has posed unique challenges that differ from the seamless integration experienced with standard HubSpot objects. This distinction has been a recurring source of frustration for developers and data integrators alike.
Custom Objects in HubSpot have historically presented hurdles when it comes to integration. Unlike their standard counterparts, they require a more specialized approach. Developers often encountered limitations in bridging the gap between Standard Objects and Custom Objects, making data synchronization a complex task
A Solution Emerges:
By harnessing the capabilities of the HubSpot CRM Custom Object API in tandem with Zapier Webhooks, it has become easier than ever to navigate these hurdles.
Sample Solution: Creating HubSpot Custom Object Associations with Zapier Webhooks
Goal:
Automatically associate a Contact with a “Metro Area” Custom Object using Zip Code. While this example uses the Contact Object, it can be applied to any HubSpot Standard Object as well.
Prerequisites:
The Custom Object must have a Property with a Unique Value in order to search by the alternative ID in the query parameter. In this example, the “Metro Area” Custom Object uses Zip Code as its unique ID, which we’ll use to match with Contact’s Zip Code.
Required Data:
- You will need to find the “objectId” of your Custom Object. You can find this in HubSpot > Settings > Objects > Custom Objects -- select the object you’re working with. The objectId will be in the URL of the page you’re viewing.
- 'https://app.hubspot.com/sales-products-settings/your_account_id/object/2-19643068
Your objectId will be different than above, but we’ll use this for examples below.
- 'https://app.hubspot.com/sales-products-settings/your_account_id/object/2-19643068
- You will need to create a HubSpot Private App with the needed Scopes. You can find this in HubSpot > Settings > Integrations > Private Apps.
- This will be needed in every Webhook step below - {{private_app_key}}
Step-by-Step Workflow:
- Trigger: In this example, a Contact-based Active List in HubSpot is used as the Zap Trigger. We will also retrieve the Zip Code property value in this step.
- Contact Zip Code token will be used below in Step 3
- Contact Zip Code token will be used below in Step 3
- Filter Validation: A Filter step is introduced to ensure the validity of the Contact Property selected. This step is also used to avoid unnecessary Zap Task Usage.
- Custom Object Lookup: The process uses a GET Webhook to search for the matching Custom Object. It identifies the Custom Object by using the Contact’s Zip Code from Step 1 in the query parameter to match the records.
-
GET in Webhooks by Zapier - Find Custom Object
-
URL: https://api.hubapi.com/crm/v3/objects/2-19643068/{{id_token_previous_step_1}}
-
Query String Params
archived: false
this is not a variableidProperty: zip_code
this is the internal name of property to search (to match value of this property above in the URL {{id_token_previous_step_1}} -
Headers
Authorization: Bearer {{private_app_key}}
-
-
RESULT = Property Values for the Custom Object, most importantly the {{hs_object_id}} that will be required in Step 5
-
- Association Labels Retrieval: Another GET Webhook is utilized to retrieve the Association Labels for the Custom Object. These association Category and IDs are essential for the final step of creating associations.
-
GET in Webhooks by Zapier - Read Association Labels
-
URL: https://api.hubapi.com/crm/v4/associations/2-19643068/contact/labels
Headers
Authorization: Bearer {{private_app_key}}
-
- RESULT = Property Values for the Association Category and Type, that will be required in Step 5
-
- Create Associations: Finally, a PUT Webhook is employed to establish the association between the Contact and the Custom Object. This step completes the integration, ensuring that the two entities are linked within HubSpot.
- PUT in Webhooks by Zapier - Create Association
URL: https://api.hubapi.com/crm/v4/objects/contact/{{hs_object_id_token_previous_step_1}}/associations/default/2-19643068/{{ id_token_previous_step_3 }} -
Payload Type = json
-
Data
associationCategory : {{Category from Step 4 above}}
associationTypeId: {{Results Type Id from Step 4 above}}
Headers
Authorization: Bearer {{private_app_key}}
content-type: application/json
- PUT in Webhooks by Zapier - Create Association