Redirect rule (redirectrule)

Description

Redirect rule assigned to numbers (SIP user accounts).
Applied by the B2BUA role server when making calls to internal SIP user numbers.

Includes several routing types: absolute, due to absence of registered devices, and due to various unsuccessful responses from called devices.

Sequential application of cascade forwarding A → B → C → D is possible.

Filtering by the call initiator number is supported.

Limitations

  • The collection is unavailable in the master domain.

  • When a SIP user account is used as a resource in queues, simultaneous forwarding may harm queue principles.

  • Does not apply to forwarding configured on the SIP device itself and initiated by receiving SIP responses with `3xx` codes.

Fields

Entity structure
{
  "id": uuid,
  "type": str,
  "filter_number": str,
  "tran_number": str,
  "priority": int,
  "enabled": intbool,
  "schedule": str,
  "periods": array<object>,
  "opts": {
    "title": str,
    "comment": str
  },
  "ext": {
    "ct": date,
    "lwt": date
  }
}
Table 1. Fields
Specification Description

Field: id
Mode: inout
Type: uuid
Default: generated

Identifier. Can be specified at creation, otherwise generated by the system.

Field: type
Mode: in
Type: str
Default: required

Depending on the selected type, the rule can apply under different conditions and at different points in the device call process.
The mapping of specific SIP responses to redirect rule condition types is configured in the general domain settings.
The table shows the mapping applied by default.

When several account devices are called in parallel and all outcomes fail, the so-called best result is selected from all received SIP response codes: 603, 486, 6xx, 5xx, 4xx.

The value may specify several types, comma-separated.

Field: filter_number
Mode: in
Type: str
Default: required

Number filter mask for the number the redirect rule belongs to.
This can be a directly specified SIP user account number, in which case the rule applies individually.
But a search filter mask can also be specified.
Filter operation modes.

Field: filter_fromnumber
Mode: in
Type: str
Default: required

Number filter mask for the number from which the call is made.
Filter operation modes.

Field: tran_number
Mode: in
Type: str
Default: required

Modifier of the redirect destination number.
By default any text value assigned in the field is applied without modification, but if it contains special formatting, the result can be changed dynamically.
The value dnd is reserved and can be set if the type is absolute. Such a rule causes the call to be rejected.
Modifier operation modes.

Field: priority
Mode: in
Type: int
Default: required

Priority. A lower value means higher priority.

Field: enabled
Mode: in
Type: intbool
Default: required

Switch. The rule applies only if it is enabled.

Field: schedule
Mode: in
Type: str
Default: "all"

Defines the rule activity schedule.
Working/non-working time is determined in the current domain settings or in parent domains up to the master domain.
Work schedule

Field: periods
Mode: in
Type: array<object>
Default: empty

Activity interval during the week.
Applied when schedule = custom.
Each list element covers a specific segment within the week: from a time on a specific day of the week to a time on another specific day of the week.
The overall schedule is formed from the set of these segments.
Weekly schedule list element.

Field: opts
Mode: in
Type: object
Compound field

Field: opts.title
Mode: in
Type: str
Default: empty

Arbitrary title

Field: opts.comment
Mode: in
Type: str
Default: empty

Arbitrary comment

Field: opts.tab
Mode: in
Type: array<object>
Default: []

Tabular data for using filters within one rule search session.
Each object in the list contains arbitrary fields that can be used in the mask as the string {tab:some_field}.
More in Filter operation modes, item 'Table'.

Field: ext
Mode: inout
Type: object
Compound field

Allows extending the compound with arbitrary keys and values

Field: ext.ct
Mode: out
Type: date
Default: generated

Object creation time

Field: ext.lwt
Mode: out
Type: date
Default: generated

Time of last modification of the object

Redirect rule condition types

Table 2. Redirect rule condition types
Value Description

"absolute"

The redirect rule always applies. Applied before the call starts.

"unregistered"

The redirect rule applies if the account has no registered devices at the time of the call. Applied before the call starts.

"busy"

The redirect rule applies after receiving a response mapped in general settings to the Busy result. By default the SIP response code is 486 Busy Here.

"timeout"

The redirect rule applies after the allowed call time expires (30 seconds by default, or as set in the SIP user account settings), or after receiving a 408 Timeout response.

"decline"

The redirect rule applies after receiving a response mapped in general settings to the Declined result. By default the SIP response code is 603 Decline.

"dnd"

The redirect rule applies after receiving a response mapped in general settings to the DND (Do Not Disturb) result. By default the SIP response codes are 404 Not Found, 480 Temporary Unavailable. The 430 Flow Failed response (device WebSocket connection lost) is treated as 480.

"error"

The redirect rule applies after errors are detected during calls.

"other"

The redirect rule applies after receiving SIP responses not mapped to other result types.

Filter operation modes

Table 3. Filter operation modes
Mode Description

Per-character

The value being checked is passed through the filter character by character.
The following special characters can be used:

  • X – any character;

  • * – all remaining characters;

  • ? - any character (when used for domain name filtering, any character except the dot, the domain name separator).

  • $ – any number of characters up to the nearest dot.

