While there are a host of paid services providers available for Salesforce customers looking to enrich their customer data, in this post I will call out a couple of limited, but free options. These are both available as public APIs.
You can use these APIs in a couple of ways. I have implemented the Twilio service via Apex using a trigger, and the Clearbit service I used to enhance a customer list prior to loading into Salesforce, using a Ruby script to process the data file.
Phone Number Validation and Formatting from Twilio
Twilio is a voice, email, and SMS services provider offering a broad range of useful services.
For this exercise, we are interested in Twilio’s Lookup API. Lookup provides information about a phone number - including whether or not the number is valid, what kind of line it is (e.g. mobile/landline/VOIP), who the carrier is, and who the subscriber is. Depending on the information you need, the service ranges from free to a penny per lookup.
The free element of the service can help you by:
-
Formatting the phone number, either using the E164 standard or the national format for the number.
-
Validating the phone number. Even if a phone number follows the right pattern, it may not represent a valid number - for example, we know that (000) 555-1234 is not a valid US phone number, even though it matches the pattern for a US phone number.
The service is easy to use, and the Twilio API documentation is extensive.
You need to set up a Twilio account, and then access the REST API (using basic auth) as follows (example is looking up (978) 521-2287). You need to include the country as well as the number.
The URL:
https://lookups.twilio.com/v1/PhoneNumbers/(978) 521-2287?CountryCode=US
The results from Twilio in JSON format:
{
"caller_name": null,
"country_code": "US",
"phone_number": "+19785212287",
"national_format": "(978) 521-2287",
"carrier": null,
"add_ons": null,
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+19785212287"
}
Since we got a result we know the number is valid, and we can use either the national format or E164 (represented as phone_number
).
If the number is not valid the service returns a 404 error as below.
Invalid phone number lookup URL:
https://lookups.twilio.com/v1/PhoneNumbers/(000) 555-1234?CountryCode=US
The results from Twilio in JSON format:
{
"code": 20404,
"message": "The requested resource /PhoneNumbers/(000) 555-1234 was not found",
"more_info": "https://www.twilio.com/docs/errors/20404",
"status": 404
}
The Twilio API can help you standardize on a single format for phone numbers for cleaner data, while flagging invalid numbers at the same time. Twofer!
Finding Web Domains and Logos with Clearbit
Web domain is a valuable attribute of an Account record in Salesforce. It acts as a “unique identifier” to help spot duplicate Account records, and to identify linkages between new Lead records and existing Account records.
You many find yourself in the situation where you have Account records that are missing domains. In this case, this free API from Clearbit can be a big help. Clearbit is a data provider that also offers a Salesforce integration for its paid services.
These APIs do not require a user account of any kind, and there is no authentication to access them. Clearbit offers clients for Ruby, Node, Python, Go, and Java.
The Autocomplete API takes a partial company name:
https://autocomplete.clearbit.com/v1/companies/suggest?query=adobe
The results from Clearbit:
[
{
"name": "Adobe",
"domain": "adobe.com",
"logo": "https://logo.clearbit.com/adobe.com"
},
{
"name": "AdobePress",
"domain": "adobepress.com",
"logo": "https://logo.clearbit.com/adobepress.com"
},
{
"name": "Adobe Business Catalyst",
"domain": "businesscatalyst.com",
"logo": "https://logo.clearbit.com/businesscatalyst.com"
},
{
"name": "Adobe I/O",
"domain": "adobe.io",
"logo": "https://logo.clearbit.com/adobe.io"
},
{
"name": "Adobe Rent a Car",
"domain": "adobecar.com",
"logo": "https://logo.clearbit.com/adobecar.com"
}
]
I believe the results are sorted in descending order of web traffic, but I am not certain (that is how the Name To Domain API works).
Lastly, I recommend when storing web domains in Salesforce, to do some standardization using regular expressions - for example, to strip http://
or https://
.