Reading Parameters from REFER Call

Hi everyone,

I am calling from Twilio to asterisk like this:

<?xml version="1.0" encoding="UTF-8"?> sip:xx.xx.68.27?X-languageId=293

I need to receive that call, and that part is working fine.

After that, I need to dial a third-party SIP, which is also working. The call goes to the third party correctly.

Here is my dialplan snippet:

[from-twilio]

exten => s,1,NoOp(— REFER RECEIVED —)
same => n,Set(REFER_TO=${PJSIP_HEADER(read,Refer-To)})
same => n,NoOp(Refer-To header: ${REFER_TO})

; Extract the portion after ‘X-languageId=’
same => n,Set(LANG_PARAM=${CUT(REFER_TO, X-languageId=, 2)})

; LANG_PARAM now contains ‘293>’ or more, so strip trailing chars
same => n,Set(LANGUAGE_FROM_ID=${CUT(LANG_PARAM, >, 1)})

same => n,NoOp(Extracted X-languageId: ${LANGUAGE_FROM_ID})
same => n,Goto(thirdparty-backup,s,1)

The issue is I am unable to read the URI parameters sent from Twilio. I need to read the parameter from Twilio and pass it to the third party.

If I pass a static parameter hardcoded, it works fine, but I want to pass the language parameter from Twilio to the third party dynamically.

Here are some relevant log lines showing empty variables:

Set(“PJSIP/twilio0-00000217”, “REFER_TO=”) in new stack
NoOp(“PJSIP/twilio0-00000217”, "Refer-To header: ") in new stack
Set(“PJSIP/twilio0-00000217”, “LANG_PARAM=”) in new stack
Set(“PJSIP/twilio0-00000217”, “LANGUAGE_FROM_ID=”) in new stack
NoOp(“PJSIP/twilio0-00000217”, "Extracted X-languageId: ") in new stack
Goto(“PJSIP/twilio0-00000217”, “thirdparty-backup,s,1”) in new stack
NoOp(“PJSIP/twilio0-00000217”, “— THIRD PARTY BACKUP CALL STARTED —”) in new stack

This retrieves the “Refer-To” header on the SIP INVITE. It doesn’t retrieve from a REFER. The “SIPREFERTOHDR” dialplan variable should contain the contents of the Refer-To header.

Thanks

The request is like this

REFER sip:asterisk@xx.xx.xx.27:5060 SIP/2.0

CSeq: 1 REFER

From: sip:+447401120267@xxxxx.sip.twilio.com;tag=41323510_c3356d0b_19a1cfae-bb51-4c33-add2-b24681115e07

To: “+44x” sip:+44xxxx@xx.xx.68.27;tag=633c05dc-ba7b-4f17-bf18-5c044de913e0

Call-ID: 57d6ce75-7ea2-41e4-8946-e697a8c05e0b

Max-Forwards: 68

Contact: sip:+447xxxx@xx.xx.41.192:5060

Via: SIP/2.0/UDP xx.xx.60.1:5060;branch=z9hG4bK33a5.33386b0d2d9fd23d64a605658a57f16c.0

Via: SIP/2.0/UDP xx.xx.41.192:5060;rport=5060;received=xx.xx.182.71;branch=z9hG4bK19a1cfae-bb51-4c33-add2-b24681115e07_c3356d0b_82-17835089868081853096

Refer-To: sip:xx.xx.xx.27?X-languageId=293

User-Agent: Twilio Gateway

X-Twilio-CallSid: CA1d23e757f906cd3eb958dda5d17d5384

Content-Length: 0

and logs are like this Executing [s@from-twilio:3] NoOp(“PJSIP/twilio0-0000021a”, “Refer-To header: sip:xx.xxxx.27”) in new stack
Executing [s@from-twilio:4] Set(“PJSIP/twilio0-0000021a”, “LANG_PARAM=”) in new stack
Set(“PJSIP/twilio0-0000021a”, “LANGUAGE_FROM_ID=”) in new stack
NoOp(“PJSIP/twilio0-0000021a”, "Extracted X-languageId: ") in new stack

I want to read the language id

Hi

@jcolp My request is like this Refer-To: sip:xx.xx.xx.27?X-languageId=293 How i can read the language id
If you see my logs SIPREFERTOHDR only provide this part sip:xx.xx.xx.27

Thanks

Please don’t tag me. If I have anything to add I will do so, and I haven’t looked at the code for this yet but if you want an immediate response, the code that puts it in SIPREFERTOHDR may result in the stripping out of such a thing so you wouldn’t be able to without code modifications.