CallerId and CalledId transformation rule (provider_callerid)
Description
CallerId and CalledId transformation rule for SIP telephony provider accounts.
Used as an adapter between external and internal number plans. In particular, when modifying the CallerId of internal subscribers for sending outside, adaptation to the external number plan occurs, and when modifying the CallerId of external subscribers for sending into the system, adaptation to the internal number plan occurs, that is, preparation of data for the routing process.
The discovered modification rule is applied to modify both From username (number) and To username (number). If modifications need to be separated to reduce the number of rules, a special "priority" indicator can be used as the modifier for To (first the rule for FromNumber is applied, then a rule for ToNumber is searched and applied, but with priority greater than or equal to the original rule and with a filter by the already changed FromNumber).
The configured set of CallerId transformation rules can be tested through the diagnostic API. However, keep in mind that application differs between the test and a call because in a call the To number is taken from Request-Uri, and also when the value matches the entity account username, an empty string is substituted as the number for modification.
Fields
{
"id": uuid,
"priority": int,
"dir": str,
"idprovider": uuid,
"providercode": str,
"fromdomain": str,
"fromnumber": str,
"tonumber": str,
"modfromdisplay": str,
"modfromnumber": str,
"modtonumber": str,
"ext": {
"ct": date,
"lwt": date
},
"opts": {
"title": str,
"comment": str
}
}
| Specification | Description |
|---|---|
Field: |
Identifier. Can be specified at creation, otherwise generated by the system. |
Field: |
Rule priority. A lower value means higher priority. |
Field: |
Filter by change direction. |
Field: |
Filter by SIP telephony provider identifier. To specify a particular provider, first clear the mask in the 'providercode' field. |
Field: |
Filter mask for the SIP telephony provider code. |
Field: |
Filter mask for the call initiator address/domain (From header of the SIP INVITE request). |
Field: |
Filter mask for the call initiator number/username (From header of the SIP INVITE request). |
Field: |
Filter mask for the destination number/username (To header of the SIP INVITE request). |
Field: |
Operation mode of the from_username, from_displayname, and to_username modifiers. Possible variants:
|
Field: |
Call initiator name modifier. The result is passed to the representation process. |
Field: |
Call initiator number modifier. The result is passed to the call routing process. |
Field: |
Call destination number modifier. The application result is passed to the call routing process. |
Field: |
Service script code for modifying CallerId and CalledId numbers. The service script runs once and immediately returns several values using variables with special names:
The variables must be created in the script with the specified names. Possible value formats of the 'add_headers' variable:
The script runs synchronously in the routing process and is allotted a maximum of 3 seconds. According to the ReInvite request pass-through mode selected for the provider account, the script, like string modifiers, can be applied when subscriber data changes on one side. The following start parameters are passed to the script:
|
Field: |
|
Field: |
Arbitrary title |
Field: |
Arbitrary comment |
Field: |
Tabular data for using filters (and modifiers) within one rule search session. |
Field: |
Switch for preliminary number modification mode (to apply the result at an intermediate stage of interaction with an external billing system). |
Field: |
Switch for substituting the destination number with the number from the Diversion header when searching for and applying a suitable normalization rule. |
Field: |
Allows extending the compound with arbitrary keys and values |
Field: |
Object creation time |
Field: |
Time of last modification of the object |
Rule application direction
| Value | Description |
|---|---|
|
Toward the external party from the internal subscriber. The rule is applied to internal subscriber data when passing it toward the external subscriber. |
|
Toward the internal party from the external subscriber. The rule is applied to external subscriber data when passing it toward the internal subscriber. |
Filter operation modes
| Mode | Description |
|---|---|
|
The value being checked is passed through the filter character by character.
If one of the service characters must be specified as a target, it should be enclosed in square brackets, e.g. |
|
The substring
The following can be used as table field values: Using the table modifier is allowed in combination with other control commands of per-character mode. For example, |
|
The Pattern template is applied to the source value. Structure of the regex template value: For example,- value:
All standard regular expression rules can be used when forming Pattern templates. |
|
The value being checked is an integer and falls within the specified range of numeric values. Structure of the dia template value: For example,- value: |
Modifier operation modes
| Mode | Description |
|---|---|
|
The source value passes through the specified modifier character by character with accumulation.
For example,- value: |
|
The substring The table links several filter and modifier fields. Based on sequential filter checks, fewer rows remain in the table, taking detected matches into account. Using the table modifier is allowed in combination with other control commands of per-character mode. |
|
The substring OPTS is a concatenated string of allowed characters:
For example, let the source number modifier value be: If, as in the example, the From number must be substituted on re-INVITEs, enable From-URI update on re-INVITEs for the provider account. Substitution of values from the SIP message can also be combined with SIP message modification rules at the border. For example, with full-text SIP message processing in a more flexible mode, a set of values can be collected in one place and a new header formed, which is then used in the normalization rule. |
|
The Pattern template with Opts options is applied to the source field value, and the found block(s) are replaced with the Replace template. General structure of the regex modifier value: Options can be omitted or contain any combination of the characters:
For example,- value: When forming the Pattern and Replace templates, all standard regular expression rules can be used, including capture groups, backreferences, named group substitution, etc. |
|
The mode is implemented in task #192. (1) Rule R1 is searched by the initial From and To. (2) Its From modifier is applied. (3) If the To modifier is 'priority=X', where X is any non-negative number, then (3.1.1) a new rule R2 is searched by the new From and initial To, with priority starting from the specified X. (3.1.2) the To modifier from rule R2 is applied to the initial To. (3.2) otherwise the To modifier of rule R1 is applied to the initial To. The algorithm for building a compact set of CallerId and CalledId transformation rules can be as follows: (1) Act as usual. (2) If there is a need to reduce M*N rules to M+N, then (2.1) Select M From modification rules with high priorities, and set their To modifier values to 'priority=X'. (2.2) Create N more rules where From filters correspond to the From modification result or (2.3) When certain values do not require From modification, either modify To immediately or specify priority=X where X is greater than the current rule priority. |
See also
-
Article: Telephony providers
-
Collection: Telephony provider accounts