Choose where you’d like to start

Parse Phone Number

Description

The zoho.ai.parsePhoneNumber task examines the given phone number to provide its device, network, location, and formatting information.

Note: 
  • The prediction results may not be accurate, which is also the case with any AI prediction. However, we are working on improving this.
  • The prediction results are dynamic. The same script may produce different outcomes at different times based on how much the machine has learned.

Syntax

<response> = zoho.ai.parsePhoneNumber(<phone_number>, <country_code>);

where:

ParamsData typeDescription

<response>

KEY-VALUE

Specifies the time zone, location, type of the device, network provider, and formatting information of the given phone number.

<phone_number>

TEXT

Specifies the phone number that needs to be examined.

Note: The specified number should not have space separations regardless of the relevant country's phone number format.

<country_code>

TEXT

Specifies the country code of the phone number in ISO alpha-2 format.
Note: You can find the list of ISO alpha-2 country codes here.

Example

The following script provides information about the phone number - 92597XXXXX.

response = zoho.ai.parsePhoneNumber("92597XXXXX","US");

where:

response
The KEY-VALUE response that represents the time zone, location, type of the device, network provider, and formatting information of the given phone number.
"92597XXXXX"
The TEXT that represents the phone number that needs to be parsed.
"US"
The TEXT that represents the ISO Alpha-2 country code of the phone number.

Response Format

Success Response

  • The success response will be returned in the following format:

     {
     "extension":"",
     "italian_leading_zero":"false",
     "international_format":"+1 925-97X-XXXX",
     "national_format":"(925) 97X-XXXX",
     "timezone":"[\"America/Los_Angeles\"]",
     "e164_format":"+192597XXXXX",
     "national_number":"92597XXXXX",
     "type":"FIXED_LINE_OR_MOBILE",
     "outside_from_CH":"00 1 925-97X-XXXX",
     "country_code":"1",
     "carrier":"",
     "original_format":"(925) 97X-XXXX",
     "outside_from_US":"1 (925) 97X-XXXX",
     "location":"California",
     "raw_input":"92597XXXXX",
     "region":"US",
     "country_code_source":"FROM_DEFAULT_COUNTRY"
     }
To fetch the the parsed values from the response, use get() function. For example, the following script fetches the timezone from the returned response:
 info response.get("timezone");

Failure Response

  • The failure response for an empty input text will be returned in the following format:

     {
     "Error Message ": "phoneNumber less than minimum occurrence"
     }
  • The failure response for invalid phone number pattern will be returned in the following format:

     {
     "Error Message":"phoneNumber value is not in the expected pattern"
     }
  • The failure response for invalid country code will be returned in the following format:

     {
     "Error Message":"countryName value is not in the expected pattern"
     }
 

Related Links

Get Started Now

Execute