text
stringlengths
0
152
Mapping (joinempty)
(empty)
penalty,paused,invalid
Mapping (leavewhenempty)
penalty,paused,invalid
(empty)
strict penalty,paused,invalid,unavailable penalty,paused,invalid,unavailable
loose
penalty,invalid
penalty,invalid
Using Local Channels
The use of local channels as queue members is a powerful way of executing dialplan
code prior to dialing the actual agent’s device. When Queue() decides to present a call
to an agent, using local channels allows us to define custom channel variables, write
to a logfile, set some limit on call length (e.g., if it is a paid service), send messages of
all sorts all over the place, perform database transactions, and perform many of the
other actions we might wish to do at that exact moment. Normally, we have no con‐
trol over when the Queue() application has decided to present a caller to a specific
member, but with local channels, we get one final kick at the can, and can even return
Congestion(), which will have the effect of returning the caller to the queue, since
the queue will not consider this call to have been successfully delivered to an agent
(this can be very handy, since some external condition can be evaluated before the
call is just fired off to an endpoint).
When using local channels for queues, they are added just like any other channels,
typically dynamically through the AddQueueMember() dialplan application.
We’ll need to define the local channel where all the magic happens, and since local
channels are typically used in a manner similar to subroutines, we like to name and
locate them in the dialplan with the subroutines, with a context name starting with
local (akin to how subroutines start with sub). If you’ve been building out your
dialplan along with the book, you’ll notice you already have a local channel [local
DialDelay]. Add this code somewhere in that part of the dialplan.
[localMemberConnector]
exten => _[A-Za-z0-9].,1,Verbose(2,Connect ${CALLERID(all)} to Agent at ${EXTEN})
; filter out any bad characters, allow alphanumeric chars and hyphen
same => n,Set(QueueMember=${FILTER(A-Za-z0-9\-,${EXTEN})})
232
|
Chapter 12: Automatic Call Distribution Queues
; assign the first field of QueueMember to Technology; hyphen as separator
same => n,Set(Technology=${CUT(QueueMember,-,1)})
; assign the second field of QueueMember to Device using the hyphen separator
same => n,Set(Device=${CUT(QueueMember,-,2)})
; dial the agent
same => n,Dial(${Technology}/${Device})
same => n,Hangup()
This code might not make total sense just yet, but what it’s doing is taking the $
{EXTEN} (which is a complex alphanumeric string at this point), and slicing and dic‐
ing it to extract the actual channel to be called (i.e., we pass as part of the local chan‐
nel all the information needed to dial the actual channel).
Let’s look at the AddQueueMember code and see if we can make more sense of this:
exten => *740,1,Noop(Logging in device ${CHANNEL(endpoint)} into the support queue)
same => n,Set(MemberTech=${CHANNEL(channeltype)})
same => n,Set(MemberIdent=${CHANNEL(endpoint)})
same => n,Set(Interface=${MemberTech}/${MemberIdent})
;;; THE FOLLOWING SHOULD ALL BE ON ONE LINE
same => n,AddQueueMember(support,Local/${MemberTech}-${MemberIdent}@localMemberConnector
,,,${IF($[${MemberTech} = PJSIP]?${Interface})})
same => n,Playback(silence/1)
same => n,Playback(${IF($[${AQMSTATUS} = ADDED]?agent-loginok:agent-incorrect)})
same => n,Hangup()
Once you’ve input all this and reloaded your dialplan, log into the queue by dialing
*740, and let’s see what we’ve got.
*CLI> queue show support
support has 0 calls (max unlimited) in 'rrmemory' strategy (1s holdtime, 0s talktime),
W:0, C:1, A:1, SL:0.0%, SL2:0.0% within 0s
Members:
PJSIP/SOFTPHONE_A (Local/PJSIP-SOFTPHONE_A@localMemberConnector)
(ringinuse disabled) (dynamic) (Not in use)
No Callers
The member is now identified to the queue as a local channel named PJSIP-
SOFTPHONE_A in the [localMemberConnector] context. (The PJSIP/SOFTPHONE_A
channel will be monitored for actual status of the endpoint.) When Queue() decides
to send a call to the member, the call will end up in the [localMemberConnector]
context, where the EXTEN (PJSIP-SOFTPHONE_A) will be sliced and diced in order to
yield our channel type and endpoint,7 which is what will actually be called.
At this point, the purpose of all this extra complexity is not immediately clear. So far
we don’t get anything useful out of all this extra code.