Call Distribution - using Queues

[Ref: Automatic Call Distribution (Queues) , Asterisk Admin Guide 2013, , Asterisk WIKI ]

Table of Contents
  1. Define
  2. Route Calls
  3. Dynamic Members

We use Queues for to help groups manage their incoming calls (distribution etc.) and more recently because we wanted to offer some services under different “labels.”

For example, we wanted to have a dedicated phone numbers for our reception, sales department, and Support. The flexibility will allow us to publish a number that clients can dial that not only puts them into the department, but also connect them with the next available person to manage their query..

Unfortunately for us, the groups are not quite distinct and we have a few people serving in multiple groups. The following is a quick review of how we used Asterik’s Queues, and messages to enable our desired solution.


Following the above reference documentation we define a simple queue template ServiceQueue from which we derive our queues.

ServiceQueue weight=0 wrapuptime=15 autopause=all maxlen=4 announce-frequency=240 min-announce-frequency=15 relative-periodic-announce=yes announce-position = no ringinuse = no periodic-announce = queues-thank-you-for-waiting-our-operators-are-currently-busy $!formatfileref(“queues.conf”)!$

The queue definition has a periodic-announce(ment) thanking callers for waiting in the queue.

An example audio message could be:

Since we’re creating multiple queues, but this message is common to all, then it makes sense to put it in once.

The audio files “queues-thank-you-for-waiting-our-operators-are-currently-busy.XXX” (with extensions .gsm, .alaw, .ulaw etc. ) are stored in the $astdatadir (defined in /etc/asterisk/asterisk.conf) which is usually /usr/local/share/asterisk/

Our queue for Reception will have a unique announce which announces the call to the our staff when picking up a call.

We also choose to explicitly set the members of the queue in our configuration file. Later we will show how we can have dynamic members.

Define: Reception Queue:

Reception announce = queues-phone-call-for-XYZ-reception member = SIP/6501 member = SIP/6502

Our queue for Sales and Support will have a different announcement, and a different member list.

Route Calls

To simplify dialplan routing for multiple Queues, we will use a macro for adding (inserting) calls into one of our chosen queues.

Very simply, we are going to take incoming calls to the imaginary phone numbers below, and route them into our new queues.

Incoming Phone NumberQueue

exten => _0211116500.,1,Goto(queue-insert,Reception,1) exten => _0211116510.,1,Goto(queue-insert,Sales,1) exten => _0211116511.,1,Goto(queue-insert,Support,1) $!formatfileref(“extensions.conf”)!$

Dynamic Members

To allow staff to dynamically enter, or exit, from a call queue we need to set up a dialplan. The below is one approach, using contexts defined further below.

exten => *9010, 1, Answer same => n, Gosub(queue-login, Sales,) same => n, Hangup()

exten => *9011, 1, Answer same => n, Goto(queue-logout, Sales) same => n, Hangup()

exten => *9012, 1, Answer same => n, Goto(queue-pause, Sales) same => n, Hangup()


To simplify our dialplan, we liberally use [contexts] as functions/subroutines to jump processing to.

The context queue-insert context takes as the 1st argument ${ARG1} the name of the queue we want to insert the call into and then goes through some processing.

[queue-insert] exten => Reception,1,GotoIfTime(08:00-17:58,mon-fri,,?q-Reception,1) same => n,Playback(business-hours-between-0800-1800) same => n,Hangup()

The basic processing of a call, within the valid business hours, is to

exten => q-Reception,1,Playback(queues-thank-you-for-calling-Company-one-of-our-friendly-staff) same => n,Queue(${queue},hHiIRtwkx,,,3000) ; don’t set n option until really needed same => n,Gosub(qjoin-${QUEUESTATUS},1) same => n,Hangup()

More Information:

$!showsrc(“media/src/asterisk/queues.conf”)!$ $!formatfileref(“queues.conf”)!$

$!showsrc(“media/src/asterisk/contexts/queues”)!$ $!formatfileref(“contexts/queues”)!$

$!showsrc(“media/src/asterisk/extensions/itsp.source”)!$ $!formatfileref(“extensions/itsp.source”)!$

$!showsrc(“media/src/asterisk/extensions/services.queues”)!$ $!formatfileref(“extensions/services.queues”)!$