text
stringlengths
0
152
same => n,Set(WorkingQueue=${CUT(AvailableQueues,^,${QueueCounter})})
same => n,Set(WorkingPenalty=${CUT(MemberPenalties,^,${QueueCounter})})
same => n,EndWhile()
; ...
These examples are probably not suitable for a production environment (we’d use
purpose-built MySQL tables for this sort of thing rather than AstDB), but it gives you
an idea of how the dialplan can be used to apply dynamic logic to more complex con‐
figuration scenarios.
Changing Penalties Dynamically (queuerules)
Using the asterisk.queuerules table, it is possible to define rules that change the
values of the QUEUE_MIN_PENALTY and QUEUE_MAX_PENALTY channel variables. The
QUEUE_MIN_PENALTY and QUEUE_MAX_PENALTY channel variables are used to control
which members of a queue are preferred for servicing callers. Let’s say we have a
queue called support, and we have five queue members with various penalties rang‐
ing from 1 through 5. If, prior to a caller entering the queue, the QUEUE_MIN_PENALTY
channel variable is set to a value of 2 and the QUEUE_MAX_PENALTY is set to a value of 4,
only queue members whose penalties are set to values ranging from 2 through 4 will
be considered available to answer that call:
same => n,Set(QUEUE_MIN_PENALTY=2) ; set minimum member penalty
same => n,Set(QUEUE_MAX_PENALTY=4) ; set maximum member penalty
same => n,Queue(support) ; entering the queue with min and max
; member penalties to be used
What’s more, during the caller’s stay in the queue, we can dynamically change the val‐
ues of QUEUE_MIN_PENALTY and QUEUE_MAX_PENALTY for that caller. This allows either
more or a different set of queue members to be used, depending on how long the
caller waits in the queue. For instance, in the previous example, we could modify the
minimum penalty to 1 and the maximum penalty to 5 if the caller has to wait more
than 60 seconds in the queue.
The sample file ~/src/asterisk-15.<TAB>/configs/samples/queuerules.conf.sample con‐
tains an excellent reference for how queue rules work.
Advanced Queues
|
225
The rules are defined using the asterisk.queuerules table. Multiple rules can be
created in order to facilitate different penalty changes throughout the call. Let’s take a
look at how we might choose to define a rule:
MySQL> insert into `asterisk`.`queue_rules`
(rule_name,time,min_penalty,max_penalty)
VALUES
('more_members',60,5,1);
New rules will affect only new callers entering the queue, not exist‐
ing callers already holding.
We’ve named the rule more_members and defined the following values:
60
5
1
The number of seconds to wait before changing the penalty values.
The new QUEUE_MAX_PENALTY.
The new QUEUE_MIN_PENALTY.
We can now tell our queues to make use of it.
MySQL> update `asterisk`.`queues`
set defaultrule='more_members' where `name` in ('sales','support')
The queuerules.conf.sample file shows that these rules are quite flexible. If you want
fine-grained control over call prioritization, some additional lab work may be worth
your while.
Announcement Control
Asterisk has the ability to play several announcements to callers waiting in the queue.
For example, you might want to announce the caller’s position in the queue,
announce the average wait time, or periodically thank your callers for waiting (or
whatever your audio files say). It’s important to carefully tune the values that control
when these announcements are played to the callers, because announcing their posi‐
tion, thanking them for waiting, and informing them of the average hold time too
frequently is going to tend to annoy them, which is not the goal of these things.
226
|
Chapter 12: Automatic Call Distribution Queues
Playing Announcements Between Music on Hold Files
Instead of handling the intricacies of announcements for each of your queues, you
could alternatively (or in conjunction) utilize the announcement functionality
defined in musiconhold.conf. Prior to playing a file for music, the announcement file
will be played, and then played again between audio files. Let’s say you have a 5-
minute loop of audio, but you want to play a “Thank you for waiting” message every