ParseNumber

A custom node that parses phone number

Overview

This custom node parses and validates a phone number input. It is designed to take any string representing a phone number, validate it according to the Mexican ("MX") numbering plan, and output the formatted international version of the number if valid. This node is useful in workflows where phone number normalization and validation are required, such as contact data cleaning, CRM integrations, or messaging automation.

For example, if you input a local or partially formatted Mexican phone number, the node will return its full international format (e.g., "+52 1 55 1234 5678"). If the input is invalid or too long, it returns an error message indicating the problem.

Properties

Name Meaning
Parse Number Any number to be parsed and validated as a phone number. The input should be a string representing a phone number, preferably in or related to the Mexican numbering system.

Output

The node outputs a JSON object with the following fields:

  • parsedNumber: A string containing the formatted international phone number if parsing and validation succeed. Otherwise, it contains an error message such as "not valid number" or "something went wrong".
  • errors (optional): Present only when parsing fails, this field contains a generic error message "errorrr" indicating that the input was invalid or processing failed.

No binary data output is produced by this node.

Dependencies

  • Uses the external library libphonenumber-js for phone number parsing, validation, and formatting.
  • Assumes the phone number is from Mexico ("MX" region code) for validation and formatting purposes.
  • No additional API keys or external services are required.

Troubleshooting

  • Input too long: If the input number contains more than 12 digits (ignoring non-digit characters), the node immediately returns an error stating "not valid number". Ensure the input is a realistic phone number length.
  • Invalid phone number: If the input cannot be parsed into a valid Mexican phone number, the node returns "not valid number". Verify the input format and country context.
  • Unexpected errors: If the node returns "something went wrong", it indicates an unexpected failure during formatting. Double-check the input and consider adding logging or debugging steps.
  • Common error message: "errorrr" is a generic error indicator used internally; users should interpret it as a failure to parse or validate the number.

Links and References

Discussion