Skip to content

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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 NamePresenceNote
contact_tgrpMandatoryContact tgrp parameter
contact_trunk_contextMandatoryContact trunk-context parameter
callingMandatoryP-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 NamePresenceNote
contact_tgrpMandatoryUsed to query table service_provider_trunks
contact_trunk_contextMandatoryUsed to query table service_provider_trunks

Output Variables

Variable NamePresenceNote
sp_trunk_nameMandatoryTable service_provider_trunks column
group_idMandatoryTable groups column
contextMandatoryinbound

Search Inbound Destination ​

Customization Possibility: No

Input Variables

Variable NamePresenceNote
calledMandatoryUsed to query table service_provider_trunks
search_numberOptionalUsed to query table numbers

Output Variables

Variable NamePresenceNote
tenant_idMandatoryTable tenants column
tenant_nameMandatoryTable tenants column
subscription_idMandatoryTable subscriptions column
subscription_nameMandatoryTable subscriptions column
trunkgroup_idOptionalTable connections column
msteams_user_idOptionalTable connections column
number_idMandatoryTable numbers column

Check CAC ​

Customization Possibility: No

Input Variables

Variable NamePresenceNote
cacOptionalRecords 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 NamePresenceNote
trunkgroup_idMandatoryUsed to query table trunkgroups

Output Variables

Variable NamePresenceNote
calledOptionalService 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 NamePresenceNote
trunkgroup_idMandatoryUsed to query table trunkgroups

Output Variables

Variable NamePresenceNote
calledOptionalService 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 NamePresenceNote
msteams_user_idOptionalTarget MS Teams user id (mutually exclusive with trunkgroup_id)
trunkgroup_idOptionalTarget trunkgroup id (mutually exclusive with msteams_user_id)
tenant_idMandatoryTenant id
subscription_idMandatorySubscription id

Output Variables

Variable NamePresenceNote
cacOptionalRecords 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 NamePresenceNote
number_idMandatoryNumber id

Output Variables

Variable NamePresenceNote
called_numberOptionalNumber 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 NamePresenceNote
group_idMandatoryGroup id

Output Variables

Variable NamePresenceNote
routesOptionalRecords 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 NamePresenceNote
trunkgroup_idMandatoryTrunkgroup id

Output Variables

Variable NamePresenceNote
routesOptionalRecords 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 NamePresenceNote
trunkgroup_idMandatoryTrunkgroup id

Output Variables

Variable NamePresenceNote
routesOptionalRecords 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 NamePresenceNote
fromURIMandatoryFrom header URI
callingMandatoryCalling number

Output Variables

Variable NamePresenceNote
allow_inboundMandatorytrue|false
allow_outboundMandatorytrue|false
contextMandatoryVariable 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 NamePresenceNote
contact_tgrpOptionalContact header tgrp parameter
trunkgroup_idOptionalTrunkgroup id

Output Variables

Variable NamePresenceNote
allow_inboundMandatorytrue|false
allow_outboundMandatorytrue|false
contextMandatoryVariable 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 NamePresenceNote
contact_tgrpMandatoryContact tgrp parameter
contact_trunk_contextMandatoryContact trunk-context parameter
callingMandatoryP-Asserted-Identity header username if present

Output Variables

Variable NamePresenceNote
allow_inboundMandatorytrue|false
allow_outboundMandatorytrue|false
contextMandatoryVariable prefixed with outbound-
cacOptionalRecords 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 NamePresenceNote
destination_numberMandatoryNumber used for number validation services
validate_destination_numberMandatorytrue|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 NamePresenceNote
msteams_user_idOptionalTarget MS Teams user id (mutually exclusive with trunkgroup_id)
trunkgroup_idOptionalTarget trunkgroup id (mutually exclusive with msteams_user_id)

Output Variables

Variable NamePresenceNote
cacOptionalRecords 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 id
  • max_total: Maximum number of simultaneous calls
  • max_out: Maximum number of outbound simultaneous calls
  • max_in: Maximum number of inbound simultaneous calls

routes ​

When defined, the routes variable must be a records list composed of several columns:

  • ruri: Request URI
  • ip_port: IP and port of SBC to relay the call to, with format <ip>:<port>