List Queue Members

Learn how to handle an inbound call queue using the FreeClimb API.

At a glance
Send an HTTP GET request to /Accounts/{accountId}/Queues/{queueId}/Members to retrieve a list of all callers currently waiting in a given queue. The API returns an array of member objects detailing queue order and total elapsed wait time.

How to build and manage an inbound call queue using the FreeClimb SDK

This dataflow diagram demonstrates how your application queries FreeClimb to retrieve a list of active callers in a queue. By sending an HTTP GET request to /Queues.../Members, FreeClimb returns a paginated JSON response containing an array of queue member objects, complete with call details, queue order, and total elapsed wait time.

Dataflow diagram showing how your app makes a GET request to the FreeClimb /Queues.../Members endpoint, which in return responds with a JSON object containing the list of Queue Members matching your request.
👍

You're ready for this how-to guide if you've got the following:

A FreeClimb account
A registered application
A configured FreeClimb Number
Your tools and language installed


Node.js

Using the FreeClimb SDK, invoke an asynchronous request for all Queue members associated with a given queueId (queueId not given for this example). Successful invocation of the get method returns the first page of Queue Members. Iteration through the entire list of Queue members uses the nextPageUri.

Create your package.json file and save in the root directory of your project:

{
  "name": "node-list-members-how-to-guide",
  "version": "1.0.0",
  "license": "MIT",
  "dependencies": {
    "@freeclimb/sdk": "^3.8.0",
    "dotenv": "^8.1.0"
  }
}

Install the package by running the following in the command line/terminal:

yarn install

Example code:

require('dotenv').config()
const freeclimbSDK = require('@freeclimb/sdk')

const accountId = process.env.ACCOUNT_ID
const apiKey = process.env.API_KEY
const configuration = freeclimbSDK.createConfiguration({ accountId, apiKey })
const freeclimb = new freeclimbSDK.DefaultApi(configuration)
getMembers(queueId).then(members => {
  console.log('got queue members', members)
}).catch(err => {
  console.log(err)
})

async function getMembers(queueId) {
  const members = []

  let response = await freeclimb.listMembers()
  members.push(...response.queueMembers)

  while (response.nextPageUri) {
    response = await freeclimb.getNextPage(response)
    members.push(...response.queueMembers)
  }
  return members
}

Java

After successfully creating the FreeClimbClient, invoke QueuesRequester to send a synchronous request for all Queue members associated with a given queueId. Successful invocation of the get method returns the QueueMemberList object allows for sequential iteration through the entire list of Queue members.

Create your build.gradle file and save it to the root directory in your project:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This is a general purpose Gradle build.
 * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
 */

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
  //Add the dependency
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE"
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'gs-spring-boot'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    testCompile "junit:junit"
    compile 'com.github.FreeClimbAPI:FreeClimb-Java-SDK:3.0.0'
}

sourceSets {
    main {
        java {
            srcDirs = ['src'] // changed line
        }
    }
}

Build the file by running the following in your terminal/command line:

gradle build

Example code:

import com.vailsys.freeclimb.api.FreeClimbClient;
import com.vailsys.freeclimb.api.FreeClimbException;
import com.vailsys.freeclimb.api.queue.member.Member;
import com.vailsys.freeclimb.api.queue.member.MemberList;
 
import java.util.ArrayList;
public ArrayList listQueueMembers(String queueId) {
    try {
        // Create FreeClimbClient object
        // accountId & apiKey can be found under API credentials on the FreeClimb Dashboard
        FreeClimbClient client = new FreeClimbClient(accountId, apiKey);
         
        //Invoke get method to retrieve initial list of queue member information
        MemberList memberList = client.queues.getMembersRequester(queueId).get();
 
        //Check if the list is empty by checking the total size
        if(memberList.getTotalSize() > 0){
            //retrieve all queue member information from the server
            while(memberList.getLocalSize() < memberList.getTotalSize()){
                memberList.loadNextPage();
            }
 
            //Create a list of the queue members
            ArrayList<Member> list = memberList.export();
 
            // Loop through the list to process queue member information
            for(Member member : list){
                //Do some processing
            }
            return list;
        }
    }
    catch(FreeClimbException pe) {
        System.out.println(pe.getMessage());
    }
 
    return null;
}

C#

After successfully creating the FreeClimbClient, invoke getQueuesRequester to send a synchronous request for all Queue members associated with a given queueId. Successful invocation of the get method returns the QueueMemberList object allows for sequential iteration through the entire list of Queue members.

Example code:

// Create FreeClimbClient object
// Your account ID & api key can be found under API credentials on the FreeClimb Dashboard
string queueId = "";
// Create FreeClimbClient object
FreeClimbClient client = new FreeClimbClient (getFreeClimbAccountId (),
                                              getFreeClimbApiKey ());

// Invoke getMembers method to retrieve initial list of queue member information
QueueMemberList queueMemberList = client.getQueuesRequester.getMembers (queueId);

// Check if list is empty by checking total size of the list
if (queueMemberList.getTotalSize > 0) {
  // retrieve all queue member information from server
  while (queueMemberList.getLocalSize < queueMemberList.getTotalSize) {
    queueMemberList.loadNextPage ();
  }

  // Convert current pages queue information to a linked list
  LinkedList<IFreeClimbCommon> commonList = queueMemberList.export ();

  // Loop through linked list to process queue member information
  foreach (IFreeClimbCommon element in commonList) {
    // Cast each element to the QueueMember element for processing
    QueueMember queueMember = element as QueueMember;
    Console.WriteLine (queueMember.getCallId);
  }
} else {
  Console.WriteLine ("No Members in queue");
}