$dialer.getSipHeaders
The method returns the SIP headers of an inbound call:
- System headers:
call-id
,cseq
,contact
,from
,max-forwards
,refer-to
,to
,via
. - Custom headers. Specify them in the SIP headers parameter in the telephony settings.
tip
For more information on working with headers, see SIP headers.
Syntax
The method is called without arguments:
$dialer.getSipHeaders();
Return value
The method returns an object with headers and their values:
{
"cseq": "12345 INVITE",
"contact": "<sip:userA@hostA>",
"call-id": "abc123",
"max-forwards": "70",
"from": "<sip:userA@domainA>;tag=tagA",
"to": "<sip:userB@hostB>",
"via": "SIP/2.0/UDP hostB:5060;branch=z9hG4bKbranchA",
"X-Example": "Example" // Custom header
}
- System headers are in lower case.
- Custom headers are in the same case used in the SIP headers setting.
How to use
For this example, we specify a custom X-Call-Purpose
header 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
- Bot gets the headers in the start state.
- In the
Order
state, the bot informs about a discount if theX-Call-Purpose
header has thepromo
value.