Route call based upon caller ID from large list

I’m trying to find the best way to evaluate and route inbound calls based on their Caller ID number.

Phase 1:
We want to load a list of about 200 phone numbers (from our CRM) into the system. If the caller ID number matches one of the numbers it will route into one queue/ring group, if it does not, it will go a different way.

Phase 2:
Load multiple lists of numbers (say lists A, B, C). Check CIDNam against lists A, B, & C. If it matches list A it goes to queue/RG A etc. If it doesn’t match A, B, or C it takes a 4th path.

I’d prefer to upload the phone number list as a CSV that replaces the existing list.

Are there any commercial modules that would help with this?

Thanks! --Andrew

Caller ID Superfecta would be the tool I’d start with. From there, you can fire up a program that can set up a lot of this stuff.

At some point, you might want to wander through the pages is the Commercial Modules. There might be one or more of those that get you close and you can tweak the system to meet the rest of your requirements.

1 Like

Superfecta would just change CID, right? I need to change call routing. (I did dig around there a bit).

I also did dig around the store before posting. It seems to me they’ve removed a lot (or at least re-arranged) their store. I didn’t see anything that matched up. I might re-invent the wheel if necessary but thought I’d sniff around and see if there was a module or project I was just missing.

No, there’s a lot you can do with Superfecta, including running programs that process against the inbound caller ID.

There is also a SangomaCRM module that can react to Caller IDs and provides a framework for web and direct program execution.

1 Like

If you’re willing to put your data in SQL rather than a CSV file, you have func_odbc which lets you define custom queries and use them in the dialplan.

You can then send incoming calls into a context where the CLID is checked against your SQL table and routed different ways. See the “solicitors” example. This function would be called on an inbound route and if it returned a true result the solicitor would be sent away (hangup or similar).


We do this today with a variable ring group. In the phone book I put the number that the call will come in on, under name we put the ring group we want to use and the phone numbers we want, with a : separator.

Number: {Dialed Number}
Name: {RG#:Phone Number1:Phone Number2:Phone Number3}

The call comes in, the caller ID name is applied due to the superfecta, and goes to a custom context that pulls apart the Caller ID Name into distinct variables, before sending the call on to the defined ring group.

The last part of the magic is I have several dummy extensions (4444444444,5555555555,6666666666,etc.) These extensions are set as the numbers to call in each ringgroup. Under Advanced>Dial we replace the value with local/[email protected]{customcontext}. This causes the extension dial string to be variable. The variable is defined in the first step as one of the dialable phone numbers in Caller ID Name.

This was a little more convoluted than @billsimon’s approach, but was valuable because:

  • Users just had to update the phonebook, that’s it. The phonebook can also take .csv upload.
  • All the big components stayed, editable, in the GUI allowing more people to learn/cover the function.
  • With this one ringgroup could serve many groups of people, which was a lot less work for us to manage (100’s of ring groups).

This is not exactly what you are asking to do, but you could draw inspiration form this approach.

As a final note the phonebook is technically depreciated. I do not think it is going anywhere for a while, but important to note.

1 Like

SQL is preferred. CSV would just be the transport mechanism to get it from CRM (no direct DB access) over to SQL or where ever asterisk/freepbx likes to query (quickly).

That solicitors example seems to hit pretty close by adjusting call flow based on a database table.

I’d still love to find a pre-built solution but if I have to roll my own I feel like the solicitors example has the framework I’d need.

Thanks @billsimon & @cynjut for the responses!

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