Service Logic Design
The following chapters describe the various child service logics that are sequentially chained within the Fusion product’s service logic.
For each service logic described, three key characteristics are outlined:
Customization Possibility: Whether the service logic can be customized to adapt the routing logic to the service provider’s specific needs and use cases. While most core service logics are not customizable—since they handle essential base services—some are designed to be customized, typically implemented as blank placeholders for custom logic.
Input Variables: The variables that the service logic expects to be present in order to perform its intended function. If these variables are missing, the service logic may fail with unexpected errors or behave unpredictably.
Output Variables: The variables that the service logic sets to enable further processing in the main service logic or in subsequent child service logics.
To understand how these child service logics are chained together within the main service logic, it is recommended to open the service logic editor on the main service logic and follow this guide in parallel.
The Fusion service logic defines four main chains of service logic flows. Some child service logics (such as Check CAC Limits) may be invoked from multiple chains. The chains are as follows:
Pre-Processing Chain: Extracts all necessary information from the SIP INVITE message, such as
trunk-group,trunk-context, and other signaling parameters required for subsequent processing.Inbound Chain: Identifies the called number in the data model, determines the associated configuration type, applies inbound services, enforces CAC (Call Admission Control) limits, and builds routes to reach the end-customer target.
Outbound Chain: Extracts the hierarchy of Group/Reseller/Distributor/Tenant, analyzes the destination number, applies blacklist, whitelist, and dial plan services, enforces CAC limits, applies on-net routing logic, and builds routes to reach the PSTN.
Post-Processing Chain: Shared by both the inbound and outbound chains, this chain is responsible for route prioritization and crankback handling before the call is relayed.
An overview of the chaining is provided in the diagram, with detailed steps omitted for clarity.
Extract SIP Information
This service logic extracts the trunk-group and trunk-context from the Contact header, and the number from the P-Asserted-Identity header, if it is present.
Customization Possibility: No
Input Variables: Default Call Descriptor
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
contact_tgrp | Mandatory | Contact tgrp parameter |
contact_trunk_context | Mandatory | Contact trunk-context parameter |
calling | Mandatory | P-Asserted-Identity header username if present |
Identify Carrier Trunk
This service logic identifies the source PSTN trunk of the INVITE by analyzing the trunk-group and trunk-context values. It also identifies the Fusion service provider.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
contact_tgrp | Mandatory | Used to query table service_provider_trunks |
contact_trunk_context | Mandatory | Used to query table service_provider_trunks |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
sp_trunk_name | Mandatory | Table service_provider_trunks column |
group_id | Mandatory | Table groups column |
context | Mandatory | inbound |
Search Inbound Destination
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
called | Mandatory | Used to query table service_provider_trunks |
search_number | Optional | Used to query table numbers |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
tenant_id | Mandatory | Table tenants column |
tenant_name | Mandatory | Table tenants column |
subscription_id | Mandatory | Table subscriptions column |
subscription_name | Mandatory | Table subscriptions column |
trunkgroup_id | Optional | Table connections column |
msteams_user_id | Optional | Table connections column |
number_id | Mandatory | Table numbers column |
Check CAC
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
cac | Optional | Records list according to format |
Output Variables
None
Service Disaster Recovery
This service logic applies the Disaster Recovery service, enabling fallback handling and routing continuity in case of service disruption.
INFO
This service logic may redirect to the Outbound Chain.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
trunkgroup_id | Mandatory | Used to query table trunkgroups |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
called | Optional | Service target number, if enabled |
Service Diversion
This service logic applies the Call Diversion service (also known as Call Forwarding), allowing calls to be redirected based on the configured diversion numbers.
INFO
This service logic may redirect to the Outbound Chain.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
trunkgroup_id | Mandatory | Used to query table trunkgroups |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
called | Optional | Service target number, if enabled |
Set CAC License Limits Inbound
This service logic can be overridden to set CAC limits based on various criteria. By default, it is implemented as an empty placeholder.
Customization Possibility: Yes
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
msteams_user_id | Optional | Target MS Teams user id (mutually exclusive with trunkgroup_id) |
trunkgroup_id | Optional | Target trunkgroup id (mutually exclusive with msteams_user_id) |
tenant_id | Mandatory | Tenant id |
subscription_id | Mandatory | Subscription id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
cac | Optional | Records list according to format |
Service Rewrite Number
This service logic implements the Number Rewriting service, which allows the end-customer to modify the dialed number before it is sent out through a trunk group.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
number_id | Mandatory | Number id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
called_number | Optional | Number to be rewritten to |
Build Teams Inbound Routes
This service logic builds the set of routes required to reach the Microsoft Teams Direct Routing infrastructure.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
group_id | Mandatory | Group id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
routes | Optional | Records list according to format |
Build PBX Inbound Routes
This service logic builds the set of routes required to reach the end-customer's PBX system.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
trunkgroup_id | Mandatory | Trunkgroup id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
routes | Optional | Records list according to format |
Build Peer Inbound Routes
This service logic can be used to customize how the set of routes is built to reach peer or service trunk groups. By default, it is implemented as an empty placeholder.
Customization Possibility: Yes
| Variable Name | Presence | Note |
|---|---|---|
trunkgroup_id | Mandatory | Trunkgroup id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
routes | Optional | Records list according to format |
Identify MS Teams
This service logic identifies the Microsoft Teams user based on the combination of the dialed number and domain.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
fromURI | Mandatory | From header URI |
calling | Mandatory | Calling number |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
allow_inbound | Mandatory | true|false |
allow_outbound | Mandatory | true|false |
context | Mandatory | Variable prefixed with outbound- |
Identify PBX Trunk
This service logic identifies the PBX trunk using the trunk-group and trunk-context values present in the SIP INVITE. If the trunk group was already identified earlier in the context of an inbound call, that trunk group ID is reused for identification.
Customization Possibility: No
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
contact_tgrp | Optional | Contact header tgrp parameter |
trunkgroup_id | Optional | Trunkgroup id |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
allow_inbound | Mandatory | true|false |
allow_outbound | Mandatory | true|false |
context | Mandatory | Variable prefixed with outbound- |
Identify Peer Trunk
This service logic enables the identification of a peer or service trunk by using any relevant information from the SIP INVITE or existing variables to match a trunk group defined in the trunk groups table. By default, it is implemented as an empty placeholder.
Customization Possibility: Yes
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
contact_tgrp | Mandatory | Contact tgrp parameter |
contact_trunk_context | Mandatory | Contact trunk-context parameter |
calling | Mandatory | P-Asserted-Identity header username if present |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
allow_inbound | Mandatory | true|false |
allow_outbound | Mandatory | true|false |
context | Mandatory | Variable prefixed with outbound- |
cac | Optional | Records list according to format |
Get Hierarchy
This service logic identifies the group, distributor, and reseller to which the current subscription belongs. Some levels may be omitted in cases of direct dependency.
Customization Possibility: No
Analyse Destination Number
This service logic determines whether the dialed number should be validated, and sets the formatted number to be used for applying blacklist, whitelist, and dial plan services. By default, the service logic sets the destination number to the called number, removing any leading + character.
Customization Possibility: Yes
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
destination_number | Mandatory | Number used for number validation services |
validate_destination_number | Mandatory | true|false (dial plan validation) |
Service Blacklist
This service logic applies the blacklist service uniformly to all subscriptions belonging to the service provider (group).
Customization Possibility: No
Service Whitelist
This service logic applies the whitelist service associated with the trunk group.
Customization Possibility: No
Validate Destination
This service logic validates the destination number against the dial plan assigned to the trunk group, considering any applicable override configurations that may restrict the dial plan.
Customization Possibility: No
Format Caller
This service logic can be customized to format the calling party number for outbound calls originating from a trunk group. By default, it is implemented as an empty placeholder.
Customization Possibility: Yes
Set CAC License Limits Outbound
This service logic can be overridden to set CAC limits based on various criteria. By default, it is implemented as an empty placeholder.
Customization Possibility: Yes
Input Variables
| Variable Name | Presence | Note |
|---|---|---|
msteams_user_id | Optional | Target MS Teams user id (mutually exclusive with trunkgroup_id) |
trunkgroup_id | Optional | Target trunkgroup id (mutually exclusive with msteams_user_id) |
Output Variables
| Variable Name | Presence | Note |
|---|---|---|
cac | Optional | Records list according to format |
Search Inbound Destination On-Net
This service logic attempts to determine whether the called number in an outbound call belongs to a Fusion customer; if so, additional processing is required.
Customization Possibility: No
INFO
This service logic may redirect to the Inbound Chain.
Get outbound routes
This service logic builds the set of routes required to send the call to the PSTN.
Customization Possibility: No
Standardized Variable Formats
This chapter describes the required format for certain standardized variables that must be followed to ensure correct execution of the service logic.
cac
When defined, the cac variable must be a records list composed of several columns:
id: Aggregation idmax_total: Maximum number of simultaneous callsmax_out: Maximum number of outbound simultaneous callsmax_in: Maximum number of inbound simultaneous calls
routes
When defined, the routes variable must be a records list composed of several columns:
ruri: Request URIip_port: IP and port of SBC to relay the call to, with format<ip>:<port>
