# Hubspot

{% hint style="success" %}
**Available for:** Preference Management Platform (PMP)&#x20;

**Premium Feature:** Hubspot
{% endhint %}

Didomi allows you to synchronize your Hubspot contact properties with the preferences collected through Didomi consent events.

{% hint style="info" %}
Alternatively, the Hubspot integration can be performed directly from the Didomi console for the Preference Management Platform (PMP).&#x20;
{% endhint %}

## Implementation

### Connection

Didomi connects to your Hubspot account through the Didomi Hubspot App. By installing the app and configuring the integration, you allow Didomi to update your Hubspot contact properties every time users change their preferences through the Didomi Platform.

{% hint style="warning" %}
**Note**: In order to ensure that events are received, Didomi will retry at least five times in the span of five minutes before moving on when your endpoint is down.
{% endhint %}

#### Didomi Hubspot App

To get started using the Didomi Hubspot App, you can follow these steps:

1. Go through the [Installation link](https://app.hubspot.com/oauth/authorize?client_id=8fd3d564-ea29-4506-98ed-2acf07dd2756\&redirect_uri=https://www.didomi.io/fr/\&scope=crm.objects.contacts.read%20crm.objects.contacts.write%20crm.schemas.contacts.read%20crm.schemas.contacts.write) and grant access to the Didomi App on the Hubspot account you'd like to link with Didomi. This will grant access to Didomi to update your contacts as well as react to contact updates.
2. After the installation, you'll be redirected to <https://didomi.io>. The redirected link will contain a `code` parameter. This is the `authorization_code` to send as a configuration item on the following section.

{% hint style="info" %}
The `authorization_code` expires within 1 hour. Please make sure [the configuration ](#configuration)of your Hubspot integration is done before the code expiration.
{% endhint %}

### Options

#### **Upsert mode**

You can choose allowing Didomi to create contacts in Hubspot, by setting `upsert_mode` to true. Otherwise, when a consent is collected but the `organization_user_id` value does not match with any contact in Hubspot, the consent update will not be propagated to Hubspot.

#### Bidirectional flow

Didomi also supports a bidirectional flow by creating a Hubspot webhook to react to your contact changes and update your Didomi users accordingly. Didomi identifies your Hubspot contacts using the `organization_user_id` property.

Didomi also creates a `Didomi Changed` property on your account that can be used on [Workflows](https://knowledge.hubspot.com/workflows/create-workflows) when you want to trigger an update from your Hubspot contact. For example, you can create a workflow that increments this property by 1 every time a contact update should be triggered on the Didomi Platform. This makes sure that your Didomi user is up to date with the changes performed by Hubspot.

### Mapping

Didomi uses the entity contact of Hubspot and sends the attributes property when updating a contact. Hence consent events are mapped to the contact attributes.

## Configuration

Didomi needs the following configuration items to set up the connection with Hubspot:

| Property               | Description                                                                             | Required                                  |
| ---------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------- |
| **Authorization code** | Authorization code returned by the redirect URL after installing the Didomi Hubspot App | Yes                                       |
| **Portal ID**          | ID of your Hubspot portal                                                               | No (only required for bidirectional flow) |
| **Mappings**           | List of contact properties to match between Didomi and Hubspot                          | Yes                                       |
| Upsert mode            | By setting upsert\_mode to true you allow Didomi to create contacts in Hubspot          | <p>No<br>Default value = false</p>        |

### Example

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "type_id": "hubspot",
    "authentication": {
        "code": "AUTH_CODE"
    },
    "properties": {},
    "mappings": [
        {
            "id": "hubspot_email_enabled",
            "value": "consents_preferences_newsletter_enabled"
        }
    ],
    "upsert_mode": true,
    "app_id": "YOUR_PORTAL_ID",
    "enable_webhooks": true
}
</code></pre>
