Route to queue based on caller ID match

I need to find a way to route calls to a specific queue based on the caller ID or internal extension number. For example, a user calls extension 9500 from extension 1XXX the call is routed to Queue01, a call to 9500 from extension 2XXX is routed to Queue02, and a call to 9500 from extension 3XXX is routed to Queue03.

Any assistance is greatly appreciated.

Thank you.

1 Like

There are also ways to use your dial plan to inspect the caller id and route to the correct queue. Some of the asterisk distros have modules that can help with this.

If you use FreePBX, the inbound routes can use the callerID, or the dynamic routing module can help with that. For the internal extensions, I suggest that you use a custom dial plan so that when an internal extension dials your special number it forwards to the right number.

That worked perfectly. Below is the code I created and tested in the extension.conf. A user calls extension 1000 from 500X the call goes to Queue1, from 600X the call goes to Queue2, and from 700X the call goes to Queue3.

[Route_Queues]
exten => 1000/_500X,1,Answer()
exten => 1000/_500X,2,Queue(Queue1)
exten => 1000/_500X,3,Hangup()
exten => 1000/_600X,1,Answer()
exten => 1000/_600X,2,Queue(Queue2)
exten => 1000/_600X,3,Hangup()
exten => 1000/_700X,1,Answer()
exten => 9500/_700X,2,Queue(Queue3)
exten => 9500/_700X,3,Hangup()

You have a typo for the 700X Series. But great work!

Yep, I mistyped the 9500 instead of the 1000.

thank you for pointing that out.

You can reduce this to:

exten => 1000,1,Answer()
exten => 1000/_500X,2,Queue(Queue1)
exten => 1000/_600X,2,Queue(Queue2)
exten => 1000/_700X,2,Queue(Queue3)
exten => 1000,3,Hangup()

or

exten => 1000,1,Answer()
exten => 1000/_500X,n,Queue(Queue1)
exten => 1000/_600X,s,Queue(Queue2)
exten => 1000/_700X,s,Queue(Queue3)
exten => 1000,n,Hangup()

or even

exten => 1000,1,Answer()
exten => 1000/_500X,n,Queue(Queue1)
exten => 1000/_600X,s,Queue(Queue2)
exten => 1000/_700X,s,Queue(Queue3)

I’m assuming you really need to Answer early. It also assumes that these are the only caller ID ranges you will get, and you don’t have a fallback action.

3 Likes

it is nice to see you typing dial plan lines, @david551 it’s hard to make you code here, but as usual , I always learn something new from your posts