You can configure your HubSpot integration with primary and secondary lookups,
which can identify a caller based on their contact record or company profile. If
the primary lookup returns no results, the system attempts the secondary lookup.
In addition, you can configure which CRM account display fields from the matched
primary or secondary lookup object appear in the agent adapter. Lastly, you can
configure the CRM *record* display fields that appear in the agent adapter,
regardless of whether the primary or secondary object was matched. The record
display fields apply to the opened CRM record---for example, a ticket or a
deal.

Configure the CRM *account* display fields when you're [configuring the primary
lookup object](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-primary-lookup) and [configuring the secondary lookup
object](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-secondary-lookup). To configure the CRM *record* display
fields, see [Configure CRM record display fields in the agent
adapter](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-crm-record-fields-agent-adapter).

> [!NOTE]
> **Note:** HubSpot lookups replace the previous HubSpot mobile phone number lookups. If you configured your HubSpot integration using HubSpot mobile phone number lookups, your configuration is preserved until you edit it.

## Before you begin

Before you begin, integrate HubSpot with your Contact Center AI Platform (CCAI Platform) instance.
For more information, see [HubSpot](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot).

## Configure the primary lookup object

You can configure the primary lookup object, which is the first object that the
system searches for when a session begins. You can also configure which CRM
account display fields appear in the agent adapter. The following procedure
shows you how to do both.

To configure the primary lookup object and the CRM account display fields,
follow these steps:

1. In the CCAI Platform portal, click **Settings \> Developer Settings** .
   If you don't see the **Settings** menu, click **Menu**.

2. In the **CRM** pane, go to the **Account Lookup** section.

3. To configure the primary lookup object, do the following:

   1. Expand the **Primary Lookup Object** section.

   2. In the **Object Type** list, select the type of object to look up.

   3. In the **Phone number lookup fields** list, select the fields that the
      system should use to match the end-user's phone number.

   4. In the **Phone number primary field** list, select the field where a
      customer's phone number is stored when the system creates a new CRM
      account.

   5. For **Phone Number Format**, select the request phone number format.

   6. Optional: To look up end-users by custom field for SDK sessions, do the
      following:

      1. Select the **Mobile / Web SDKs: lookup users by custom field for SDK
         sessions** checkbox.

      2. In the **Custom lookup field in CRM** list, select the custom lookup
         field.

4. To configure CRM account display fields in the agent adapter, do the
   following:

   1. In the **CRM Account Display Fields** section, in the **Matched account
      display field** list, select the main identifier for the account.

   2. Optional: To display a second field, do the following:

      1. Select the **Display a second field** checkbox.

      2. In the **Second Display Field** list, select a second field type to
         display.

      3. For **Second field display position**, select the order to display
         the fields in the agent adapter.

5. Click **Save**.

## Configure the secondary lookup object

You can configure the secondary lookup object, which serves as a fallback in
case the primary lookup returns no results. You can also configure which CRM
account display fields appear in the agent adapter. The following procedure
shows you how to do both.

To configure the secondary lookup object and the CRM account display fields,
follow these steps:

1. In the CCAI Platform portal, click **Settings \> Developer Settings** .
   If you don't see the **Settings** menu, click **Menu**.

2. In the **CRM** pane, go to the **Account Lookup** section.

3. To configure the secondary lookup object, do the following:

   1. Select the **Secondary Lookup Object** checkbox.

      > [!NOTE]
      > **Note:** The **Object Type** list displays the option type that you didn't select in [Configure the primary lookup
      > object](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-primary-lookup).

   2. In the **Phone number lookup fields** list, select the fields that the
      system should use to match the end-user's phone number.

   3. In the **Phone number primary field** list, select the field where a
      customer's phone number is stored when when CCAI Platform
      creates a new CRM account.

   4. For **Phone Number Format**, select the request phone number format.

   5. Optional: To look up end-users by custom field for SDK sessions, do the
      following:

      1. Select the **Mobile / Web SDKs: lookup users by custom field for SDK
         sessions** checkbox.

      2. In the **Custom lookup field in CRM** list, select the custom lookup
         field.

4. To configure CRM account display fields in the agent adapter, do the
   following:

   1. In the **CRM Account Display Fields** section, in the **Matched account
      display field** list, select the main identifier for the account.

   2. Optional: To display a second field, do the following:

      1. Select the **Display a second field** checkbox.

      2. In the **Second Display Field** list, select a second field type to
         display.

      3. For **Second field display position**, select the order to display
         the fields in the agent adapter.

5. Click **Save**.

## Configure CRM record display fields in the agent adapter

You can configure the CRM record display fields that appear in the agent
adapter, regardless of whether the primary or secondary object was matched. To
configure which CRM *agent* display fields that appear in the agent adapter, see
[Configure the primary lookup object](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-primary-lookup) and [Configure
the secondary lookup object](https://docs.cloud.google.com/contact-center/ccai-platform/docs/hubspot-lookups#configure-secondary-lookup).

To configure CRM record display fields in the agent adapter, do the following:

1. In the CCAI Platform portal, click **Settings \> Developer Settings** .
   If you don't see the **Settings** menu, click **Menu**.

2. In the **CRM** pane, go to the **CRM Record Display Fields** section.

3. In the **Matched record display field** list, select the main identifier for
   the record.

4. Optional: To display a second field, do the following:

   1. Select the **Display a second field** checkbox.

   2. In the **Second Display Field** list, select a second field type to
      display.

5. Optional: To display a third field, do the following:

   1. Select the **Display a third field** checkbox.

   2. In the **Third Display Field** list, select a third field type to
      display.

6. Click **Save**.

## Lookup cascade logic

The following explains the cascade logic that CCAI Platform uses for
object lookups:

- If `contact_id` is provided, CCAI Platform performs a direct GET
  call first. Otherwise, CCAI Platform searches phone, email, SDK,
  and SIP identifiers using OR logic.

- If multiple matching records are found, CCAI Platform selects the
  one modified most recently. Modification dates are determined as follows:

  - **Contact** uses `lastmodifieddate`.

  - **Company** uses `hs_lastmodifieddate`.