Last updated: 04 May 2021 

This tutorial guides you through the process of integration HubSpot and using this integration to send leads from your chatbot to your CRM.

The principles behind this specific tutorial can be applied to various other HubSpot integration use cases.

Step 1: Find your HubSpot API key

  1. Log into HubSpot.

  2. Click the cog icon in the top right to reach your Settings.

  3. Using the side-nav, go to IntegrationsAPI Key.

You will find your Active API key in the middle of the page.

To copy it, first click Reveal and pass the Captcha requirements. Then, hit Copy.

Step 2: Integrate HubSpot into the chatbot platform

In your chatbot platform:

Head to IntegrationsIntegrations. Click Add new.

Give your integration a name, for internal purposes.

Find your Base URL

HubSpot offer a vast API with extensive documentation. Depending on the object you’d like to manipulate, you will need to enter a slightly different Base URL. Typically, you will work with

  • The CRM API

  • The CMS API

Because we are sending leads from the chatbot to HubSpot, we will need the CRM API base URL. It contains objects like contacts, deals, companies, and more.

We’re particularly interested in the Contacts object, for which the base URL is https://api.hubapi.com/crm/v3/objects

Need to work with another part of HubSpot API? Visit their API documentation.

Add the Base URL to your integration.

Authorize your integration

There are four authorization methods available inside your chatbot platform. For our HubSpot integration, we will use the API Key authorization.

  1. Pick API Key in the type drop-down.

  2. In the Key field, enter hapikey.

  3. In the Value field, paste the API key you grabbed from your HubSpot account earlier.

  4. In the Add to drop-down, select Body.

Hit Save.

Step 3: Create variables

Now that we have integrated HubSpot, it’s time to think about the value we want to capture from the users.

To generate a lead in HubSpot, at the very least you must capture an email address. We probably want to go a bit further than that and capture:

  • Email address

  • First name

  • Phone number

You are not limited to the three above. You’re free to capture as much information as you need.

In your chatbot platform, go to IntegrationsVariables.

Click Create. Create three variables, one for each of the above.

Make sure you follow the required format: variable or variable_name. No spaces allowed.

Step 4: Create your endpoint

Endpoints allow you to map the values you capture within your chatbots (e.g. a user’s email address or name) to corresponding fields inside HubSpot. Within this endpoint, we will tell exactly which data we want to send from our chatbot to HubSpot.

Go back to IntegrationsIntegrations.

On your newly created HubSpot integration, click Endpoints, then Add new endpoint.

Name your endpoint. Something like 'Submit a lead to HubSpot' will do.

Set up the request

Referring to HubSpot’s API documentation, we know that to create a new contact in our CRM we will need to make a POST request to the /contacts folder.

Select POST in the drop-down and add /contacts to the folder field.

Create the request body

You can write the request using either PARAMS or JSON. For this example, we will use JSON.

In the body is where you map the HubSpot properties with the variables we are collecting.

Write the following request:

{
    "properties": {
        "email": "{{email}}",
        "firstname": "{{name}}",
        "phone": "{{phone}}"
    }
}
CODE

Make sure you enter the variables you’ve created in the {{ }}.

Hit Save.

Step 5: Create your lead generation conversation

Time to wrap it all up.

Let’s create a short conversation where the chatbot will ask a user for their name, email address, and phone number before sending it all to HubSpot.

Go to ChatsBuilder.

Create the conversation

Click Create conversation in the top right. Give your conversation a name, a description, and a trigger of your choice (learn more about triggers).

  1. Create four steps in this conversation, the first three asking for information from the user, the last one thanking the user and firing the integration.

  2. For each step (except the last), click Options and go to Transitions. Under Save variable, pick the variable associated to the step you’re editing (e.g. firstname for the step asking the user for their name).

  3. Hit Save.

Add the integration

At the last step of the conversation, the thank you step, we will fire off the integration.

  1. Click Options on this step.

  2. Go to Integrations.

  3. Click Add integration.

  4. Find your integration and endpoint.

  5. Hit Save.

Congratulations, your chatbot is ready to capture leads and send them to HubSpot!