Retrieving Queue Status in AGI Using PHP

I am managing queue status to route calls and using Asterisk with AGI in PHP. I execute the command:
‘’’
$result = $this->agi->exec(‘Queue’, [“QueueName”]);
‘’’

However, the result I receive is true or false, not the detailed QUEUESTATUS values such as:

  • TIMEOUT
  • FULL
  • JOINEMPTY
  • LEAVEEMPTY
  • JOINUNAVAIL
  • LEAVEUNAVAIL
  • CONTINUE
  • WITHDRAW.

What should I do to retrieve the queue status as a text string?

Those values are put into the QUEUESTATUS dialplan variable, so you have to retrieve that dialplan variable using a separate call in your AGI.

Thank you for your response!

I understand that the QUEUESTATUS values are set in the dialplan variable, and I need to retrieve it using a separate call in my AGI. Could you provide an example or clarify how I can fetch this value directly from the dialplan for statuses like JOINUNAVAIL, LEAVEUNAVAIL, CONTINUE, and WITHDRAW?

Any additional guidance on the exact method to call the dialplan variable in AGI would be greatly appreciated!

Thanks again for your help.

You’re asking me how to do something in an AGI script I don’t know the contents of using its own AGI implementation OR using a library that I’m unaware of. The most I’ll say is that the AGI command is GET VARIABLE[1] but how that is done in your AGI I don’t know.

[1] GET VARIABLE - Asterisk Documentation

sorry my question is not clearly. I wanna to know how to config queue to get statuses like JOINUNAVAIL , LEAVEUNAVAIL , CONTINUE , and WITHDRAW ?

Those are stored in the QUEUESTATUS dialplan variable when Queue exits.

I understand that the queue status is retrieved from the status variable. For example, when testing the FULL status, I was able to replicate it by setting queue max contacts to 1. When a second SIP phone attempted to call, it received the FULL status as expected.

However, I’m struggling to understand the following scenarios:

  1. CONTINUE:
  • When does this status occur? Can you clarify?
  1. JOINUNAVAIL and LEAVEUNAVAIL:
  • What configurations or circumstances result in these statuses?
  • Are they related to agents being unavailable or specific settings in the queue?
  1. TIMEOUT and WITHDRAW:
  • Could you provide examples or scenarios where these statuses would appear?

I reviewed the Asterisk documentation, but it doesn’t provide detailed explanations for these cases.

Any guidance or examples would be greatly appreciated!

Thank you in advance.

1 and 2 only occur when you have non-default settings that can causes them. If you are using those settings, they should be obvious.

3 I think TIMEOUT means that the timeout, specified in the parameters, was exceeded.

WITHDRAW is another case where, if you weren’t explicitly doing something that would cause it, you will not see it, and if you are doing that something, it should be obvious.

Thank you for your response, David. From your answer, I understand that the statuses CONTINUE, JOINUNAVAIL, and LEAVEUNAVAIL are triggered only under specific configurations. Could you please clarify which exact settings or configurations cause these statuses to occur? For instance, is it related to agent availability settings, queue configurations, or other factors?

Additionally, can you provide a concrete example or step-by-step instructions on how to trigger these statuses in Asterisk? This would really help in understanding the conditions under which these statuses are set.

As for the WITHDRAW status, you mentioned that it is triggered by a specific action. Could you elaborate on what specific action or configuration causes the WITHDRAW status to appear? Are there particular conditions or actions (such as agent state changes or other configurations) that trigger this status in Asterisk?

If you want specific details, you should read the source code of app_queue.c.

In my experience, no published software documentation fully documents interfaces to that level. The best documentation tends to be the unit test plan, but that is generally confidential. With open source software, you at least have the option of going to the source code.

The only time you need that level of detail is generally if you are coding yourself, so reading the source code is not difficult. It took me about a minute to find a structured comment that gave a good hint as to the meaning of WITHDRAW, and maybe 5 more to follow through the code to confirm my understanding. The others are ones I already knew, in principle, and should be obvious to anyone who has read the basic documentation (queues.conf.sample, and the Queue application document) to a level that I would consider necessary to make effective use of queue.

Thank you for your useful explanation and recommendations. The sources have been cited with the purpose of explanation of a certain understanding and perspective, which is also useful. I will surely do that, especially looking for the part in the code that determines how the status is set. I think your recommended approach to tackling this is starting from the structured comments and following the logic in code. Thank you once again for helping me in this way I appreciate it!