Get caller name from SIP_HEADER(Remote-Party-ID)

The SIP_HEADER function returns

"caller-name" <sip:1000@192.168.1.1:5060>;party=calling;privacy=off;screen=no"

Now I would like to extract caller name from it (“caller-name”) so I created below

same => n,Set(MYCALLERNAME=${CUT(SIP_HEADER(Remote-Party-ID), ,1)})
same => n,Set(CALLERID(name)=${MYCALLERNAME})

The name needs to be without quotes

The Set above works fine but sometimes It does not work with strange names.

Is there a better way to get the name without using the CUT() functions??

trustrpid=yes in sip.conf

How will that affect the dialplan?

It will cause chan_sip to use the Remote-Party-ID information for the callerid set of dialplan functions, thus chan_sip will be the one parsing the header and interpreting it. This is what most people do instead of trying to parse it themselves.

1 Like

Thanks for your help, understood now