Skip to content

How to use variables 1.14.45

The Yeti variables mechanism allows you to attach custom variables to a call. These variables can be used across different routing stages and later applied in gateway templates. Typical use cases include:

  • Adding additional metadata to a call to simplify API integrations
  • Storing extra metadata in CDRs (call variables are saved in the CDR metadata attribute)
  • Using variables for templating and dynamic configuration in gateways

Assigning variables

Variables can be added to a call at multiple routing stages:

  • Customer Auth processing
  • Customer Auth Src Numberlist processing
  • Customer Auth Dst Numberlist processing
  • Routing Plan Src Numberlist processing
  • Routing Plan Dst Numberlist processing
  • Termination gateway Src Numberlist processing
  • Termination gateway Dst Numberlist processing

To add a variable, configure it in the variables attribute of Customer Auth, Numberlist, or Numberlist Item objects.

At each processing stage, newly added variables are merged with the existing set. If a variable with the same name already exists, its value will be overwritten. To remove a previously assigned variable, explicitly set its value to null.

Using variables in gateway

The primary purpose of variables is to influence how a call is sent to a gateway based on dynamic conditions. This is achieved through the templating mechanism available in the following gateway attributes:

  • Host (for termination gateways)
  • Term append headers req (for termination gateways)
  • Orig append headers req (for origination gateways)
  • Orig append headers reply (for origination gateways)

To reference a variable inside these attributes, use the following syntax: {{vars.var_name}}.

Example

Assume you need to add a P-Access-Network-Info header with the value GSTN;operator-specific-GI="<R1R2><INSEE>00";network-provided when sending a call to a termination gateway.

The values R1R2 and INSEE depend on the source number (CLI) used by the customer originating the call.

Assing variables depends on CLI

Create a Numberlist and corresponding Numberlist Items for each source number allowed for the customer. Depending on the matched source number, each Numberlist Item will define specific R1R2 and INSEE values in its variables attribute:

json
{
    "r1r2": "000",
    "insee": "12345"
}

The Numberlist must be assigned as a source Numberlist either in Customer Auth or in the Routing Plan.

Adding header template at termination gateway

Configure the Term append headers req attribute in the termination gateway as follows:

P-Access-Network-Info: GSTN;operator-specific-GI="{{vars.r1r2}}{{vars.insee}}00";network-provided

Results

  1. During call routing, variables are added to the call based on the matched source number.
  2. Before the call is sent to the provider, the template defined in the termination gateway Term append headers req attribute is evaluated, and the header is injected with the appropriate values.
  3. Call variables will be saved in CDR metadata attribute