> For the complete documentation index, see [llms.txt](https://docs.middle.app/middle-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.middle.app/middle-docs/guides/app-reference/hubspot/contact-merge-process.md).

# Contact merge process

How you can use Middle to merge contacts in HubSpot

## Summary

Middle is able to connect identities in your POS platform or membership management platform to HubSpot contacts. Identified contacts can then be merged together, cleaning up your HubSpot data.

Using serialized workflows you can look up an individual in HubSpot by their external ID (such as a member ID), their email, and their phone and name. Using Middle's action to search for an object in HubSpot, you are able to combine all of these search queries into a single step. This then returns all contacts that match your search terms.

If more than one contact is returned, Middle's merge contacts HubSpot action allows you to merge together these duplicate contacts.

{% hint style="info" %}
This process relies on a unique external ID property being set up in HubSpot
{% endhint %}

{% content-ref url="/pages/zdIQwzG87FOlY4h90LEH" %}
[External ID properties](https://docs.middle.app/middle-docs/guides/app-reference/hubspot/external-id-properties.md)
{% endcontent-ref %}

## How the process works

Middle's HubSpot module workflows employ the following process:

1. Search for individual by external ID, email, and phone
2. Categorize found contacts by their matching criteria:
   1. **External ID match**
   2. **Email match:** Do not overwrite a contact found via email match if the contact in HubSpot represents an active customer
   3. **Phone matches:** only match when an exact match on name is found
3. If multiple distinct matches exist, a merge branch selects a surviving contact and merge duplicates into the surviving contact
4. A final step performs an update to the surviving contact so that data is up to date

### Surviving contact selection

**Most recent conversion wins:** if any eligible contact has `recent_conversion_date`, consider only contacts with that value and select the newest.

**Otherwise, oldest contact wins:** if none has a conversion date, select the earliest HubSpot `createdate`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.middle.app/middle-docs/guides/app-reference/hubspot/contact-merge-process.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
