I’m trying to pass a PAI that’s different than the phone number in the “From” header, but only on a specific PJSIP trunk.
Following Stewart1’s advice in Overwriting P-Asserted-Identity on PJSIP trunk was very helpful as it did the trick, but unfortunately it also applies to all other trunks, which adds an irrelevent PAI to calls routed out through these other trunks.
In extensions_custom.conf I have the following, where 6030000000 is a dummy DID for the purpose of this post
[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Adding PAI)
same => n,GoSub(func-set-sipheader,s,1(P-Asserted-Identity,sip:[email protected]\;user=phone))
same => n,MacroExit()
Is there an ExecIf that I could use on that 2nd line to only apply when it is executed on a call going out through the trunk named “Trunk123” ? ${OUT_${DIAL_TRUNK}} seems to return “PJSIP” so it is not of much help.
Why are you trying to do this. The common reason is that the From header contains a, fixed, account id, and the PAI contains the real caller ID, in which case set the From header in the trunk definition and use the builtin PAI support.
Because I need to have a different PAI and From in this specific scenario.
My provider requires me to “validate” who I am with the use of the PAI. I want to use my toll free number as the caller id (which is not provided by this carrier) and I need to send one of my valid DID in the PAI field so that the call can go through and that I am billed accordingly for long distance.
Yes by DID I mean a PSTN number. The carrier is one of the Big 3 canadian carrier, I guess they know their stuff. I know that I have to set it manually, that is exactly what I am trying to do here, which worked, but I want to assign it to a specific trunk only since my other 2 trunks are with another carrier and do not need this as they are used for a different purpose and use their real PSTN numbers for dialing out.
the GoSub call would work by itself, but as soon as I entered it as a result of a successfull “ExecIf”, it would not run. The solution was to replace ExecIf by GoSubIf and everything works perfectly
[macro-dialout-trunk-predial-hook]
exten => s,1,Set(the_trunk_raw=${OUTNUM}${OUT_${DIAL_TRUNK}_SUFFIX})
same => n,Set(the_trunk=${CUT(the_trunk_raw,@,2)})
same => n,GoSubIf($["${the_trunk}"="Trunk123"]?func-set-sipheader,s,1(P-Asserted-Identity,<sip:[email protected]\;user=phone>))
same => n,MacroExit()
I’ve seen big companies implement things wrongly several times. The thing about being big is that the smaller people have to work round your mistakes. Asterisk assumes that From user is the constant, representing the account and PAI is the variable, representing the caller ID.