question

hamoody-abdulla1771 avatar image
hamoody-abdulla1771 asked Anirban answered

Is it possible to get a list of users in a Call Queue?

I am in need of getting a dynamic list of users that are part of a call queue. Is there a way to this with the API? Can someone point in the right direction? My end game is wanting to get the number of available users in a call queue by checking presence for each user that would be returned from the list I am looking for. Thanks in advance.

call queues
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

benjamin-dean avatar image
benjamin-dean answered
Yes, you can do this with the RingCentral API.

Setup an application which has the permissions: Read Accounts, Read Presence

First, you'll want to authenticate using RingCentral Admin credentials to obtain an access_token.

POST  https://platform.devtest.ringcentral.com/restapi/oauth/token

You will use the Extension API resource and filter by type = "Department" in the query parameters to fetch the list of Call Queue/Groups in your account. This will provide the extension information for the Call Queue/Group (you want the ID for the group).

GET  https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension?status=Enabled&type=Department<br>
RESPONSE EXAMPLE:
{  "uri" : "YOUR EXTENSION URI;,
  "records" : [ {
    "uri" : "INDIVIDUAL_DEPARTMENT_URI;,
    "id" : DEPARTMENT_ID,
    "extensionNumber" : "1",
    "contact" : {
      "firstName" : "Generic Queue",
      "company" : "Goofy Goobers",
      "email" : "benjamin.dean@ringcentral.com"
    },
    "name" : "Generic Queue",
    "type" : "Department",
    "status" : "Enabled",
    "permissions" : {
      "admin" : {
        "enabled" : false
      },
      "internationalCalling" : {
        "enabled" : false
      }
    },
    "profileImage" : {
      "uri" : "URI_TO_PROFILE_IMAGE";
    }
  } ],
  "paging" : {
    "page" : 1,
    "totalPages" : 1,
    "perPage" : 100,
    "totalElements" : 1,
    "pageStart" : 0,
    "pageEnd" : 0
  },
  "navigation" : {
    "firstPage" : {
      "uri" : "IF_MORE_THAN_ONE_PAGE_FIRST_PAGE_URI";
    },
    "lastPage" : {
      "uri" : "IF_MORE_THAN_ONE_PAGE_LAST_PAGE_URI";
    }
  }

You can then make a request to get the Department (using the DEPARTMENT_ID property value from the previous request). This gives you the list of members for that particular Call Queue/Group.

GET  https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/department//members<br>
RESPONSE EXAMPLE:
{  "uri" : "REQUEST_URI";,
  "records" : [ {
    "uri" : "https://platform.devtest.ringcentral.com<b>/restapi/v1.0/account/111111111/extension/123456789</b>";,
    "id" : 133128004,
    "extensionNumber" : "101"
  }, {
    "uri" : "https://platform.devtest.ringcentral.com<b>/restapi/v1.0/account/111111111/extension/012345678</b>";,
    "id" : 133165004,
    "extensionNumber" : "102"
  }, {
    "uri" : "https://platform.devtest.ringcentral.com<b>/restapi/v1.0/account/133128004/extension/098765432</b>";,
    "id" : 664573005,
    "extensionNumber" : "103"
  }, {
    "uri" : "https://platform.devtest.ringcentral.com<b>/restapi/v1.0/account/133128004/extension/023456789</b>";,
    "id" : 134694004,
    "extensionNumber" : "104"
  } ],
  "paging" : {
    "page" : 1,
    "totalPages" : 1,
    "perPage" : 100,
    "totalElements" : 4,
    "pageStart" : 0,
    "pageEnd" : 3
  },
  "navigation" : {
    "firstPage" : {
      "uri" : "FIRST_PAGE_URI";
    },
    "lastPage" : {
      "uri" : "LAST_PAGE_URI";
    }
  }
}

Then you create a new subscription and provide it an array of event filters (event filters are the records.uri + "/presence" from the Department members call response in the previous step). This will create a new subscription for your application and it will start receiving the event notifications in your handler.

POST  https://platform.devtest.ringcentral.com/restapi/v1.0/subscription?aggregated=true<br>
Body:
{"eventFilters":["/restapi/v1.0/account/11111111/extension/123456789/presence","/restapi/v1.0/account/11111111/extension/012345678/presence", etc...],"deliveryMode":{"transportType":"PubNub","encryption":false}}
Your application will then be notified of the presence events for each of those extensions. Additionally, since we used the "aggregated=true" query parameter on when creating the subscription, you will receive the bootstrap data your application may require during initialization.

This URI for the API Developer Guide provides good information about how to interpret and use the aggregated presence status:  https://developers.ringcentral.com/api-docs/latest/index.html#!#AggregatedPresence.html

Let me know if this is what you wanted.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

hamoody-abdulla1771 avatar image
hamoody-abdulla1771 answered
Thanks for the help. This helped me get the data I needed. However, once I had everything working in the sandbox, I applied for production and my subscription events stopped working. I can still do normal API calls and I can subscribe to events, but I do not receive any events. I pointed my app back to the sandbox and I still do not receive any events. Can you shed some light as to what could be wrong or do I need to post another question/issue. 

I have also created another simple app that only subscribes to my extension presence and it still does not receive events. There are no error messages on either app.

Thanks
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

benjamin-dean avatar image
benjamin-dean answered
Yes, there was a breaking change which was introduced late last week which causes you to require the ReadPresence API permission when  you are using eventFilters which are presence events for an extension.

Try adding that permission and see if this resolves your issue.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

hamoody-abdulla1771 avatar image
hamoody-abdulla1771 answered
My app currently has both read accounts and read presences API permissions. Also, I see you cannot change the permissions after you have been promoted to production, as I was going to remove and re-add.


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban avatar image
Anirban answered

If you are getting issue with your app after it moved into production and want to change the permission in prod, either you need to contact the dev support team to do this on behalf of you or you can clone the app, add/remove the required permission in the new app created, push it to production and cancel/suspend the existing application in the production

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys