Aircall + Hubspot

Hello, I would like to know how I can clean up all the contacts that are created directly with Aircall in Hubspot, as I have many contacts with the name: phone number + Aircall. How can I fix this?

Hi @evs949
Thank you for reaching out to the Community!
I’d like to invite some community members who are subject matter experts to join this conversation.
@Anton @kosalaindrasiri @AGupta58 - Would you be able to share any insights on this? Your expertise would be greatly appreciated.
Best,
Victor

If you have Ops Hub Pro, you can create a custom private app and custom workflow action to merge duplicate records based on matching phone numbers. I recenetly created this for a client who uses CallRail. It took some troubleshooting but I got it to work. It does require some coding but I can give you the code I used if you’d like.

/**
 * Searches for another contact with the same value of DEDUPE_PROPERTY.
 * - If no matches are found, nothing happens
 * - If one match is found, the enrolled contact is merged into the matching contact
 * - If more than one match is found, the action fails
 */

const DEDUPE_PROPERTY = 'phone';

const hubspot = require('@hubspot/api-client');

exports.main = (event, callback) => {
 // Make sure to add your API key under "Secrets" above.
 const hubspotClient = new hubspot.Client({
 accessToken: process.env.Change_to_your_HS_secret_name
 });

 hubspotClient.crm.contacts.basicApi
 .getById(event.object.objectId, [DEDUPE_PROPERTY])
 .then(contactResult => {
 let dedupePropValue = contactResult.properties[DEDUPE_PROPERTY];
 console.log(`Looking for duplicates based on ${DEDUPE_PROPERTY} = ${dedupePropValue}`)
 hubspotClient.crm.contacts.searchApi
 .doSearch({
 filterGroups: [{
 filters: [{
 propertyName: DEDUPE_PROPERTY,
 operator: 'EQ',
 value: dedupePropValue
 }]
 }]
 })
 .then(searchResults => {
 let idsToMerge = searchResults.results
 .map(object => object.id)
 .filter(vid => Number(vid) !== Number(event.object.objectId));

 if (idsToMerge.length == 0) {
 console.log('No matching contact, nothing to merge');
 return;
 } else if (idsToMerge.length > 1) {
 console.log(`Found multiple potential contact IDs ${idsToMerge.join(', ')} to merge`);
 throw new Error("Ambiguous merge; more than one matching contact");
 }

 let idToMerge = idsToMerge[0];
 console.log(`Merging enrolled contact id=${idToMerge} into contact id=${event.object.objectId}`);
 hubspotClient
 .apiRequest({
 method: 'POST',
 path: `/contacts/v1/contact/merge-vids/${idToMerge}`,
 body: {
 vidToMerge: event.object.objectId
 }
 })
 .then(mergeResult => {
 console.log(`Contacts merged! ${mergeResult}`);
 })
 .catch(err => console.error(err));
 })
 .catch(err => console.error(err));
 })
 .catch(err => console.error(err));
};

There’s a piece on line 15, Change_to_your_HS_secret_name, that you will need to change to the Secret Name, where you place your Private App Access Token, in the workflow’s custom action section (also where you’ll add this code).

Hope this helps!