format

format

Formats a phone number in the specified format using default rules. Note that this does not promise to produce a phone number that the user can dial from where they are - although we do format in either NATIONAL or INTERNATIONAL format depending on what the client asks for, we do not currently support a more abbreviated format, such as for users in the same area who could potentially dial the number without area code.

This action makes use of the default_region and format parameters.

Consider the following dialplan fragments:

  <action application="phonenumber" data="format caller default_region=US,format=E164"/>

will set the phonenumber_caller_format channel variable to the resulting value.


  <action application="phonenumber" data="format destination default_region=US,format=E164"/>

will set the phonenumber_destination_format channel variable to the resulting value.


  <action application="phonenumber" data="format all default_region=US,format=E164"/>

will set both the phonenumber_caller_format and the phonenumber_destination_format channel variables to the resulting value.


  <action application="phonenumber" data="format ${variable} default_region=US,format=E164"/>

will set the phonenumber_number_format channel variable to the resulting value.

freeswitch@test> phonenumber format 800FLOWERS default_region=US,format=E164

+18003569377

freeswitch@test> phonenumber format 800FLOWERS default_region=US,format=INTERNATIONAL

+1 800-356-9377

freeswitch@test> phonenumber format 800FLOWERS default_region=US,format=NATIONAL

(800) 356-9377

freeswitch@test> phonenumber format 800FLOWERS default_region=US,format=RFC3966

tel:+1-800-356-9377

freeswitch@test> phonenumber format '020 7679 2000' default_region=GB,format=E164

+442076792000

freeswitch@test> phonenumber format '020 7679 2000' default_region=GB,format=INTERNATIONAL

+44 20 7679 2000

freeswitch@test> phonenumber format '020 7679 2000' default_region=GB,format=NATIONAL

020 7679 2000

freeswitch@test> phonenumber format '020 7679 2000' default_region=GB,format=RFC3966

tel:+44-20-7679-2000

Consider the following hook definitions:

    <hook>
      <param name="scope" value="caller"/>
      <param name="actions" value="format"/>
      <param name="default_region" value="US"/>
      <param name="format" value="E164"/>
    </hook>

will set the phonenumber_caller_format channel variable to the resulting value.


    <hook>
      <param name="scope" value="destination"/>
      <param name="actions" value="format"/>
      <param name="default_region" value="US"/>
      <param name="format" value="E164"/>
    </hook>

will set the phonenumber_destination_format channel variable to the resulting value.


    <hook>
      <param name="scope" value="all"/>
      <param name="actions" value="format"/>
      <param name="default_region" value="US"/>
      <param name="format" value="E164"/>
    </hook>

will set both the phonenumber_caller_format and the phonenumber_destination_format channel variables to the resulting value.