N8N

N8N Hubspot

In this guide, we will walk you through two different approaches on how you can use Hubspot with N8N. These were inspired by a recent customer who wanted to have data from SQL reports populate custom fields within hubspot.

If you need any help with N8N workflows, I’m taking on customers.

Simple Hubspot Workflow

Before we jump into this one, the image above is missing the trigger for the workflow (since it is not being used). 

Let’s start with the data we want to send to hubspot. For this usecase I’m grabbing data from a metabase question that I wrote in SQL. The original data was from BigQuery. It’s also quite easy to grab in data from Google Sheets, Airtable, or a CSV (if you need to go the manual route).

From there we want to set up a loop. Unfortunately you cannot bulk update contacts in Hubspot (same with deals and companies). So we are limited in N8N  to one at a time. The next workflow will show you how to send up to 100 at a time.

This loop looks at one row at a time and sends that data into the create or update a contact Hubspot Node.

You’ll want to setup new credentials for Hubspot, but it won’t take long. All you need to do is login with your account that is attatched to your Hubspot account.

In N8N the main way you connect to a contact is through the email. This is different then when we will be using the official api documentation!

I won’t show all the properties I connected to for privacy reason, but drag and drop in the property names and the associated values.

This workflow is nice if you do not have a ton of contacts, but once you scale past a couple hundred, it takes forever. The better approach is to use the advanced workflow down below.

Advanced Hubspot Workflow

Now let’s look at the better way to approach updating contacts.

This involves setting up a private app in your hubspot account and using an Http Request and code node.

Also to note! The one above uses Email to link contacts in Hubspot. The one below uses the hubspot contact id. Small difference, but you will have issues if you do not use the contact id.

Let’s first setup a private app. Go to your hubspot dashboard and click the gear icon. Go to account management.

Under integrations click the drop down and go to private app. Click on create a private app.

Name your app in Basic info. Under scopes fill in all the scopes listed in this N8N article at the bottom

Once this is completed, you will have an app token. Save that as we will use it shortly

Advanced Hubspot N8N Workflow

Since I want this workflow to either start manually or on a specified time, I’ll set up two different trigger.

Then I pull the data from the SQL query in metabase.

Hubspot has a contact update rate limit of 100 per 10 seconds. What I’ll do is grab 100 rows at a time and we will loop. Above we only did 1 so this is already way more efficient.

To format the rows so they are in JSON Hubspot requires, I’ll then go through a Code node. I write my code in Python, but you can do this in Javascript if needed.

For the HTTP Request, fill out the following settings. In the Hubspot App Token, set up the credential and paste in the private key from earlier.

To work with the HubSpot rate limits, set a wait trigger after the Http Request. I used 2 seconds since the Python code + loop will take a few seconds to run each time.

Final Thoughts

That’s how you can update HubSpot contacts in N8N. Sadly the nodes only offer basic opportunities, so you’ll have to go through an Http Request. Hopefully this guide was able to help save you time setting this up. 

Check out our other N8N content and reach out if you need any help with N8N Automations!

Leave a Reply

Your email address will not be published. Required fields are marked *