Use number templates

<< Click to Display Table of Contents >>

Navigation:  How to... >

Use number templates

Number templates are used to translate the To address from one format to another. You can use a number template if the gateway accepts only specific number formats (e.g. only numbers in international number format) and the source of the messages might generate the numbers in other formats.

 

Number templates can also be used if you use different gateways to send the messages and if each gateway accepts numbers in a slightly different format. For instance when you use a GSM modem as a primary gateway to send the messages and a Paging Gateway with an email service as a backup gateway. Since the email service only accepts an email address as a valid recipient address you can use a number template to translate the GSM phone number to a valid email address.

 

Number templates in gateways or connectors

All the gateways and connectors in Diafaan SMS Server have a number template property. The number template of the connectors change the number format immediately after they are received in the connector, the result is that the transformed number is used throughout Diafaan SMS Server, including in the logs. In the gateways, the number is changed just before sending the message. This means that the original number is used throughout Diafaan SMS Server, including in the logs

 

 

Number template format


The number template uses a simple format to check if the number confirms to the template and to translate the number from one format to another.

 

#

The hash tag character is used for each individual digit or character that is available in the source address and should be sent to the gateway.

[...]

Everything in brackets is not used to check if the number matches the number format but is inserted in the resulting recipient address.

Other characters

All other characters are used to check if the number matches the number format but are removed from the resulting recipient address.

 

The number template field can contain multiple number templates, each one separated by a semicolon, e.g.:

07[+447]#########;447[+447]#########

 

The number template also supports regular expression replacement if the field conforms to the following format:

regex:<regular expression>replace:<replacement>

or

regex:<regular expression>replace:<replacement>template:<number template>

 

 

If the number does not conform to the template format it is not translated to a different number format but sent 'as is'.

 

 

Examples


Translate local UK GSM numbers to international format:

07[+447]######### translates "07848000000" to "+447848000000".

 

Translate UK GSM number to an international format starting with 00:

07[00447]#########;+447[00447]######### translates "07848000000" and "+447848000000" to "00447848000000".

 

Translate a pager phone number to a 5 digit PIN:

+124812#####;024812##### translates "+12481234567" and "02481234567" to "34567"

 

Translate a national GSM number to an email address:

0[0]##########[@t-mobile.de] translates "01511111111" to "01511111111@t-mobile.de"

 

Translate national German GSM numbers to international format:

regex:^01(?=[0-9]{9,13}$)replace:+491

 

Strip all non digits from the number:

regex:[^\d]replace:

 

Strip all non digits (0-9) from the number and then translate local UK GSM numbers to international format:

regex:[^\d]replace:template:07[+447]#########