node-red-contrib-libphonenumber
A Node Red wrapper around Google Lib Phone Number
Parses, validates and converts a phone number.
This node wraps default capabilities.
See details and meaning of outputs at Google-LibPhoneNumber
Inputs
- payload string | buffer
- the raw phone number.
- msg.defaultCountryLetters string | buffer
- the default country number formating.
- msg.regionDialingFrom string | buffer
- Optional. If provided, msg.phone.isValidNumberForRegion<region> is returned.
Outputs
- msg.phone string | buffer
- Parsed number info with various details.
See details and meaning of outputs at Google-LibPhoneNumber
Installation
From node-red home directory, run below command:
$ npm -i node-red-contrib-libphonenumber
Test
Using docker:
$ docker-compose up -d
Then browse to http://localhost:2880 to see the example described in section below.
Example
Screenshot
Sample output
{
"_msgid":"58c04e91.b1f0a",
"topic":"","payload":"0123456789",
"phone":{
"CountryCode":33,
"NationalNumber":123456789,
"Extension":"",
"CountryCodeSource":"FROM_DEFAULT_COUNTRY",
"ItalianLeadingZero":false,
"RawInput":"0123456789",
"isPossibleNumber":true,
"isValidNumber":true,
"isValidNumberForRegionGB":false,
"RegionCodeForNumber":"FR",
"NumberType":"FIXED_LINE",
"E164":"+33123456789",
"INTERNATIONAL":"+33 1 23 45 67 89",
"NATIONAL":"01 23 45 67 89",
"RFC3966":"tel:+33-1-23-45-67-89",
"OriginalFormat":"01 23 45 67 89"
}
}
Flow
[
{
"id": "ff7d7036.5206",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "d93be7de.37c7c",
"type": "phonenumber",
"z": "ff7d7036.5206",
"name": "Parse Phone Number",
"defaultCountryLetters": "FR",
"regionDialingFrom": "GB",
"x": 660,
"y": 120,
"wires": [
[
"29b6bc91.33599c"
]
]
},
{
"id": "6eb1095d.89e388",
"type": "inject",
"z": "ff7d7036.5206",
"name": "",
"topic": "",
"payload": "0123456789",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 370,
"y": 120,
"wires": [
[
"d93be7de.37c7c"
]
]
},
{
"id": "29b6bc91.33599c",
"type": "debug",
"z": "ff7d7036.5206",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 890,
"y": 120,
"wires": []
}
]