get_region_code

get_region_code

Returns the region where a phone number is from. This could be used for geocoding at the region level. Only guarantees correct results for valid, full numbers (not short-codes, or invalid numbers). Returns ZZ when no match is possible.

This action makes use of the default_region parameter.

Consider the following dialplan fragments:

  <action application="phonenumber" data="get_region_code caller default_region=US"/>

will set the phonenumber_caller_region_code channel variable to the resulting value.


  <action application="phonenumber" data="get_region_code destination default_region=US"/>

will set the phonenumber_destination_region_code channel variable to the resulting value.


  <action application="phonenumber" data="get_region_code all default_region=US"/>

will set both the phonenumber_caller_region_code and the phonenumber_destination_region_code channel variables to the resulting value.


  <action application="phonenumber" data="get_region_code ${variable} default_region=US"/>

will set the phonenumber_number_region_code channel variable to the resulting value.

freeswitch@test> phonenumber get_region_code 6172531000 default_region=US

US

freeswitch@test> phonenumber get_region_code +16172531000 default_region=GB

US

freeswitch@test> phonenumber get_region_code 02076792000 default_region=GB

GB

freeswitch@test> phonenumber get_region_code +442076792000 default_region=US

GB

freeswitch@test> phonenumber get_region_code 6172531000 default_region=US

US

freeswitch@test> phonenumber get_region_code 6172531000 default_region=GB

ZZ

Consider the following hook definitions:

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

will set the phonenumber_caller_region_code channel variable to the resulting value.


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

will set the phonenumber_destination_region_code channel variable to the resulting value.


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

will set both the phonenumber_caller_region_code and the phonenumber_destination_region_code channel variables to the resulting value.