Queue Failover Destination Based on CID Prefix

Hello Everyone.

We are migrating to a FreePBX.

We want to setup that when someone calls the main number it should ring 3 times, failover > IVR > ring 5 time > Failover > Voicemail.

So here’s where it get’s tricky, usually i would setup two queues one Pre-IVR and one Post-IVR and set the failover accordingly (Pre-IVR to IVR, Post-IVR to Voicemail), and have a button on their phone to log them in or out to/from both queues with a press of a BLF button.
But the users preferred logging in/out using FOP2, and we wouldn’t like them to have to login to two queues, therefore we would like to know if we can create one queue that will be used Pre-IVR and Post-IVR --and if there’s a way that failover can be sent to different destinations based on… let’s say CID Prefix.

Same like you can set failover to be driven by a time condition which can send it to different destinations based on time/date, i would like to setup that failover should look for a CID Prefix, if it has no Prefix send it to IVR if it has a Prefix, send it to Voicemail (Prefix will be added by the IVR)

Feel free to ask questions…


When this question came up last week, I think we decided there might be a module in the “contributed” collection that might do what you need (per the CID prefix thing)

If the prefix is a simple binary (it’s there or it isn’t) then doing it in a special context would probably be pretty simple.

Now, having said that, it’s going to be a lot easier if you get the rest of your stuff working before you start down this path. It sounds like you have a lot of unanswered/unresolved design decisions and implementation steps to do before you start getting trick with CID prefixes.

There’s nothing in your description that sounds hard to do, but smaller bites are easier to eat.

Thanks Dave,

It’s not the first time we are setting up a FreePBX, this particular box we have setup Extensions, FollowMe, IVR’s, DISA, Time Conditions, Conference Bridging, and much more.
Our design is basically done, we just need a solution to avoid users logging into two Queues.

Thanks again

This has nothing to do with experience - there are still lots of routes through the problem space and I’m not convinced you’ve explored enough of them.

It seems like you are actually looking for a way for FOP2 to log people into two queues at a time OR a way to process a call through a single queue twice.

I think writing a context that logs people into two queues would be a LOT simpler. Create a custom context that basically does the same thing as the current queue login, but do it twice (or call the current queue login twice with both queues as arguments). Point a Feature Code at it and log them in, then set FOP2 to call the feature.

The other way would require an application that would catch a flag (your modified CID, for example) and route the call through one of a number of paths that would all be normal call context destinations. In your specific example, it could be specific, but I’m not aware of something that exists that does that right now.

Now, if you were thinking “in the large” (as in, “what can I do that will make the system more flexible for the next guy and make me famous!”) you might suggest a feature that does one of the things you need done. For example, I’m pretty sure it would be reasonably simple to add an “Issues” Feature Request that said something like “Add an option for a queue that when a person logs into queue ‘A’ they also log into queues ‘B’ through ‘Z’ with a pick list of existing queues.”

Another could be a Feature Request that said something like “Create a contextual destination to route a call based on the first ‘N’ digits of the Caller ID.” I think there might be a Contributed Package that already does some of this, so there might be something that can get close to what your looking for. I can think of a thousand ways to use it (incoming routes, voicemail, extension routing, etc.). If that one existed, you could use it as the “destination” of your queue and route to voicemail or the IVR (for example).

If you change your design to 4 (or more) ringings first and 4 later it can be done.
First, time how many seconds is 4 ringings.
Create one queue,set maximum wait time to the time that coresponds to 8 ringing times.
In the same queue options page set an ivr breakout at the time that corresponds to 4 ringings.
Finally add your failover destination.

Problem: branch call flow based on Caller ID (or other Asterisk channel variable)
Solution: 3rd party module, Dynamic Routes or custom dialplan.

Hello all,

To accomplish we did the Following,

Inbound Route > Queue 501 > Failover to Misc Destinations which dials 58056565141 (Randomized Number) Which reaches the script below in extensions_custom.conf, if no Prefix it goes to IVR-1 which adds Prefix "AA: " if it does have the Prefix, it sends it to Voicemail of Extension 200.

So you can basically have one queue and Failover can be sent to different destinations based on the callers CID (In this case a Prefix)

Here’s the script:

exten => 58056565141,1,Set(check="${CALLERID(name):0:4}")
exten => 58056565141,n,GotoIf($[${check} != “AA:”]?4:3)
exten => 58056565141,3,Goto(ext-local,vmu200,1)
exten => 58056565141,4,Goto(ivr-1,s,1)

Nothing wrong with what you did (particularly if it works), but there is a slightly more elegant way of achieving the same end. If you modify your dialplan to:

exten => s,1,Set(check="${CALLERID(name):0:4}")
exten => s,n,ExecIf($[${check} != "AA:"]?Return())
exten => s,n,Goto(ext-local,vmu200,1)

Then create a Custom Destination that dials fork-call,s,1 with a return destination to your IVR. You also want to test the diaplan, you appear to be comparing the first 4 character of the CallerID name against a 3 character string, they will not match very often.