Telephone call servicing
Overview
The system services connected SIP subscribers. It authorizes and routes their calls (INVITE) to other subscribers or services.
Connection to the system is possible:
-
From below (sipusers class) — subscriber devices and PBXs; the platform can act as a registration server or a node without registration.
-
From above (providers class) — PSTN access providers, backbone PBXs, other PBXs or softswitches with a separate number plan, acting as a registration server or a node without registration.
The connection method is dictated by
-
the device type,
-
the presence and direction of registration,
-
the separateness of the number plan.
An incoming call arriving from a device connected under a sipuser account enters the system through the outbound proxy (SG microservice) and is considered internal. An incoming call arriving from a device connected via a provider account enters the system through the gateway (ESG microservice) and is considered external.
On the ESG microservice, for an incoming invite, the account is searched and normalization rules are applied:
-
provider_callerids class — number normalization rules.
These are transformations of To and From numbers and From-displayname before submission to routing. ESG is a back-to-back user agent, and for an INVITE request incoming from outside it forms a new INVITE request into the system with a different Call-Id.
Any successful call results in a conversation of two subscribers. Three servers handle SIP signaling of each conversation. From 0 to 3 media gateways handle media traffic of each conversation; in normal mode — 1 media gateway. How leg codecs are negotiated — in the article Codecs and media negotiation.
Conversation of two internal subscribers. |
Conversation of an external subscriber with an IVR script. |
Call servicing process
Any call lands on one of the B2B (back-to-back user-agent) microservice instances and is serviced there.
Call servicing is a state machine. Each successful call passes sequentially through three key stages: routing, forking, and dialog. All main events in the servicing process form the callevents event stream.
So the servicing process begins with receiving an incoming INVITE request.
| callevents event: invite |
Routing stage (routing)
At the routing stage the called side is determined, along with the possibility of calling it.
The first routing step is determining the called side from the incoming request. The output after the first step is a list of called side directions (URIs, routes, and rules for calling them). This can be one or several users, external numbers, services, one or several devices, one or several URIs.
Routing proceeds in cascade and may be performed several times with changing input parameters. First, routing rules are iterated and a specific rule is found by incoming request parameters. For flexibility, two-level class-based routing is used:
-
routes class — routes (vectors)
-
vectorrules class — routing rules
Depending on its type, the process follows one of the branches: call outside, call an internal subscriber, call a service, or call another domain. Further branching of the process may occur along each of these directions. At this step the following classes may be applied:
-
featurecodes class — subscriber feature and service codes;
-
featurerules class — rules for access to service features;
-
ivrscripts class — IVR script metadata;
-
redirectrules class — redirection rules;
-
providers class — provider accounts for connecting to uplinks;
-
sipusers class — internal subscriber accounts for connecting downstream devices;
-
sipgroups class — group numbers with a parallel-sequential call plan;
-
sipkits class — feature groups;
-
hunt class — hunt groups and personal queues (formed automatically).
Group numbers, feature groups, redirections, feature codes — may lead to an additional routing process with new call parameters. Subscriber unavailability, provider unavailability — may lead to applying the next matching routing rule by priority or to refusal. Prohibition of the direction call, absence of a direction, empty called subscriber list — lead to refusal without proceeding to the next stage. Also in some cases the call may end by proxying to another target B2B instance.
|
callevents events:
|
The second routing step is the representation of the calling subscriber to the called one. The output after the second step is the From number for each direction. Except when the call occurs inside one domain, the number of subscriber A for called subscriber B can be customized using the class:
-
representatives class — representation rules.
If routing reveals several called subscribers (directions), then for each direction leading to another domain, representation is performed individually (A → B1, A → B2).
Forking stage (forking)
At the forking stage, according to the plan, outgoing INVITE requests (fork-INVITE) are sent.
| callevents events: dlg_init, dlg_call, dlg_binding |
For each sent request a new Call-Id is formed, a port for the prospective media session is opened on the media gateway, and SDP is formed. Sessions with identical parameters are merged and not multiplied within one incoming call. The stage ends when the first final 2XX response to any of the sent INVITE requests is received.
Alternative branches are:
-
call pickup by another incoming INVITE (callevents event: dlg_pickup),
-
receiving a final response from each sent INVITE request,
-
timeout waiting for a response.
During the call, redirections may occur. 3XX responses are checked and may initiate a new dedicated routing process whose results are added to the current called direction list.
| callevents event: fork_redirect. |
Redirections may also occur on receiving unsuccessful final 4XX-6XX responses from subscribers (sipusers class) as a result of applying typed redirection rules (redirectrules class — redirection rules)
| callevents event: user_redirect. |
Already at the forking stage, 183 Session Progress responses containing a media session description may arrive. Such responses start media exchange with the calling subscriber. System behavior in a multiple call with several 183 responses may lead to collisions on subscriber devices. This case is atypical; there are several conceptual ways to handle it.
| callevents events: fork_start, fork_preanswer, fork_answer, fork_cancel, fork_stop, fork_redirect — for each outgoing call. |
Dialog stage (dialog)
An answered call becomes a dialog.
| callevents event: dlg_start. |
A call that reached the dialog state has two legs — one for the calling side (A) and the second for the called side (B). (In some cases the called side may be the pickup side that sent an INVITE to a special suitable number into the system).
At dialog start its type is determined — intra-domain or cross-domain.
Also at dialog start the need for recording is determined by iterating recording rules in descending priority order (recordrules class — recording rules). For cross-domain calls recording rules are applied in both domains. A recording rule can activate recording by platform means and saving to the specified storage, as well as recording by external SIPREC RFC 7866, 7865 means. If at least one of them has platform recording enabled, recording is enabled on the media gateway serving the media context. For each domain that ordered it, the storage for subsequent recording placement is determined (storages class — connections to storages and file storages), and transcription rules are applied (asrrules class — transcription rules), determining whether this operation will be performed after dialog completion. In domains that ordered external recording, SRS server endpoints are determined to which special SRC-INVITE requests with media sessions copying the traffic of both dialog participants are sent.
| callevents events: rec_info — for each domain |
During the dialog, DTMF signals may arrive from either leg. They are forwarded to the other leg with possible protocol conversion (RFC-2833 or SIP-INFO).
| callevents events: dtmf — for each received character |
During the dialog, conversation recording may be paused and resumed (API)
| callevents events: rec_changed — for each request related to pause or resume, for one or both domains participating in the conversation, depending on the initial placement of recording rules. API. |
During the dialog, one leg (X) may put the other leg (Y) on hold. This is a re-INVITE changing the media session characteristic.
Mutual hold may also occur. For each side, unhold alternates with hold. Sound flows both ways when both sides are off hold. When one side is on hold, the system plays one of the hold melodies, configurable in the domain and in the platform as a whole. An exception is putting services on hold — the hold melody is not played toward them. Mutual not yet answered re-INVITEs receive a 491 Pending response with a random timeout in the range up to 1 second.
During the dialog a transfer may occur. This is a REFER from leg X which the system forwards to the other leg Y, as a result of which subscriber device Y initiates a new call in the specified direction. Information about the new call progress is forwarded by leg Y into the original call as NOTIFY requests and relayed to leg Y. Notification of a successful answer causes leg X to terminate the original dialog. At the same time notification of a final unsuccessful 4XX-6XX response causes the dialog to continue — for subscriber devices this is a callback with subsequent unhold. A two-step transfer follows a more complex scenario, as a result of which the REFER request arriving from leg X contains identification information about a third subscriber already in the dialog. In this case the system does not simply pass REFER further but performs a coordinating modification of identification values.
| callevents events: refer, refer_aborted — for each processed REFER request. |
At the same time all calls (up to three in a two-step transfer) are coupled by identifiers, information about which is supplied by callevents events at the moment the transferred call enters the system.
| callevents events: referring_invite. And in calls linked by transfer, callevents events: replaces_refer, replaces_invite, route_referred, route_replacing. |
If a media gateway is lost during the dialog, then given alternative media gateways in the configuration, a move to another media gateway occurs, new sessions are created, and re-INVITE with media session substitutions is sent to both dialog legs
| callevents events: media_migrate_done — for each media context migration. |
Recording is also formed anew, but after dialog completion the recordings are coupled during mixing.
If one of the signaling servers is lost during the dialog, then with conversation recovery mode enabled, instead of the dialog that lost signaling, a new call is formed between the same subscribers but with new identification data. The session identifier is preserved.
If the server with the current B2B instance is lost, the call transitions to servicing by the pickup service, which will interrupt media processing only when media traffic stops flowing in it. This service will start the post-processing process.
During the dialog an external CTI control command to complete the dialog may arrive — such a dialog is interrupted by the server with a BYE request sent to both legs. On receiving an incoming BYE request from either dialog leg, the request is redirected to the other leg and the dialog ends.
However, if a PCS (Post-Call-Survey) call evaluation script is assigned to the dialog in the corresponding direction, then on receiving a BYE request from leg X, instead of terminating leg Y, a transfer to the PCS script number is performed by sending a REFER request.
| callevents event: dlg_pcs. |
During the dialog any label can be assigned to the call by an external request. The label mechanism is used in particular by higher call center logic, for example to bind calls to sessions or to register PCS (quality evaluation script).
| callevents events: dlg_binding — for each external label modification. |
After completion
After dialog completion the system, already outside the B2B microservice servicing the call, performs the planned post-processing:
-
mixing (MIXER microservice. callevents event: call_rec_links),
-
placement in storages (RECMOVER microservice. callevents event: records_moved),
-
transcription (MWARE microservice. callevents event: call_asr).
All callevents events were sent to brokers, subscribers, tracking services, and context scripts.
This completes call servicing within the platform.