Need Help with Queue Login/out

Helloe eveyone, I am new to Asterisk, trying to learn now.

I have an Asterisk server running on VMware Workstation and softphones running on another PC, tablets. I can make calls between SIP devices. I create a queue and I can add/remove agents manually from CLI.

So things are working well so far. I am trying to make it easy so agents can login/out from their phone. I use the lines below:

exten => 8101,1,Answer
exten => 8101,2,AddQueueMember(myqueue)
exten => 8101,3,Playback(agent-loginok)
exten => 8101,4,Hangup
exten => 8101,103,RemoveQueueMember(myqueue)
exten => 8101,102,Playback(agent-loggedoff)
exten => 8101,105,Hangup

Now the agent from SIP/2000 can dial 8101 to login; however when he dial 8101 again he still hears the message “Agent logged in”. It does not log off the agent as expected. At the server CLI, I see the message " Unable to add interface ‘SIP/2000’ to queue ‘myqueue’: Already there"

What is wrong here?


Your dialplan, every time the user dial 8101 asterisk will execute the priority 1, so the devuce reach again the line exten => 8101,1,Answer and then jump to the next.

You set the priority 103 which is wrong. So you have 2 options:

-Add another exten like 8102 to logout the user like:

exten => 8102,1,RemoveQueueMember(myqueue)

-Or add a flag, logic, whatever to evaluate the status of the agent in the queue if exist logout if not login.

Thanks. I got the codes from

I can add a second extension to logout. For second option using a flag, I will need to do more research as I am totally newbie with Asterisk.

Thanks again.

Using priority gaps for error handling is deprecated. It has probably been removed from the application or is only applied if an option is set.

Looks like it has been removed; you need to test ${AQMSTATUS}. This is explained in the application help.