Table of Contents

How to Create & Update contact in Hubspot

Pau Sanchez Updated by Pau Sanchez

In this article we will explain how you can use Landbot to capture information and store it in Hubspot. And if required, how to update that contact just created using Hubspot API and our Webhook block

Create Contact

  1. Set up questions blocks (name, phone, company)

Each question, will store the user input in a specific variable

it is required that when you create the contact, you should have the user email:

  1. Now we will add the Webhook block, that we will use to create the contact in Hubspot using it's API:

  1. The first thing we need to set up in the Webhook block will be the Method, in this case will be a POST

And after, we will add the URL required for this action:

You can copy from here:

https://api.hubapi.com/contacts/v1/contact/

  1. Now we will add the params settings:

In the Key will be "hapikey"

To get the "hapikey" from your Hubspot account, you should go to your settings Section:

Then select Integration on the left side panel

Select API Key

If is your first time, you might need to create the API Key, otherwise, you just need to copy it:

  1. Now paste the API Key in the params value:

  1. Now we will select to Customize Body of the request

We will add the JSON:

Here is the JSON:

{
"properties": [
{
"property": "email",
"value": "@email"
},
{
"property": "firstname",
"value": "@name"
},
{
"property": "company",
"value": "@company"
}
]
}

As you can see, we map the variables in Landbot that we are storing in the blocks before the webhook, and map them to properties in Hubspot. You can add as many as you need, but bear in mind that such properties must exist in Hubspot.

Also, you will need to match the variable @name with the property "firstname"

And always make this request with the email

  1. We need to make sure everything is set correctly, to do this, we will make a test with some data that we will use to create a contact in Hubspot for testing

Here we fill the variables, with some values:

  1. Press test check response

And the response from this test will be displayed below:

And if we check in Hubspot the test has been successful creating a new contact

  1. And finally if we want later to be able to update such contact with more details, we need to store the id that Hubspot is using, in this case is the "vid" value:

To store such value, we will activate the "Save Responses as Variables" section

Click on the blue dropdown where it says "Entire Response Body":

And finally select the "vid" value:

And finally we will create a variable where to store the vid value, we will call it "vid" and use the number format:

Update contact

We might want to add additional information as we collect it, without the need to wait until the chat is done. In that case, we will add another user input, and another Webhook block.

  1. Add additional questions, in this case we will ask for the phone, and we will store it in the variable @phone

  1. And add the new webhook that will be used to update the contact we created earlier with the phone value

  1. The first thing we need to set up in the Webhook block will be the Method, in this case will be a POST

And after, we will add the URL required for this action:

You can copy from here:

https://api.hubapi.com/contacts/v1/contact/vid/@{vid}/profile

as you can see we are using the variable @vid in the url to identify the contact created earlier

  1. Now we will add the params settings:

In the Key will be "hapikey"

To get the "hapikey" from your Hubspot account, you should go to your settings Section:

Then select Integration on the left side panel

Select API Key

If is your first time, you might need to create the API Key, otherwise, you just need to copy it:

  1. Now paste the API Key in the params value:

  1. Now we will select to Customize Body of the request

We will add the JSON:

Here is the JSON:

{
"properties": [
{
"property": "phone",
"value": "@phone"
}
]
}

As you can see, we map the variables in Landbot that we are storing in the blocks before the webhook, and map them to properties in Hubspot. You can add as many as you need, but bear in mind that such properties must exist in Hubspot.

Also, you will need to match the variable @name with the property "firstname"

And always make this request with the email

  1. We need to make sure everything is set correctly, to do this, we will make a test with some "fake data" that we will use to create a contact in Hubspot

Here we fill the variables, with some values:

  1. Press test check response

And the response from this test will be displayed below:

And if we check in Hubspot the test has been successful updating a new contact

How did we do?

Send contact info to Hubspot CRM

Contact