Help getting data (DND Status, Presence Status, etc) for metrics

  • 1
  • Question
  • Updated 2 months ago
Hello everyone,

The company's division I work with is in the process of moving to RingCentral (other divisions already use RingCentral, so I am already setup with an account and have access to a sandbox account); our customer service department has one important requirement for one of the metrics they run on the agents that are on the phone all day.

They currently collect this data manually from our phone system UI, and it looks this:



They basically collect the "Total Idle time" and the "Total Unavailable time" per day, per person.


I am developer, and I have been tasked with figuring out how to get this data out of  RingCentral's API. We have gotten information from RingCentral (I guess during the sales/discovery meetings), that we need to use Webhooks. 

I have gone through the API, all information about Webhooks, polling and using the SDK, however, I still have  few questions and would like help with answering them.

Through my investigation, I came up with API methods to access the data we need:
  • Presence data: This should give me the core information needed
  • Extension info data: This should allow us get the user name and extension information to match with the Presence data.
Question 1:

Is this correct? If I need to get the "Total Idle time" and the "Total Unavailable time", those two
methods will return the data needed?

If my thinking is correct, and the answer is yes, then:

Question 2:

After reading other posts in this forum, and reading the API documentation, I understand that we should subscribe a Webhook to get the changes in the Presence data as they happen. Is this correct? Is there any other way to get this data?

Question 3:

I have worked with this type of subscription service with other vendors before. I know that eventually, there might be problems, and we might not receive the data. Is there some kind of recovery method? I asked this question because of this other forum entry:
https://devcommunity.ringcentral.com/ringcentraldev/topics/webhook-for-active-calls-presence-detaile...


Question 4:

We don't need to get this information in real time; as a matter of fact, it would be better if we could create a small app using the SDK and scheduled it to run overnight to collect this data if available this way.

Is there a way to get the historical Presence data? Is that data present in the Call Log or any other API method?


I am sorry for the long post, and thanks for all the help!!!









Photo of Alex Pereira

Alex Pereira

  • 90 Points 75 badge 2x thumb

Posted 3 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 3,192 Points 3k badge 2x thumb
Hi Alex,

Very interesting use case!

My quick answer is yes, you can do that with RingCentral API. However, there is no dedicated API for getting the metrics your company wants to track.

To do that, you need to call the following APIs, grab the data and process it to generate the metrics

1/ Login with an Admin user and call the Extension List API to read extensions information. Remember to keep the extension Id (ID not the extension number like 101, 102!)

2/ Subscribe for the Account Presence notification "/restapi/v1.0/account/~/presence?".

3/ Implement code to parse the push notification response and parse the statuses you are interested (telephonyStatus, presenceStatus, dndStatus, userStatus).

4/ Implement your logic to calculate "Total Idle time" and the "Total Unavailable time" using one or more statuses in the step 3. If you say the idle time is the period of time an extension is available, then you might want to use the presenceStatus to detect when the extension's presence status is changed from 'Available'  to 'Busy' then again to "Available". Create a timestamp when the status changes then get the time interval when the extension is busy. Add all the "busy" time intervals then subtract by the total time you expect that person to work (8hrs or 24hrs for full day) then you will get the result.

5/ You can check the userStatus as well to see if that user manually changes his/her status from as Offline/Busy/Available and implement similar logic to calculate idle or unavailable time.

6/ Get the extension Id from the push notification message and match it with the extension Id you keep from step 1 to identify the user. And finally log the calculated result to your database.

Check out my blog for how to use the push notification Presence.
https://medium.com/ringcentral-developers/api-spotlight-presence-e9a725f2afa6

Let me know if you have further questions.

Hope this helps,
+ Phong

Photo of Alex Pereira

Alex Pereira

  • 90 Points 75 badge 2x thumb
Hi Phong,

Thanks for the reply. I'm going to go over everything here and your blog. I will write back if I have any questions. Thanks again.
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,934 Points 2k badge 2x thumb
Hi Alex,
regarding your question #4. Unfortunately there is no way to get historical presence data through the API. I can recommend you to check our Real-time and Historical reporting on Service Web portal. As far as I remember they have some data about agents availability. 
Photo of Alex Pereira

Alex Pereira

  • 90 Points 75 badge 2x thumb
Thanks Anton!