Default inbound route to matching extensions?

configuration
Tags: #<Tag:0x00007f70322e0398>

(Jeremy Schaeffer) #1

I have a large application with over 1000 extensions. Each extensions in the system has a DID number to it, with the last 4 for the DID matching the extension. Instead of having a inbound route for each extension, as they own over 6000 numbers and they change users and numbers frequently, is there a way to make a default inbound route that if no DID matches one of the exceptions, send the call to the station that ends in the last 4 digits if there is one? I know and have setup the Outbound loopback trunk for dialing a DID internally, can I do something similar for Inbound?


(Lorne Gaetz) #2

You would need custom dialplan to do this. Perhaps your own context that does a DIALPLAN_EXISTS on the last 4 digits in context from-did-direct and if not proceed to from-pstn. There is a bit to it all, something we could knock up for you at Sangoma Support. With this you extension numbers would supersede your inbound routes.

Simplifying, you could have your own context that discards all but 4 digits of the DID and then proceeds to from-pstn, that would allow your inbound routes to supersede any extensions.


#3

Building on @lgaetz’ suggestion, If your ‘exceptions’ where also 4 digits and within the owned 6000 , then just goto the ‘last4’ of the DID in [from-internal] perhaps.


(Jared Busch) #4

I’m more surprised that no one has asked for a context to do this prior to now.


(Jared Busch) #5

As stated, make a custom context to figure out the extension.

[did-to-ext]
stuff here

Then make a Custom Destination that sends to it.

Then make an inbound route or three depending on what oyu need for a pattern match for the DIDs and make the destination the above custom destination.


(Lorne Gaetz) #6

Or, ya know, you could just use the predefined context that’s existed for years expressly for this purpose:

; from-did-direct:
;
; forces ext-findmefollow to take precedence over ext-local. Also exposed to
; the public side to allow an extension number to be used as an external DID
; without requiring inbound routes to be created, common in many PRI installations
; where the last 4 digits are used as the extnension and DIDs are delivered in
; 4 digit formats.

(Jared Busch) #7

Too easy.

Edit: Does that match only on extension? Makes sense based on the description. So if I needed to match on the outbound CID declared in the extension, this would not work. Just clarifying.

Edit 2: I’m not the OP. Just curious.


Inbound routing with from-did-direct custom context does not return
#8

The from-did-direct works if only the last 4 are sent, the context just letters find me have preference, so yes, but you need to strip off all but the last four in your inbound context


(Lorne Gaetz) #9

Building on @sorvani’s suggestion to use a Custom Destination with an inbound route w/pattern match, you get a 100% GUI solution by using a custom dest of:


Strip prefix from DID for incoming calls from a specific trunk
(Jeremy Schaeffer) #10

Ahh, ok. I see that. That is a good suggestion and I will try it. Thanks!


(Jared Busch) #11

I love sticking with the GUI as much as possible. This is a much better choice than a custom context.


(Itzik) #12

The solutions provided here is great.

There’s also another option: if you can get your provider to send 4 digit DID’s then it will automatically match the extensions if there’s no entry for that 4 digit DID in the inbound route.


#13

Almost , but from

/etc/asterisk/extensions.conf
.
.
.
;-------------------------------------------------------------------------------
; from-did-direct:
;
; forces ext-findmefollow to take precedence over ext-local. Also exposed to
; the public side to allow an extension number to be used as an external DID
; without requiring inbound routes to be created, common in many PRI installations
; where the last 4 digits are used as the extnension and DIDs are delivered in
; 4 digit formats.
;
[from-did-direct]
include => ext-findmefollow
include => ext-local


(Lorne Gaetz) #14

@dicko if your post was meant to correct @PitzKey, implicit in their claim is that the trunk context is set to from-pstn:

freepbx*CLI> dialplan show from-pstn
[ Context 'from-pstn' created by 'pbx_config' ]
  Include =>        'from-pstn-custom'                            [pbx_config]
  Include =>        'ext-did'                                     [pbx_config]
  Include =>        'ext-did-post-custom'                         [pbx_config]
  Include =>        'from-did-direct'                             [pbx_config]
  Include =>        'ext-did-catchall'                            [pbx_config]

This trunk context will first match on inbound routes, then if not finding a match there will attempt to match a local extension.

Throughout this thread are references to 4 digits, possibly creating the misconception that from-did-direct requires exactly 4 digits. It should be noted that there is nothing magical about the number 4, any digit sequence will work. The four comes comes from PRI providers who historically have provided 4 digits here in NANP land.


(system) closed #15

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