No matching results Documentation Forum
Asterisk Tutorial 27 - Dynamic Asterisk Queues

Asterisk Tutorial 27 - Dynamic Asterisk Queues

Asterisk Tutorial 27 - Dynamic Asterisk Queues

Introducing Asterisk Phone Systems – The Solution to Dynamic Asterisk Call Agents & Queues

Firstly, we are back – nice and refreshed (or at least Mathias says he is) from our Summer Break. What that means is that it is now time to demonstrate how you can make your queues and agents truly dynamic using everything we have demonstrated so far.

Why Are Dynamic Call Agents & Queues Important?

In some cases you may not require any special call routing as you only have a single queue and all your team are logged into that queue. This is all well and good until you get to the point when you have multiple queues – say sales, support and customer service – and one of the call queues is experiencing high demand and the other are not. The question then is how to best utilise your resources?

One option could be to get your system administrator to manually log team members out of their current queue and into the one where they are needed. This however takes time – so much so that once he or she has finished the high call volumes will have likely subsided. The other negative here is that to restore the status quo they will have to repeat the process in reverse to get their call agents back into correct call queues.

The next option could be to keep the users in their current queue, but manually log them into the other queue. While this does not require as much time, it is still a long-winded process that is labour intensive and not overly efficient. This means that the answer lies in being able to log users into a queue as needed and log out again when they are no longer needed, either by themselves or via a team leader, but the important aspect here is that it is achieved with the minimum of hassle and as quickly as possible – so in essence dynamically. This functionality has many benefits for a large number of organisations, but the benefits are mostly clearly demonstrated in any form of contact centre.

How To Configure Dynamic Call Agents / Queues in Asterisk?

As mentioned in our tutorial, and above, to configure truly dynamic teams requires knowledge from across a range of topics that we have covered over the last few tutorials. Today’s tutorial is based on combining this knowledge in order to finally resolve how to configure dynamic call agents. So by following our previous tutorials on Asterisk Database, regular expressions (REGEX), Asterisk applications and Asterisk functions in combination with the steps outlined for setting up queues, music on hold etc, we now have the final piece of the puzzle – so how to bring everything together in our dialplan to enable dynamic call agents.

The easy part – Configuring the log in / out actions in your dialplan

In order to dynamically log agents in and out of a specific queue, it is first a good idea to configure your dial plan to be able to perform said action. In our example, we used the support queue with the extension 300 and my user (james) – all of which we configured in previous tutorials. Therefore, we configured our dialplan as follows using the *300 extension as this can be easily related back to the support queue.

If Agent exists and needs to be logged out

exten => *300-logout,1,NoOP (james exists, logout)
same => n,RemoveQueueMember(support,SIP/james)
same => n,Playback(beep)
same => n,Hangup

If Agent does not exist and needs to be logged in

exten => *300-login,1,NoOP (james doesn't exist, login)
same => n,AddQueueMember(support,SIP/james)
same => n,Playback(beep)
same => n,Hangup

While this step can be performed afterwards, it is perhaps a good idea to do it first as it will then provide you with information that is required in the next step, which is a bit more complicated so having the information to hand will only help you keep things simpler.

Here comes the tricky part

The crux of the problem is how to discover whether or not an agent is currently a member of the queue. In order to answer this question, it is possible to use the Asterisk Database (DB) function in combination with regular expressions. This will allow us to define which queue we wish to search when identifying whether a specific agent is logged in or not:

${REGEX(“SIP/james“)} – james would be the name of the call agent you are searching for.

${DB(Queue/PersistentMembers/support)} – support would be the name of the queue you wish to search through.

Next we will need to combine both of these lines of code into one string which we can use in our dialplan, which in our example looks like this:


The final step in the process is to then configure a new extension (e.g.*300) in your dial plan, which the user can use to log themselves in and out of queues. Once this is done, the GoToIf Application can be used in combination with the above query string to determine which actions should be taken – in our case log in or out of a queue as shown below:

exten => *300-login,1,NoOP (james login/logout)
; ${DB(Queue/PersistentMembers/support)}
; ${REGEX(“SIP/james“), ${DB(Queue/PersistentMembers/support)}}
same => n,GotoIf(${REGEX(“SIP/james“), ${DB(Queue/PersistentMembers/support)})}?*300-logout,1:*300-login,1)
same => n,Hangup

How the Final Dynamic Call Agent Configuration Should Look

Once you have completed all the steps above, you should have a final dialplan configuration that will look very similar to the one shown below (minus extension numbers, queue and agent names) and if you have configured all your queues, agents and dialplan entries correctly you should be able to dial the designated extension (*300 in our example) and this will either log an agent in or out of a queue. does not exist


There you have it - how to make your team members into dynamic queue members should you need them to be able to log in and out of queues. This tutorial provides the basis for what can be done with Asterisk Queues, however, should you wish to make your queues more advanced, feel free to use our template as the basis and build on it and let us know how you got on.

pascom hosted PBX - start upgrading your business communications today

Final Word

A well-configured business phone system that oozes useful tools, delivers excellent audio quality and intuitive call flows will leave callers with a highly professional impression. The configuration options, available applications and how well they are utilized will have a decisive impact on how professionally you manage your calls and therefore how your customers view your company. The switch to a pascom VoIP phone system solution provides the opportunity to not only upgrade your internal employee collaboration but also to redefine your business telephony.

If you would like more information regarding pascom and our Asterisk based PBX software, please visit our website or give the pascom team a call on +49 991 29691 0 to discuss your requirements and get started within minutes using our free hosted business VoIP phone system edition.