Skip to main content

$dialer.getSipHeaders

The method returns the SIP headers of an inbound call.

To use the method:

  1. Go to telephony settings. In the SIP headers field, specify the headers that the bot must extract from the SIP INVITE message when there is an inbound call.
  2. Add $dialer.getSipHeaders to the script start state.

Syntax

The method is called without arguments:

$dialer.getSipHeaders();
caution

Use $dialer.getSipHeaders only in the start state of the script. In other states, the method always returns undefined.

Return value

The method returns an object with headers and their values:

{
"Call-ID": "1234abcde",
"X-Example": "Example"
}

If a header is missing in the SIP INVITE message, it will not be added to the object.

How to use

For this example, we will specify X-Call-Purpose in the SIP headers setting, so that the bot can get this header in the script.

state: Start
q!: $regex</start>
a: Hello!
script:
$session.sipHeaders = $dialer.getSipHeaders();

state: Order
intent: /order
if: $session.sipHeaders["X-Call-Purpose"] === "promo"
a: Today we have a 20% discount
  1. Bot gets the headers in the start state.
  2. In the Order state, the bot informs about a discount if the X-Call-Purpose header has the promo value.