Call Queue Count of Callers on Hold

Discussion in 'Call Flow Designer' started by Pat Huesers, Sep 7, 2017.

Thread Status:
Not open for further replies.
  1. Pat Huesers

    Joined:
    Sep 7, 2017
    Messages:
    3
    Likes Received:
    0
    How can I use the 3CX API to query the amount of callers that are in a call queue? It looked like this was it, but it does not compile.

    public int QueueCalls(string queueNumber)
    {
    Queue[] queues = PhoneSystem.Root.GetQueues();

    foreach (Queue queue in queues)
    {
    if (queue.Number == queueNumber)
    ActiveConnection[] conns = queue.GetActiveConnections();
    return conns.length();
    }
    return 0;
    }
     
  2. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,236
    Likes Received:
    95
    Hi @Pat Huesers,

    Your code looks fine, but it seems you're missing the if braces. Your code should be:
    Code:
    public int QueueCalls(string queueNumber)
    {
    Queue[] queues = PhoneSystem.Root.GetQueues();
    
    foreach (Queue queue in queues)
    {
    if (queue.Number == queueNumber)
    {
    ActiveConnection[] conns = queue.GetActiveConnections();
    return conns.length();
    }
    }
    return 0;
    }
    But also, instead of iterating the queues, you can just get the DN by invoking:
    Code:
    Queue queue = (Queue) PhoneSystem.Root.GetDNByNumber(queueNumber);
    Then, your code would be much simpler:
    Code:
    public int QueueCalls(string queueNumber)
    {
      Queue queue = (Queue) PhoneSystem.Root.GetDNByNumber(queueNumber);
      ActiveConnection[] conns = queue.GetActiveConnections();
      return conns.length();
    }
    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Pat Huesers

    Joined:
    Sep 7, 2017
    Messages:
    3
    Likes Received:
    0
    Ernesto-

    Thanks for the help and the code. I am using this code below you gave me, but it seems to be returning the qty of Agents logged into the queue, not the qty of callers that are holding in the queue. What is the correct way to get that information?

    Code:
    public int QueueCalls(string queueNumber)
    {
      Queue queue = (Queue) PhoneSystem.Root.GetDNByNumber(queueNumber);
      ActiveConnection[] conns = queue.GetActiveConnections();
      return conns.length();
    }
     
Thread Status:
Not open for further replies.