Setting up number conversion rules

When setting up SIP accounts from some telecom operators or registering with a PBX whose settings are not on our list Server templates You may need to manually configure number conversion rules for outgoing calls.

Before sending the phone to a SIP operator, you may need to convert the number to its format. For example, in telephone numbers are often written with 8s, with brackets and spaces. For compatibility, it is better to convert such numbers to a standard format:

8 (926) 123-45-67 → 79261234567

The essence of the necessary number conversion: remove spaces, brackets and hyphens. The number 8 at the beginning of the number must be converted to the country code, for example, for Russia it is 7.

This kind of transformation is done using one or more regular expression rules.

  • There are 2 types of rules: those containing the = sign (equality) and those not containing it
  • All rules are applied in turn
  • We recommend using the ` (single quote) character at the beginning and end of rules to disable the possible conversion of part of the rule into emoticons.

First type of rule (with equal sign =)

Such rules replace the left part of = with the right part. Both parts of the rule are regular expressions. If the left side of the rule is not found in the phone number, the rule is skipped.
[^+*#\w]= ^8=7
Example 1: The transformation contains 2 rules. The first removes all characters from the dialed number except numbers, letters and the signs +, *, # and _. The second rule replaces the first digit 8 in the number with 7.
Example 2: Two equivalent rules replace the 8 and +7 at the beginning of the phone number with 7 (the period at the end of the rule is important).
Example 3: Converts any number to an empty value. This value, for example, is the default for Gateway lines (SIP accounts), so that possible text messages from the user are not processed as numbers by default and a call over the line occurs only to an explicitly set number (PBX number).

Second type of rules (without equal sign =)

Such regular expressions specify a mask to restrict the use of the operator. If the regular expression does not match a phone number, that operator is excluded and subsequent rules are not considered. If there is a match, the next rule is reviewed.
Example 4: limits the use of a SIP account only to Russian phone numbers (starting with 7 and continuing with 10 digits)
Example 5: Russian mobile numbers
Example 6: three-digit (usually internal) numbers

See also

Payment methods for the SIP.TG gateway for transferring calls between Telegram and SIP telephony

Frequent problems and solutions when setting up a gateway for calls between Telegram and SIP telephony

Configuring codecs for SIP accounts when setting up the SIP.TG gateway for voice calls in Telegram

Settings and use of the DTMF keyboard when Telegram- calls

Error codes and their interpretation that may occur when setting up a gateway for calls from Telegram

Methods for transferring tariff management to another user, transferring the right to administer the tariff, as well as transferring ownership of the tariff

Request for SIP.TG account management to help users whose categories of users have access to the function

IP telephony operators for different geographical areas, tested by our team

Purpose, advantages, procedure for installing and configuring your own Worker servers for SIP.TG

Purpose, advantages, procedure for installing and configuring your own Session Storage Telegram for SIP.TG