Forward incoming call to extension

Hi all,

I apologize if this question was already answered, but I could not find the solution to it.

I have installed FreePBX on Ubuntu and already connected it to an Exchange Server, a Lync Server and a SIP provider.
On the FreePBX Box, there are also some extensions registered.
Incoming calls from the SIP provider get to FreePBX and can be routed to an extension, by manually specifying the extension to call (in an incoming route).
Internal calls also get properly routed to the right desinations, based on their first digit of the extension, i.e. numbers 3xx are extensions on FreePBX, 1xx is Exchange and 2xx is Lync.

What I want to do is this:
Whenever an outside caller (through the SIP Provider) calls my number plus an extension, the according extension should ring, either on FreePBX or one of the connnected trunks (Exchange or Lync).
Example:
The number I got from my SIP provider is: “+49 6666 12345678”.
If someone calls “+49 6666 12345678-321”, the call should get transferred to the extension 321 on FreePBX.

I was not able to implement that behaviour somehow:
I created Incoming Routes with wildcards for Incoming calls (DID _496666123456781XX goes to Trunk Exchange and accordingly for Lync) and that works, but I am unable to create a rule to match local extensions.
My only solution right now is, to manually add an incoming route for every extension on FreePBX, but that’s cumbersome and not flexible.

Further, I currently have to maintain two sets of rules, one for incoming and one for outgoing, although they are basically identical.

I’d appreciate your help to carry out this seemingly simple task.

Best,

Daniel

PS: I did not include log messages, because I don’t think they are relevant.
I can provide them of course, if necessary.

If I understand what you are wanting to do…Point your inbound to an IVR which directs the caller to “Enter your extension”.

BF

Not quite, I’d like to leave out the IVR.

FreePBX should see by the called number (aka DID, if I am correct), which extension to call.
All incoming calls start with 4966612345678, followed by an extension no.
This ${extension no} should get the call.

I managed to implement that behavior by scripting a little, but that seems to me like a real dirty hack:

[from-trunk-external-sip]
exten => _X.,1,NoOp(Redirecting call..)
exten => _X.,n,Set(NUMTOCALL=${EXTEN:12}) ; just remove the first 12 digits from the number
exten => _X.,n,NoOp(Calling ${NUMTOCALL})
exten => _X.,n,Goto(from-internal,${NUMTOCALL},1) ; had to use from-internal here to apply outbound rules

Hey…

If you got it to work with custom scripting, I’d leave it that way, otherwise, you’re going to have to set up an inbound route for each DID.

BF

Thank you for your answer.

I already experimented with inbound routes and noticed, that I could set up one route for every DID. But as I mentioned in my first post, that would be really cumbersome as the number of extensions grows.

I thought, maybe in FreePBX/Asterisk there is an easier way to do that. Something like regex matching or a gui-proof way to do it.

Anyway, since there is no “beautiful” solution, I’ll just stick with the scripting.

Thanks!

Daniel

Well, I’ve set up several hundred inbound DID’s so it can be done. Just another setting…

Good luck.

BF

Of course, I never doubted that.
As an engineer, I’m just looking for an elegant solution :slight_smile:

1 Like