Take a look at the things that interest us.

How to check if a agent is registered in the Asterisk queue

Wesley Wesley 2 years

In today blog post we are going to check if a agent is currently registred in the Asterisk queue. Let's get started.


1. Asterisk Extensions Let’s start by moving to the Asterisk directory.

cd /etc/asterisk

Here we’ll open our extensions.conf

vi extensions.conf

Here we’ll first add the login and logout option for agents to our dial plan.

; login to queue
exten => _8000,1,Verbose(2, Login to queue support)
same => n,Playback(agent-loginok)
same => n,AddQueueMember(support,PJSIP/${CALLERID(num)})
same => n,Hangup()

; logout to queue
exten => _9000,1,Verbose(2, Logout to queue support)
same => n,Playback(agent-loggedoff)
same => n,RemoveQueueMember(support,PJSIP/${CALLERID(num)})
same => n,Hangup()

Next, we’ll add a GoToIf option to our dial plan.

# asterisk documentation

Arguments condition destination

  • labeliftrue - Continue at labeliftrue if the condition is true. Takes the form similar to Goto() of [[context,]extension,] priority.
  • labeliffalse - Continue at labeliffalse if the condition is false. Takes the form similar to Goto() of [[context,]extension,] priority.

Let's add it to our queue dial plan.

; send calls into call center queue
exten => _2000,1,Verbose(2,${CALLERID(all)} entering the support queue)
same => n,GotoIf($[${QUEUE_MEMBER(support,count)}=0]?absent:queue)

In the example above we added the GotoIf function to our queue dial plan. In the GoToIf function we'll check if the current queue has agents currently registered or not with the following parameter.


Next, we'll add the absent label to our dial plan.

; absent agents
same => n(absent),Verbose(2, There are no agents registered)
same => n,Playback(beeperr)
same => n,Queue(support-offline)
same => n,Hangup()

if there are no agents registered, we'll transfer the call to a different queue.

After this we'll add the normal support queue label to our dial plan.

; queue
same => n(queue),Verbose(2, Call into queue)
same => n,Playback(hello)
same => n,Wait(1)
same => n,Answer()
same => n,Queue(support)
same => n,Hangup()

After updating the file we’ll save and close it.


2. Restart Asterisk

The last step is to restart Asterisk, this can be done with the following command.

systemctl restart asterisk

In our dial plan we’ll first check if an agent is registered, when the agent is not registered we’ll transfer the caller to another queue.

How to check if a agent is registered in the Asterisk queue 2021-08-27 08:50:47

There are no comments.


Have questions about our services?

Contact our Sales team to get answers.

Contact Us