Skip to content

How You Can Automatically Apply Association Labels in HubSpot Using Zapier

Hi, I'm Ryan Schweighart, founder of Whole Hart Impact, where I help businesses grow leveraging HubSpot and Zapier. Today's WHInsight is inspired by common questions in the HubSpot and Zapier communities about automatically applying association labels. While this can be done within HubSpot workflows, today we'll focus on how to do this within Zapier.

 

Steps to Apply Association Labels

  1. Setup Association Labels in HubSpot:

    • Go to Settings > Objects.
    • Create a contact to company association label (e.g., "Billing Contact").
    • Create a contact to deal association label.
  2. Create a Webhook in HubSpot:

    • Go to Settings > Integrations > Private Apps.
    • Create or use an existing private app.
    • Go to the Webhooks tab and create a subscription for when an association changes, accepting the scope updates.
  3. Setup Zapier:

    • In Zapier, create a new Zap with the trigger step set to Webhook.
    • Select Catch Hook as the event and copy the provided URL.
    • Paste this URL as the target URL for your private app in HubSpot.
  4. Filter and Process Data in Zapier:

    • Add a filter step to only trigger when a company is associated with a deal.
    • Use an API request step to get detailed information about the association, including labels.
    • Use a Code by Zapier step to extract the contact with the "Billing Contact" label from the webhook response. Here's the code I used from step 4 of the video:
      • // Parse the response_body from the input data to a JSON object const response = JSON.parse(inputData.response_body);

        // Initialize a variable to store the toObjectId let toObjectId;

        // Loop through the results array in the response object
        for (let i = 0; i < response.results.length; i++) {
          // Check if the label in the associationTypes array matches "Billing Contact"
          if (response.results[i].associationTypes[1].label === "Billing Contact") {
            // If it does, assign the corresponding toObjectId to the toObjectId variable
            toObjectId = response.results[i].toObjectId;
            // Break the loop as we have found the toObjectId we need
            break;
          }
        }

        // Assign the toObjectId to the output object output = { toObjectId };

  5. Create the Association in HubSpot:
    • In Zapier, add a step to create the association in HubSpot, mapping the contact and deal IDs, and applying the "Billing Contact" label.

Example Workflow

  1. Setup Association Labels:

    • In HubSpot, create the necessary association labels for contacts to companies and contacts to deals.
  2. Create a Webhook:

    • Configure a private app in HubSpot to send data when associations change.
  3. Configure Zapier:

    • Use the provided webhook URL in your private app.
    • Add a filter to only trigger on relevant associations.
    • Extract necessary details using a code step.
  4. Apply Association Labels:

    • Use the extracted data to create the desired associations in HubSpot.

Troubleshooting

If you encounter any issues, ensure that:

  • Association labels are correctly set up.
  • Webhook URL is correctly configured.
  • Filters in Zapier are correctly set to trigger only on desired events.

Conclusion

Automating the application of association labels in HubSpot using Zapier can streamline your workflow and ensure consistent data management. If you have any questions or need further assistance, feel free to comment below or contact me directly. If you want more content on HubSpot and Zapier, let me know, and I'll create more guides.

Happy WHImpacting and bye for now!