If one of the service characters must be specified as a target, it should be enclosed in square brackets, e.g. [X].

For example, XXX – any three-character value.

Table

The substring {tab:…​} can be used. It allows selecting a group of characters in the checked value and matching them against the table embedded in the rule (opts.tab).
For example, {tab:a} selects a substring and matches it against the a field of all objects/rows in the table.
The table links several filter and modifier fields. Based on sequential filter checks, fewer rows remain in the table, taking detected matches into account.
The first remaining row is used in modifiers. If no rows remain in the table, the rule is rejected.
Character capture from the checked value based on the mask can occur automatically or with strict specification of the substring length:

  • {tab:KEY} - Automatic capture from the checked value.

  • {tab:KEY:LENGTH} - Capture the specified number of characters from the checked value.

The following can be used as table field values:

  • constants;

  • regular expressions (to do this, set the value in the format /reg/EXPRESSION, e.g. /reg/^1[1-4]$);

  • mappings to other table fields (to do this, set the value in the format /tab/FIELD, e.g. /tab/a). The mode is used to link values of different fields. For example, to allow calls only to one’s own voicemail box. The linking order must be strictly observed: if the referenced table field has not yet been checked and filled with the real value of another entity field, the match will not succeed. Entity field check order: filter_number, filter_fromnumber.

  • any value applied without a regular expression (to do this, set /any). The mode is useful exclusively for direct mappings to values of other fields without additional filters.

Using the table modifier is allowed in combination with other control commands of per-character mode.
Repeated specification of fields in one modifier, repetition, and specification of nonexistent fields are allowed.

For example, {tab:a:3}XXXXX{tab:b} allows selecting the 3-character city code in the number and matching it with field a in the table, and simultaneously selecting the tail starting from the 9th character and matching it with table field b.

Regex

The Pattern template is applied to the source value.

Structure of the regex template value:
/reg/Pattern1.

For example,- value: "302"
- mask: "/reg/0"
- result: true.

  • value: "302"

  • mask: "/reg/^0$"

  • result: false.

  • value: "302"

  • mask: "/reg/^302$"

  • result: true.

  • value: "302"

  • mask: "/reg/^(301|302|305)$"

  • result: true.

All standard regular expression rules can be used when forming Pattern templates.

Range

"The value being checked is an integer and falls within the specified range of numeric values.

Structure of the dia template value:
/dia/FromValue+N - matches N+1 values from FromValue to FromValue+N.

For example,- value: "302"
- mask: "/dia/300+10"
- result: true.

Modifier operation modes

Table 4. Modifier operation modes
Mode Description

Per-character

The source value passes through the specified modifier character by character with accumulation.
The per-character modifier does not provide value substitution as a result. The specified value is treated as a constant. The characters 0-9, *, # are supported.

Table

The substring {tab:…​} can be used. It allows substituting a substring from the specified table field (opts.tab) into the value being modified.
The source is the first row remaining after filtering in the table.
For example, {tab:ccc} substitutes the value from field ccc of the first remaining table row into the corresponding position of the final result.
If the specified field is absent in the first row/object, an empty value is substituted.

The table links several filter and modifier fields. Based on sequential filter checks, fewer rows remain in the table, taking detected matches into account.
The first remaining row is used in modifiers. If no rows remain in the table, the rule is rejected at the filter check stage.

Using the table modifier is allowed in combination with other control commands of per-character mode.
Repeated specification of fields in one modifier, repetitions, and specification of nonexistent fields are allowed.

Regex

The Pattern template with Opts options is applied to the source value, and the found block(s) are replaced with the Replace template.
The result can again be passed to the next Regex modification operation, and so on a finite number of times.

General structure of the regex modifier value:
/reg/Pattern1/Replace1/Opts1 /reg/Pattern2/Replace2/Opts2 …​.

Options can be omitted or contain any combination of the characters:

  • i – case-insensitive

  • g – global.

For example,- value: "qwerty,qwerty"
- modifier: "/reg/t/E/g /reg/qwer/a/"
- result: "aEy,qwerEy".

When forming the Pattern and Replace templates, all standard regular expression rules can be used, including capture groups, backreferences, named group substitution, etc.

Work schedule

Table 5. Work schedule
Value Description

"all"

The rule is always available for application

"disabled"

The rule is never available for application

"work"

The rule is available for application only during working hours

"non-work"

The rule is available for application only outside working hours

"custom"

The rule defines an individual availability schedule in the rule periods field

Weekly schedule list element

Table 6. Weekly schedule list element
Field Value Description

daystart

1 – 7

Day of week when the segment starts (1 – Mon, 7 – Sun)

daystop

1 – 7

Day of week when the segment ends (1 – Mon, 7 – Sun)

timestart

0 – 1440

Start time of the segment within the day, in minutes

timestop

0 – 1440

End time of the segment within the day, in minutes

See also

Logical roles

  • b2b performs routing and applies redirect rules.

  • mdc and sdc search for redirect rules.