PAI and CID on 'common' trunks

Hi All,
This is my second FreePBX install, but the first where I can’t solve the problem myself.

PBX Firmware: 12.7.5-1807-1.sng7
PBX Service Pack:

As far as I’m aware this is the latest/current version, and I have all the updates applied.

My Trunk provider is Spark Voice Connect (New Zealand).
They have given me 1 account, which has a couple of DID’s attached.

They require me to send a PAI as part of the outgoing call authentication process.

The only way I can do this is to have the extension CID set as the Account number, and have the options in Extension/Advanced set as -
TrustRPID ‘Yes’
SendRPID “Send P-Asserted-Indentity header”

Then I need to set the extension Outbound CID to the account number Spark are expecting, so they get the correct PAI.

This creates a few problems though.

The account number (as needed by Spark in the PAI) doesn’t have any calling rights, so it can’t make a call.

And even when they allow calling rights (temporary for testing), the CID is obviously wrong, as it shows the account number, not the CID for the DID.

I’m really stuck here as I’ve been pulling my hair out for the last couple of days, and I’m starting to feel the guys at Spark are loosing patience with me.

How can I send the PAI of the account, and also send the CID of the DID?

I hope someone can help me, and I hope that I can understand what you suggest or request.

Thank you in advance for your help.

Cheers, Sean

Do I understand correctly that you want the outbound caller ID in the From header and the account number in P-Asserted-Identity?

If so, configure the trunk so it doesn’t set PAI at all (From will contain the caller ID propagated from the extension). Then, use some custom dialplan to set PAI:

On a chan_sip trunk, this is easy. In extensions_custom.conf, put some code like:

exten => s,1,SipAddHeader(P-Asserted-Identity: <12345678>)
exten => s,n,MacroExit()

where 12345678 is the account number. This will of course be more complex if you have multiple trunks with different account numbers and/or trunks from other providers where you don’t want to monkey with the header.

I’ve not done this with pjsip, but there are some gotchas. See @maple solution in Add custom SIP header to PJSIP trunk , which I hope will work for you.

I’d not heard of Spark Voice Connect before and looked at their website. Alas, I found only marketing speak. If you want to try another trunking provider (as a workaround for the present problem, as a backup provider, or perhaps as your main provider if rates and/or quality prove superior to Spark), take a look at AnveoDirect and Voxbeam. Both provide a small credit at signup so you can test without making a payment or providing any financial information. Both allow sending an arbitrary caller ID and don’t require any special headers.

Prices below are in US dollars.
AnveoDirect’s NZ rates on their ‘Prime’ route are $0.00835/min. (landline) and $0.02662/min. (mobile). Voxbeam’s ‘Platinum’ route is $0.01 (Auckland), $0.0116 (other landline), $0.034 (mobile).

If this is a Chan_SIP trunk then you do

If this is a PJSIP trunk then you go under the Advanced tab of the trunk settings and set the CallerID options to PAI.

Those setinngs will use PAI for the CallerID

Hi Tom,
Cool, I feel a bit better because I’ve already worked through this.
I need the account code as PAI, not the caller ID (these are different and have several DID’s on same trunk).

Hi Stewart1,
Yes, you’ve got me in one with your opening question.

I’ll do as you have suggested, I’ll change to chan_sip and add the line in the extensions_custom.conf file.

I’ll do this on Friday and see how it goes.

Will there be any ongoing issues with using chan_sip rather than pjsip? Wil chan_sip one day stop being supported? Do you know?

As for Spark Voice Connect, I have a document that I could share with you. How can I get this to you?

Their comments on PAI are -
3.2.6 P-Asserted-Identity: Header
Calls from the PBX to Voice Connect.
The use of the P-ASSERTED-IDENTY: header is supported and for new dialog call
attempts the INVITE must contain a Pilot AOR (Address of Record) if it is being
used for Trunk Group Identification ( TGI)

I love the way they say ‘supported’, when they really mean ‘required’ :slight_smile:

Thank you again for your help. If you want the Spark Voice Connect PBX Interface guide, please let me know how to send it to you.

Cheers, Sean

Since they are requesting an AOR, your extensions_custom.conf should probably be something like:

exten => s,1,SipAddHeader(P-Asserted-Identity: <sip:[email protected]>)
exten => s,n,MacroExit()

If you still have trouble, at the Asterisk command prompt type
sip set debug on
and make a failing call, to view what is being sent.

I found online; is that the same as your guide?

I’m also interested in Spark’s pricing, if you are permitted to share that.

Hi Stewart1,
Thanks for oyur help with this. The actual uri will be

The doc I have is about a month newer than the one you refer to. It is also rebranded with the Spark branding (the new identity of Telecom NZ).
How can I send it to you?

Spark’s pricing is pretty high compared to other providers. They are the original Telco in New Zealand (ex Telecom NZ).
Cost is around NZ$16 per channel, per month. DDI’s are just under NZ$1 per month. This only includes local calls, not toll calls.

If you want a fairly low cost NZ provider for ‘normal’ usage, the best option is 2talk NZ (http:// www. 2talk They have some good rates for higher usage.
I personally use didlogic for my system at home (https:// didlogic .com/). Their nearest server is in Sydney (40ms max), which works ok.

Thanks again for your help.

Cheers, Sean

PS, sorry for breaking up the URL’s, I can’t post links…

Hi Stewart1,
Thanks for your help with this.
Did as you suggested, changed SIP driver to CHAN_SIP, and added the lines you suggested (updated the URI to suit the provider), and it all worked well.
There are a couple of other gotcha’s with Spark Voice Connect, but we got there in the end.

At some stage I’ll have to revisit this (if they wish to connect to another VoIP provider), but for now I’m sorted.

Thanks again for the help.

Cheers, Sean

I am really struggling get my Spark Sip trunk working, registers ok but cannot make or receive calls. Can you let me know what settings you used (Spark Gotcha’s).



Hi Dencom,
I have a document mostly completed to explain all my settings.
This should be enough for you to sort it out. The guys at Spark are also really useful at sharing screen-shots of what they see. And definitely use the SIP logging feature to compare the messages you see, with what Spark sees.
And I couldn’t have done what I did without the help from Stewart.

If you send me your email address, I’ll send you my (mostly) completed how-to.

Cheers, Sean

Thanks, that would be much appreciated. [email protected]


Thanks, that information worked perfectly.


Hi sslewis698
I am having the same problem as mentioned by dencom in that I can register the chan_sip trunk but can’t make or receive calls is it possible to get the same doc you sent to dencom [email protected]

Hi Mike,
I’ve just emailed it to you.

Remember, credit where it is due, I wouldn’t have been able to get it sorted without Stewart1’s help.

Cheers, Sean

Hi sslewis698

I have just configured my freepbx with Spark sip, while SIP is registered I can’t make any calls.
I am guessing I am missing something in the config file.

Could you please kindly share your solutions with me?
my email is:

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