Integrations · n8n

Validate Phone Numbers via n8n

Build a workflow that checks the phone number on every new Salesforce contact. Carrier, line type and ported status land on the contact.

Your first $5 of validations are on us, valid for 30 days. No card required.

score.phone.validation.mnpHTTP RequestSalesforce

What you'll build

TriggerSalesforce Trigger On Contact Created
ActionHTTP Request POSTscore.phone.validation.mnp
IfIf Did the response carry an error?
ActionSalesforce Update a contact

One execution per new contact. Five results and the time of the check land on the contact.

Before You Start

01

A ScoreMachine account. Create your workspace with Start free. Your first $5 of validations are on us, valid for 30 days. No card required.

02

A long-lived API key. Ask your account manager for one. The key goes in the Token header of every request, where a login token would go. No key yet? The If You Have No API Key section logs in with your email and password.

03

n8n Cloud or a self-hosted instance. n8n counts a workflow run as one execution, whatever the number of nodes. Community Edition is free to self-host.

04

A Salesforce credential in n8n. n8n connects through an External Client App in Salesforce. Step 01 also needs permission to add custom fields to Contact.

Build It Step by Step

Seven steps and four nodes. The workflow runs every time Salesforce creates a contact.

01

Add the custom fields in Salesforce

In Setup, open Object Manager › Contact › Fields & Relationships and create six fields. Salesforce adds __c to each field name.

Field LabelField NameData Type
Phone validSM_Phone_ValidCheckbox
Line typeSM_Line_TypeText (40)
CarrierSM_CarrierText (80)
PortedSM_PortedCheckbox
Phone E.164SM_Phone_E164Text (20)
Phone checked atSM_Phone_Checked_AtDate/Time
02

Store the API key as a credential

In n8n, create a Header Auth credential. n8n keeps credentials apart from the workflow, so the key never sits in a node.

Credential typeHeader Auth
NameToken
Value<your API key>
03

Start the workflow with a new Salesforce contact

Add the Salesforce Trigger node, connect your Salesforce credential and pick On Contact Created.

NodeSalesforce Trigger
Trigger OnOn Contact Created

Fetch Test Event returns a recent contact. Its Phone field holds the number to check.

04

Send the number to ScoreMachine

Add an HTTP Request node and fill in the fields below. Import cURL also works, with the curl sample from doc.scoremachine.ai.

MethodPOST
URLhttps://api.scoremachine.ai
AuthenticationGeneric Credential Type
Generic Auth TypeHeader Auth
Header Auththe credential from step 02
Send Headerson · Accept → application/json
Send Bodyon
Body Content TypeJSON
Specify BodyUsing JSON
JSONthe request body below, as an expression
Options › Timeout30000
Settings › Retry On Failon · Max Tries 3 · Wait Between Tries (ms) 2000
JSON · score.phone.validation.mnp
{
  "jsonrpc": "2.0",
  "method": "score.phone.validation.mnp",
  "params": {
    "phones": ["{{ $json.Phone }}"]
  },
  "id": 1
}

Switch the JSON field to Expression, so n8n fills in the contact's Phone. Use MobilePhone to check the mobile field.

phones takes numbers in E.164 format, such as +447911123456. geo_iso_code is optional and takes a two-letter ISO country code.

The node's output holds result, with phone_validation_mnp inside it.

05

Branch on errors

Add an If node after the HTTP Request. The true output catches responses that carry error. Connect the false output to step 06.

Conditions{{ $json.error }} → Object › exists
true outputleave empty, or add a notification
false outputthe Salesforce node in step 06
06

Write the results back to the contact

Add a Salesforce node on the If node's false output. Set Contact › Update, then add one custom field row per result.

ResourceContact
OperationUpdate
Contact IDthe expression below
Update Fields › Custom Fieldsone row per field below
EXPRESSIONS · Salesforce › Update a contact
Contact ID
{{ $('Salesforce Trigger').item.json.Id }}

SM_Phone_Valid__c
{{ $json.result[0].valid }}

SM_Line_Type__c
{{ $json.result[0].phone_validation_mnp.line_type }}

SM_Carrier__c
{{ $json.result[0].phone_validation_mnp.carrier }}

SM_Ported__c
{{ $json.result[0].phone_validation_mnp.ported }}

SM_Phone_E164__c
{{ $json.result[0].phone_validation_mnp.e164_format }}

SM_Phone_Checked_At__c
{{ $now.toISO() }}
07

Test the workflow and publish it

Click Execute workflow, then add a contact in Salesforce with the number +44 7911 123456. Open the contact when the execution finishes. Then click Publish, so the workflow runs on every new contact.

Line type mobile · Carrier Vodafone · Ported true · Phone E.164 +447911123456

Map the Results

Six fields land on the record. Five come from the response, and one is the time of the check.

Salesforce fieldScoreMachine fieldWhat it holds
Phone validSM_Phone_Valid__cresult[0].validtrue when the number fits a numbering range
Line typeSM_Line_Type__cresult[0].phone_validation_mnp.line_typemobile, landline or voip
CarrierSM_Carrier__cresult[0].phone_validation_mnp.carrierThe network serving the number today, after porting
PortedSM_Ported__cresult[0].phone_validation_mnp.portedtrue when the number moved from the network that issued the range
Phone E.164SM_Phone_E164__cresult[0].phone_validation_mnp.e164_formatThe number in E.164, ready for a dialer or an SMS route
Phone checked atSM_Phone_Checked_At__cthe platform's run timeWhen the check ran

valid says whether the number fits a numbering range. It does not say whether the number is in use. score.phone.ehlr answers that.

mcc and mnc identify the serving network by its mobile country and network codes. Add two text fields to store them.

Errors and Limits

01

Errors arrive as HTTP 200

A failed call returns an error object in place of result. The object carries code, message and optional data. An account with no funds left returns code -32004 and the message Low balance. The If node in step 05 sends error responses down its true output. Salesforce is left unchanged.

02

Retry network failures

Retry On Fail in step 04 repeats a failed request up to three times, 2 seconds apart.

03

Limits

Up to 20 requests per second. 2 seconds average response. Up to 10,000 numbers per request. A flow that runs once per new record sends one request per record.

For records already in your CRM, export a CSV and upload the file in your workspace. Uploads take up to 5 MB and 200,000 rows.

If You Have No API Key

auth.login takes your email and password. The token arrives in the Token response header, and it lasts 24 hours.

The HTTP Request node can return response headers with the body. A login node reads the token, and the check node sends it on.

A

Add a login node before the check

Add an HTTP Request node between the trigger and the check, and name it ScoreMachine login.

MethodPOST
URLhttps://api.scoremachine.ai
AuthenticationNone
Send Bodyon · JSON · Using JSON
JSONthe login body below
Options › ResponseInclude Response Headers and Status: on
JSON · auth.login
{
  "jsonrpc": "2.0",
  "method": "auth.login",
  "params": {
    "email": "you@company.com",
    "password": "********"
  },
  "id": 1
}
B

Send the token from the check node

In the check node, set Authentication to None and add a Token header. The phone now comes from the trigger by name, since the login node sits in between.

EXPRESSIONS · check node
Header: Token
{{ $('ScoreMachine login').item.json.headers.token }}

Body: phones
["{{ $('Salesforce Trigger').item.json.Phone }}"]

n8n returns header names in lowercase, so the expression reads headers.token.

The password sits in the workflow. Anyone who can edit it can read the password. Ask your account manager for an API key when you can.

Frequently asked questions

Check Every New Salesforce Contact

Create your workspace, or walk through your stack with our team.

Zapier guideMake guideCRM integrationsAPI reference at doc.scoremachine.ai