P-Asserted Identity

Complete newbie to Asterisk, it came as part of a Synology box and we needed a web phone system via Gamma SIP trunks. Managed to get extensions and trunk working and the only issue I have been having is with outbound Calling Line Identity over the SIP trunk. I have delved into extensions.conf and from another very useful post in this forum I discovered that I needed to comment out a line at the 7th line below.

This caused CLI to be correctly forwarded but my provide Gamma in the UK does not seem to recognise this. The do however support P-Assisted-Identity and after a lot of searching I came up with the content of line 6. This does work and called id is recognised, however it does not work perfectly as if there is no CLI set for the extension the call fails.

Can anyone help me with the syntax of how to correctly provision the P-Assisted-Identity.

exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,SIPAddHeader(P-Asserted-Identity: sip:${CALLERID(num)}@
;exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${ARG3}})} > 6]?${CID_${ARG3}}:${GLOBAL_OUTBOUNDCID})})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,Goto(1-dial,1)

With a current version of Asterisk:


in sip.conf.

You have already set PAI before line 6, so line 6 will have no effect on the PAI value sent.

Beware that Synology seem to use a discontinued GUI, so any questions about the GUI dialplan code should be addressed to them.