APIs & Integrations

matt72
Contributor

Custom Code to find Duplicate Phone Numbers

Hello,

I'm learning to code and work with web developers that can help me write code. We need to write custom code that will be used in a workflow. The code would take the contact in the workflow's phone number and check the CRM to see if their number has been used by another contact.

 

Basically, we need the code to make an API call and search for the phone number. If the phone number exists on multiple contacts, it will set a boolean (numberIsDuplicate) to "true". If the number is only used by one contact set it will set the boolean to "false.

 

This would be used to accept a contact if their phone number is unique and reject them if the number has been used by another contact.

 

If you could recommend any starting code or existing tutorials that do something similar we could probably figure it out from there.

 

Thanks for your help,

Matthew 

2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

Custom Code to find Duplicate Phone Numbers

Hey, @matt72 👋 Thanks for your question.

 

If it were me, I'd start by making a simple list to scope out the pieces you'll need.

 

One question that will be helpful for the community to know — are you writing this custom coded workflow action using Python or JavaScript?

 

An example list:

  • create your Private or Public App and give it the needed scopes
  • look into the endpoint or endpoints you will need to call. I'd start with the Search API for this project
  • if you're using JS, set up a quick Node app to test your function(s) locally
  • break your function into small parts – one to make the request, one to evaluate the response and set the numberIsDuplicate boolean

Another consideration, if these contacts are being created and then immediately enrolled into this workflow, you'll need to add a delay of 5–10 seconds to account for the Search API limitations. Otherwise, you may encounter a race condition and get an error. 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
matt72
Contributor

Custom Code to find Duplicate Phone Numbers

Hey Jaycee,

I've found a tutorial on YouTube that will get me close to what we need. I will run through the tutorial and follow your outline. If I have any hang-ups I will check back to this post.

Thanks for your help!

Matthew