Custom PAI for extensions

I have a trunk provider that requires PAI to be sent to do caller-id masquerade.

Now I added a second location to that PBX and inherited a second trunk.

Now calls are failing outbound because of the PAI from the first location being sent on all outbound calls.

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Adding P-Asserted-Identity)
exten => s,n,SipAddHeader(P-Asserted-Identity: sip:##########@corpBALLS.net )
exten => s,n(done),MacroExit()

So I am wondering if there is a little critical thinking that can be done to match extension this.

All of my main location extensions are 1XXX 2XXX where my second location is 3XXX.

Usually, one would not need a hook to send PAI – on a pjsip trunk, set Send RPID/PAI appropriately; for chan_sip use sendrpid=pai . Then, the Outbound CID for the extension (or the Outbound Route) will be sent on that trunk.

If you add a second trunk that requires the outbound caller ID to be sent differently, configure that trunk accordingly. If the new trunk does not allow control over caller ID at all, ensure that the only calls sent over that trunk are those for which the fixed CID is suitable.

The problem i’m having is call’s are being rejected when PAI is being sent on the second trunk.

The provider wants PAI in sip:(PilotNumber)@Their.DNS

Both trunks are ChanSIP trunks so no pjsip.

Something like:

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${custom}" != "SIP/trunkthatneedspai"]?done)
exten => s,n,NoOp(Adding P-Asserted-Identity)
exten => s,n,SipAddHeader(P-Asserted-Identity: sip:##########@corpBALLS.net )
exten => s,n(done),MacroExit()

Not tested, may have errors.

You are smarter then me when it comes to this. Defining the SIP trunk instead of the extensions might work.

I’m using extension routing to filter which extension uses each trunk.

can you explain the ${custom}

Also I’m guessing the trunkthatneedspai is the “Trunk Name” field under Connectivity > Trunks > Edit Trunk

There’s dialplan here you can use to set a sip header that can be applied to a specific trunk name and is channel agnostic. Your diaplan will only work for chan_sip trunks: Custom SIP header on outgoing calls

1 Like

Sorry to respond so late.

So you would suggest adding this to extensions_custom.conf over extensions_override_freepbx.conf

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,ExecIF($["${OUT_${DIAL_TRUNK}_SUFFIX}"!=""]?Set(trunk_name=${OUT_${DIAL_TRUNK}_SUFFIX}):Set(trunk_name=${OUT_${DIAL_TRUNK}}))
exten => s,n,Noop(Trunk Name: ${trunk_name})
exten => s,n,GoSubIf($["${trunk_name}"="V_C_R_Location"]?func-set-sipheader,s,1(P-Asserted-Identity: sip:#######[email protected]))
exten => s,n,MacroExit

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,ExecIF($["${OUT_${DIAL_TRUNK}_SUFFIX}"!=""]?Set(trunk_name=${OUT_${DIAL_TRUNK}_SUFFIX}):Set(trunk_name=${OUT_${DIAL_TRUNK}}))
exten => s,n,Noop(Trunk Name: ${trunk_name})
exten => s,n,GoSubIf($["${trunk_name}"="V_C_Location"]?func-set-sipheader,s,1(P-Asserted-Identity: sip:######[email protected]))
exten => s,n,MacroExit

No. Add it to extensions_custom.conf. You can only define the macro once, so it would look like:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,ExecIF($["${OUT_${DIAL_TRUNK}_SUFFIX}"!=""]?Set(trunk_name=${OUT_${DIAL_TRUNK}_SUFFIX}):Set(trunk_name=${OUT_${DIAL_TRUNK}}))
exten => s,n,Noop(Trunk Name: ${trunk_name})
exten => s,n,GoSubIf($["${trunk_name}"="V_C_R_Location"]?func-set-sipheader,s,1(P-Asserted-Identity: sip:#######[email protected]))
exten => s,n,GoSubIf($["${trunk_name}"="V_C_Location"]?func-set-sipheader,s,1(P-Asserted-Identity: sip:######[email protected]))
; add addn'l gosubif for each trunk needed
exten => s,n,MacroExit
1 Like

Even in the first case, you are just sending calller ID, so you should be setting that, and using sendrpid=pai, rather than explicitly adding a standard header. I’m not sure why the second provider needs it, unless they are misusing it for the account name, which some do. If they don’t need it, just set sendrpid=no for that provider. If they do, use the same tactics as suggested for setting the value of the header explicitly, to set the caller ID.

So i am using this for follow me to send the dialed number’s CID through and for some reason it’s not sending the matched PAI along with the dialed number

Also no match and insert into the header of the PAI on standard calls either.

no%20PAI_sangoma

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.