Dynamic Queues – Advanced Part 2

In this lesson the dialplan extensions will be modified to add and remove the user that is calling the extension. We will use the CHANNEL variable. The CHANNEL(channeltype) value displays the protocol the user is connecting with, for example SIP. The CHANNEL(peername) value holds the name of the user context. We can replace “SIP/chaz” from the previous lesson with these variables. To make things a little easier, a variable name QueueMember is created on the second line that holds both variables, making it easier to reference in preceding lines.

exten => 800,1,NoOp(Modify Queue for ${CHANNEL(channeltype)}/${CHANNEL(peername)})
same => n,Set(QueueMember=${CHANNEL(channeltype)}/${CHANNEL(peername)})
same => n,GotoIf(${REGEX("${QueueMember}",${DB(Queue/PersistentMembers/techteam)})}?800-logout,1:800-login,1)
same => n,Hangup
exten => 800-logout,1,NoOp(${QueueMember} exists, logout)
same => n,Answer()
same => n,RemoveQueueMember(techteam,${QueueMember})
same => n,Playback(beep)
same => n,Hangup
exten => 800-login,1,NoOp(${QueueMember} doesn’t exist, login)
same => n,Answer()
same => n,AddQueueMember(techteam,${QueueMember})
same => n,Playback(beep)
same => n,Hangup