Head Scratcher - Passing CID From from registrant through FreePBX

On Asterisk 13.22.0 and FreePBX

I have several lines that use traditional CID’s just fine. On 2 of these lines the endpoint (softphones) will are set to send different CID’s in the From header which is visible to Asterisk. The header may change throughout the day creating a variation in the From field. The problem is I need to pass these through the trunk and outbound route set up only for this purpose while retaining the CID in the From header. This trunk works fine except that it will only pass it’s own CID, not the one in the From from the registrant.

So I am using FreePBX and I cannot for the life of me figure out how to pass the From CID all the way through. In the PEER details of the trunk I tried to mess with fromuser= to no avail, even looking to see if there was a way to insert a variable in here.

I have read around that removing the CID’s from both the trunk and the outbound route would allow this however when I do this I get an “All circuits are busy now” message when trying to dial.

Is this possible with FreePBX? I have a suspicion that this will require Asterisk config mods and that’s totally fine I just don’t know where to start.

Any help would be GREATLY appreciated. I’m about in my 15th hour trying to resolve this.

First, get the Outbound CID field for a normal extension to pass through the trunk correctly. This entails having the Outbound Route and the trunk not forcing another CID. If your trunking provider requires an account number or main DID in the From user field, they will usually accept the caller ID in P-Asserted-Identity (use sendrpid=pai) or Remote-Party-ID (use sendrpid=yes). You have to use the right format. Depending on provider, they may want e.g. 2123456789, 12123456789 or +12123456789.

Once that’s working, if the softphone will be sending only a few CID values, I recommend creating an extension for each one and changing the extension number as needed in the softphone. If they are in a block, you could change e.g. the last digit of the extension number to select the desired CID. If the extensions all have the same secret, no other change will be needed.

If sending an arbitrary CID is needed, it would be easiest to set up the softphone as a trunk, with context=from-internal or similar. This method unfortunately removes features such as voicemail, follow-me, etc. If you also need those features, I believe that custom dialplan code is required.

Stewart1, thank you.

Removing the CIDS from the trunk and the outbound route and then dialing with a CID on the extension works. If all three lack a CID I get the circuits message. sendprid had been set. My carrier, Flowroute, accepts the CID in just about any format.

How would I go about setting up the softphone as a trunk? That confused me but I am interested. I don’t need voicemail or anything else here. Can you give me a rundown of what that setup looks like?

Assuming chan_sip, try something like:

host=(ip address of softphone)
port=(bind port of softphone)

(You may also need settings for codecs, etc.)

In this case I wouldn’t be able to transfer a call to another extension on the PBX, correct?

Sorry, I don’t know. It’s possible that a SIP REFER would work; you’ll have to test that.

I would expect that if you set the T option for the outbound trunk (not the softphone trunk), the softphone could use the DTMF transfer features.

Is it practical to just use a block of extension numbers, or do you have too many CIDs to send?

There is a factor that has been missed in all of this and that is, Asterisk is a Back-to-Back Agent. So the actual CallerID sent from the softphone (that is an extension on the PBX) is moot. Because that CallerID is only valid when the call is initiated. After that the PBX assigns the CallerID to be used, either internal or external, that will be set on the called channel(s).\

The softphone is going to make the call, Asterisk is going to look at the From User for auth and that’s it. After the call is authed, the system is going to lookup the cidname/cidnum, the Outbound CID and the Emergency CID assigned to the extensions user. By default the cidname = Extension Name, cidnum = Extension Number. These will be used for internal calls.

If there is an external call and the Outbound Route or Trunk are not overriding the CallerID of the extension, the Outbound or Emergency CIDs will be used for external calls out. If those aren’t set it will use the internal CallerID as default.

I have way too many CIDs.


After hours and hours here is the SOLUTION in case anyone ever comes across this.

I made a copy of my existing trunk so that I can apply rules to it in following steps. No additional changes are really needed assuming your first trunk works just fine.

I installed the Custom Context module (you have to search around for it) and made a new context (just a name)

For the extensions I needed to customize the CID I pointed their contexts to use to the context in the next step.

I created a custom dialplan context in extensions_custom.conf that would use this new trunk copy. This context uses AGI which is a way to run a script (like PHP, ruby, BASH) and this script returns the caller id to use based on my needs and the information I passed to it. I pass the dialed number to it through AGI, AGI runs the script I made to check some conditions based on the EXTEN, then passes back the CID to use.

Then the context is set to dial the call through the trunk copy packaged up all nice with the caller id returned from the script.

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