Capture sip header for outgoing invite

Quick question.

When the dialplan dials a number. A sip invite is being sent. Is it possible to capture a specific SIP header from that request? We need the Call-ID for later use.

Dialplan

The dialplan
[ctbVariableOutboundCallStartSuccess]
exten => 1,1,Verbose(Variable outbound call start success)
same => n,Dial(PJSIP/+${ctbEmployeeOutboundNumber}@${ctbSipProviderEndpoint},${ctbDialTimeOut},b(ctbVariableOutboundCallStartHeaders^addheader^1))

SIP Request

<--- Transmitting SIP request (1259 bytes) to UDP:xxx.xxx.xxx.xxx:5060 --->
INVITE sip:+xxx@xxx.xxx.xxx SIP/2.0
Via: SIP/2.0/UDP xxx:5060;rport;branch=z9hG4bKPjf768733a-99fd-4f7e-b436-63e7814fe061
From: "+xxx" <sip:+xxx@8xxx>;tag=28e30a9c-b7af-4361-bde1-fa8e9a814a15
To: <sip:+xx@xxx.xxx.xxx>
Contact: <sip:asterisk@xxx:5060>
Call-ID: d8b12f79-045d-414d-ab18-d74257a5729a
CSeq: 1813 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
CtbVisitorUserId: 0
Max-Forwards: 70
User-Agent: Asterisk PBX 20.5.2
Authorization: Digest username="xxx", realm="xxx", nonce="1706016309:0f4de1eb5732c50788c5d249b567d3a89bf494f4", uri="sip:+xxx@xxx.xxx.xxx", response="fbdfebab07327c9deb08fc9bda7e9671"
Content-Type: application/sdp
Content-Length:   334

v=0
o=- 1012811249 1012811249 IN IP4 xxx.xxx.xxx.xxx
s=Asterisk
c=IN IP4 xxx.xxx.xxx.xxx
t=0 0
m=audio 33582 RTP/AVP 0 8 18 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

You can’t capture headers, no, but the CHANNEL dialplan function[1] allows access to information about the PJSIP channel such as the Call-ID:

${CHANNEL(pjsip,call-id)}

[1] CHANNEL - Asterisk Documentation

Wow, that was fast, it’s working like a charm. Thank you !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.