Hello,
I’m trying to extract the Display Name in the From URI from the SIP header in the INVITE and place it in an Asterisk variable, however it looks like the PJSIP functions I’m using are not working.
This is my setup until now:
extensions_custom.conf
[macro-dialout-trunk-predial-hook]
exten => s,1,Set(CUSTOM_FROM_SIP_HEADER=${PJSIP_HEADER(read,From)})
exten => s,n,Set(CUSTOM_FROM_DISPLAYNAME=${PJSIP_PARSE_URI_FROM(CUSTOM_FROM_SIP_HEADER,display)})
For example, I have the following From and Contact header in the INVITE:
From: "Test456" <sip:[email protected]>;tag=cb13bd4de9b3473da8c110e2ef3b5d68
Contact: <sip:[email protected]:62627;ob>;expires=299
However, when I try to place a call and see the result of my code, I get:
[2025-02-24 08:24:03] VERBOSE[5417][C-00000001] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] Set("PJSIP/1000-00000000", "CUSTOM_FROM_SIP_HEADER="Test456" <sip:[email protected]>;tag=fe91110cd42840cb8798b65759226559") in new stack
[2025-02-24 08:24:03] WARNING[1907] pjsip/dialplan_functions.c: Failed to parse URI '"Test456" <sip:[email protected]>;tag=fe91110cd42840cb8798b65759226559'
[2025-02-24 08:24:03] VERBOSE[5417][C-00000001] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:2] Set("PJSIP/1000-00000000", "CUSTOM_FROM_DISPLAYNAME=") in new stack
Could someone help me understand my mistake?
I would like to have the display name in a custom variable to be further used. I see there are also functions to work with the Contact header.