Strip prefix from DID for incoming calls from a specific trunk

Hello.

I have a working FreePBX system, that is working just great.

I have about 30 extensions, all with 3-digit numbers.

For example, I have the extension 120, 121, 250, 251 etc

I have also a trunk configured, for outgoing and incoming calls.
This trunk is a connection with another PBX system, which I don’t have administrative access to it.

All the incoming calls from this trunk, has as DID a prefixed version of my extensions.
For example:
the incoming call for 333120 has to be routed to my extension 120.
the incoming call for 333250 has to be routed to my extension 250.

The current setup, has about 30 inbound routes (one for each extension), in the following format: DID 333120, Destination extension 120.

What I am asking, is if I can replace all those inbound routes, with 1 rule, that will strip the prefix (333) from the incoming calls, only from the specific trunk.

Thank you very much
George Betsis

Hello @gbetsis,

You can do that with a custom context on your trunk. Change the context to something like this:
from-other-pbx and add this context to your extensions_custom.conf file:

[from-other-pbx]
exten => _333XXX,1,Log(NOTICE, Incoming call from other pbx:${EXTEN})
same => n,Goto(from-internal,${EXTEN:3},1)

Reload you dialplan from the linux console like that: rasterisk -x'dialplan reload'

If you do not want to do that with this method, you can add a custom destination and use this context like that:
from-other-pbx,${EXTEN},1

and add a general inbound route like that: _333XXX that would route to the custom destination that you created.

You can delete your specific inbound route to test this general inbound route, and if it will work you will be able to delete the rest of the specific inbound routes.
Thank you,

Daniel Friedman
Trixton LTD.

No need for a custom context. Stay in the GUI.

Set your inbound route to point to a Custom Destination like @lgaetz says in this post.

2 Likes

Hi @sorvani, @lgaetz,

Thank you for the tip of using the from-did-direct context in the custom destinations module. I just wish that the GUI was way more flexible than today. It would have been much more easier to manage the Asterisk servers with the Freepbx framework.

Thank you,

Daniel Friedman
Trixton LTD.

I translate this to “I wish the easy way was a lot harder.”

They call it “drag-and-drool” for a reason. :slight_smile:

1 Like

Wishes are okay for Birthdays; pull requests are better for new features.

Thank you all for your help, especially @danielf and @sorvani.

I have done what I want, with two different ways (as proposed by all of you!)

First method: (more “clean” way)

(Step 1)
I have added to the incoming trunk, the following context:
context=from-old-pbx

(Step 2)
vi /etc/asterisk/extensions_custom.conf

[from-old-pbx]
exten => _333XXX,1,Log(NOTICE, Incoming call from OldPBX:${EXTEN})
same => n,Goto(from-internal,${EXTEN:3:3},1)

(Step 3)
Reload you dialplan from the linux console like that:
rasterisk -x'dialplan reload'

Second method: (100% GUI)

(Step 1)
I have added the following “custom destination”:

Target: from-did-direct,${FROM_DID:3,3},1
Description: Strip off the first 3-digits, and send the next 3-digits of DID

(Step 2)
I have added the following “Inbound Route”:

Description: Direct to DID
DID Number: _333XXX
Set Destination: Custom Destinations (Strip off the first 3-digits, and send the next 3-digits of DID)

Thank you all guys…

Now I have another issue that I have to figure out.

For all the extensions (I have 3-digit extensions), whenever a call is placed, and the call is leaving from the trunk “toOtherPBX”, I want to prepend my site’s prefix, which is “333” to the outgoing CallerID.

So, for example, if a call is placed from extension 120, I want to set the CallerID to 333120.

I don’t want to use the “Outbound CID” field, because I use it to set the CallerID for the Public Outside Phone Network, which is reachable with another trunk named “toOutsideWorld”.

So, what I am asking is how can I prepend to the CallerID, my site’s prefix (which is “333”) to all my extensions, when a call is being placed through a specific trunk.

Thank you very much.

Hello @gbetsis,

Change your custom context to this:

[from-old-pbx]
exten => _333XXX,1,Log(NOTICE, Incoming call from OldPBX:${EXTEN})
same => n,Set(CALLERID(all)=333${EXTEN:3:3})
same => n,Goto(from-internal,${EXTEN:3:3},1)

Thank you,

Daniel Friedman
Trixton LTD.

Thanks @danielf for your fast reply. I appreciate your help.

Although, the line you provided:
same => n,Set(CALLERID(all)=333${EXTEN:3:3})
changes the CallerId for the incoming calls (from the specific trunk), and what it actually do, is set as CallerID the Called Number.
For example:
If an external extension (ex: 444220) calls my extension (ex: 333120), it sets as CallerID the called extension (ex: 333120)

What I am trying to do is, to set the CallerID for the outgoing calls.
So for example, if my extension (ex: 120) calls an external extension (ex: 444220), I want to set the CallerID to 333120.

Is there any way I can do that for all my extensions at once?

Thank you.
George Betsis

Hello @gbetsis,

Can you send me a verbose log of an external call to the other pbx (444XXX) ? I will write you a special context to change the outbound called id for your other pbx trunk.

Thank you,

Daniel Friedman
Trixton LTD.

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