question

scott-rister7361 avatar image
scott-rister7361 Deactivated asked scott-rister7361 Deactivated commented

How to read all users call logs at once?

I am working on to access RingCentral Call Reports using API access.


Our requirement is to fetch the Outbound call logs of all the users (Company Call Logs) registered under my organization, at once.


The API documentation states that to fetch the call logs of all the users at once, we have an account call log API, i.e., '/account/~/call-log' and we are trying to access the same.

What we need are the exact equivalent records that we get using "Analytics Portal" under "Reports" menu of "RingCentral Admin Account".

Below is the Request URL that we have been accessing to fetch the records:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/call-log?direction=Outbound&type=Voice&view=Detailed&dateFrom=2018-08-01&dateTo=2018-08-30&page=1&perPage=100

When we generate the analytical reports from Admin portal, it shows thousands of outbound calls made by the company's agents and when we hit the above request URL it gives an empty response. We have tried the same from the available "API Explorer" in the developer's account and still, no data got loaded.


Please do suggest if we are missing something in the process or if there needs to be something activated from RingCentral portal? Or if there is any other way to track the call activity of the employees using API access?




sdk
1 |3000

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

Phong Vu avatar image
Phong Vu answered scott-rister7361 Deactivated commented
Hi Scott,

That sounds a very simple feature and doable with the Company Call Log API. What I see from the Request URL above is the "devtest" environment. When you said that you access your company call log via the "Analytics Portal", is that your on real (production) account? If that is your production account then the request url above is pointing to a different account, which is your sandbox account and that could be the reason why you don't see any call log. If that is the case, then just remove the "devtest" from the request URL and try again.

If you want to see a useful demo/tutorial about how to access the call log, read data and visualize the data, please read this blog and learn more from the step-by-step tutorial.

Blog:  https://medium.com/ringcentral-developers/visualize-your-business-communications-history-2c81f85c324...
Tutorial:  https://ringcentral-tutorials.github.io/calllog-visualization-nodejs-demo/?distinctId=1398916020

Hoe this helps and let me know if you still have any problem with RingCentral platform.

+ Phong
5 comments
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·
Hi Scott,

The best way for your use case is to follow the flow below:

1. read all extensions under your account.
2. read call log of each extension one at a time.
var extensionList = []
var endpoint = '/account/~/extension'
var params = {
        status: "Enabled",
        type: "User",
        perPage: 1000
    }
    
platform.get(endpoint, params)
    .then(function(resp){
      var son = resp.json()
      for (var record of json.records){
        var item = {}
         item[extId'] = record.id
         item['extNum'] = record.extensionNumber.toString()
         item['fullName'] = record.contact.firstName + " " + record.contact.lastName

         extensionList.push(item)
        }
      })
      .catch(function(e){
        throw e
      })
// go thru the extensionList and read each extension call log at a time
for (var extension of extensionList){
  var endpoint = '/account/~/extension/'+ extension.extId +'/call-log'
  var params = {
    view: "Detailed",
    dateFrom: dateFrom,
    dateTo: dateTo,
    type: "Voice",
    perPage: 1000
  }
  platform.get(endpoint, params)
    .then(function(resp){
       // parse result from here
   })
  

Then you can process the results from both APIs to get the info you want.

1. Extension => get from your extensionList

2. Agent Name (making the call) => get from your extensionList (remember when you want the name of the caller then check for Outbound call only!)

3. Date and Time of the call made => from the response of call-log (startTime)

4. No. of times the call made to a number => iterate thru the response of each extension to count this value

5. Call status (missed, rejected, received) => from response of call-log (result)

6. Call duration => from response of call-log (duration)

7. Phone number (on which the call is made to) => from response of call-log (to.phoneNumber)

Hope this helps!

+ Phong
1 Like 1 ·
scott-rister7361 avatar image scott-rister7361 commented ·
Hello Phong,

Thanks for replying.

Yes, we are using "devtest" environment. I see that there are certain "Graduation Requirements" to activate to the "Production" environment, But that won't be a problem to activate the production environment. All we want is to get the following data in the result object:
1. Extension
2. Agent Name (making the call)
3. Date and Time of the call made
4. No. of times the call made to a number
5. Call status (missed, rejected, received)
6. Call duration
7. Phone number (on which the call is made to)

Since I have an admin account on the ring central so I can use "Account Level" API. But when I hit the API URL, I'm not sure if I'm getting the above required data as I couldn't get extension and agent name from the response object.

Is there anything else that needs to be done. Any help will be appreciated. Thanks in advance.

Below is the result that I get by hitting the API URL:

{
  "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/227254004/call-log?view=Detailed&t...;,
  "records": [
    {
      "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/227254004/call-log/AZyj2yIJqFvwzUA?vie...;,
      "id": "AZyj2yIJqFvwzUA",
      "sessionId": "19486376004",
      "startTime": "2018-08-27T13:07:02.897Z",
      "duration": 3,
      "type": "Voice",
      "direction": "Inbound",
      "action": "Phone Call",
      "result": "Missed",
      "to": {
        "phoneNumber": "+19043297097"
      },
      "from": {
        "phoneNumber": "+18007257091"
      },
      "transport": "PSTN",
      "lastModifiedTime": "2018-08-27T13:07:20.001Z",
      "billing": {
        "costIncluded": 0,
        "costPurchased": 0
      },
      "legs": [
        {
          "startTime": "2018-08-27T13:07:02.897Z",
          "duration": 3,
          "type": "Voice",
          "direction": "Inbound",
          "action": "Phone Call",
          "result": "Missed",
          "to": {
            "phoneNumber": "+19043297097"
          },
          "from": {
            "phoneNumber": "+18007257091"
          },
          "transport": "PSTN",
          "billing": {
            "costIncluded": 0,
            "costPurchased": 0
          },
          "legType": "Accept",
          "master": true
        }
      ]
    },
    {
      "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/227254004/call-log/AZvPIrGP5pMgzUA?vie...;,
      "id": "AZvPIrGP5pMgzUA",
      "sessionId": "19447136004",
      "startTime": "2018-08-20T12:59:40.202Z",
      "duration": 3,
      "type": "Voice",
      "direction": "Inbound",
      "action": "Phone Call",
      "result": "Missed",
      "to": {
        "phoneNumber": "+19043297097"
      },
      "from": {
        "phoneNumber": "+18007257091"
      },
      "transport": "PSTN",
      "lastModifiedTime": "2018-08-20T13:00:00.004Z",
      "billing": {
        "costIncluded": 0,
        "costPurchased": 0
      },
      "legs": [
        {
          "startTime": "2018-08-20T12:59:40.202Z",
          "duration": 3,
          "type": "Voice",
          "direction": "Inbound",
          "action": "Phone Call",
          "result": "Missed",
          "to": {
            "phoneNumber": "+19043297097"
          },
          "from": {
            "phoneNumber": "+18007257091"
          },
          "transport": "PSTN",
          "billing": {
            "costIncluded": 0,
            "costPurchased": 0
          },
          "legType": "Accept",
          "master": true
        }
      ]
    }
  ],
  "paging": {
    "page": 1,
    "perPage": 100,
    "pageStart": 0,
    "pageEnd": 24
  },
  "navigation": {
    "firstPage": {
      "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/227254004/call-log?view=Detailed&t...;
    },
    "lastPage": {
      "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/227254004/call-log?view=Detailed&t...;
    }
  }
}
0 Likes 0 ·
scott-rister7361 avatar image scott-rister7361 commented ·
Hello Phong,

Thanks for the reply. Yes, I see what I need to do. But another problem that I am facing now is that my company has over 60 employees using RingCentral to make calls. So, when I try to hit the API as per every agent's extensionNumber, I receive an error of "Request Rate Exceeded". Is there any wat to increase the request rates per minute? I'm using "RingCentral Office Premium 2" plan.

Thanks in advance.



0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
Hi Scott,

Yes, that was the API rate limit. I can increase the limit for your company but it may not help in the case of reading a lot of data. The best way is to cause a few second delay between reading each extension or API call.

Let me know,
+ Phong
0 Likes 0 ·
scott-rister7361 avatar image scott-rister7361 commented ·
Oh Great! I tried looping with some sleep time of few seconds and it worked.
0 Likes 0 ·
scott-rister7361 avatar image
scott-rister7361 Deactivated answered scott-rister7361 Deactivated commented
Phong,

I'm having this strange case. Please see below:

I fetched the records for the Extn. 33345 (The extn. is associated to Peter Burke) for the date 2018-09-19. From my admin panel of RC, I used the filters and it showed me aroung 20 records or so as the outbound calls that were made on the mentioned date. But when I use the API, the results are different entirely. Have a look:

CASE 1: (Extension Level)
--------------------------------------------------------------------------
Request URL:
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/call-log?extensionNumber=33345&a...:
Response:<br>{   "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/extension/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100",   "records": [],   "paging": {     "page": 1,     "perPage": 100   },   "navigation": {     "firstPage": {       "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/extension/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100"     },     "lastPage": {       "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/extension/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100"     }   } }

CASE 2: (Account Level)
---------------------------------------------------------------------
Request URL:
https://platform.ringcentral.com/restapi/v1.0/account/~/call-log?extensionNumber=33345&direction...:
Response:<br>{   "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100",   "records": [     {       "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/call-log/LMQu3tU8kmTBjUA?view=Simple",       "id": "LMQu3tU8kmTBjUA",       "sessionId": "541191845007",       "startTime": "2018-09-19T14:34:57.773Z",       "duration": 94,       "type": "Voice",       "direction": "Outbound",       "action": "VoIP Call",       "result": "Call connected",       "to": {         "phoneNumber": "+19133345670",         "location": "Bethel, KS"       },       "from": {         "phoneNumber": "+19724136243",         "name": "Neil Caffery"       },       "extension": {         "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/extension/165831030",         "id": 165831030       }     }   ],   "paging": {     "page": 1,     "perPage": 100,     "pageStart": 0,     "pageEnd": 0   },   "navigation": {     "firstPage": {       "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100"     },     "lastPage": {       "uri": "https://platform.ringcentral.com/restapi/v1.0/account/214632031/call-log?view=Simple&extensionNumber=33345&type=Voice&direction=Outbound&showBlocked=true&withRecording=false&dateFrom=2018-09-19T00:00:00.000Z&dateTo=2018-09-19T23:59:59.000Z&page=1&perPage=100"     }   } }
How are these hits giving me different records for the same extension? Also, the record that the "Case 2 (Account Level)" API returned me lists some other agent name and phone number in "from.name" and "from. phoneNumber". How is this possible?

After seeing this I looked into other returned results that I was getting and yes, the API response data don't match with the records that I get from my Admin panel from RC under "Call Log" heading.

Please help me in understanding this here.

4 comments
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·
The extensionNumber (101, 102, max 5 digits) is not the same as the extension Id (internal ID)!

As I said earlier, you need to use the Extension List API to get a list of all extension IDs of your account, then use the extension Id instead of the tilde (~) to read call log of that extension.

Now, don't use the extensionNumber query parameter to read call log for that extension even if you login with the Admin (from both service dashboard and API).

+ Phong
1 Like 1 ·
scott-rister7361 avatar image scott-rister7361 commented ·
Phong,

Thank you so much. It solved my problem.
1 Like 1 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
Hi Scott,

I think the description of the extensionNumber query param is incorrect. It is kind a filter to search for call log items that contain the extension number. Not reading the call log for that extension.

So to read the call log at extension level can be done only by either following ways:

1. Login with the extension's credentials then read it  https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~call-log?

2. Login with an admin user then get the extension Id of the extension you want to read, then read it:  https://platform.ringcentral.com/restapi/v1.0/account/~/extension/xxxxxxxxx/call-log?

Hope this helps,
+ Phong

0 Likes 0 ·
scott-rister7361 avatar image scott-rister7361 commented ·
Phong,

Thanks for your response.

I'm trying the 'Extension Level' API #2 that you have mentioned above. Below are the steps that I followed:

1. I logged into my admin portal of RingCentral.
2. I went to 'Call Log' menu. Added the filters:

  • Date Range => From 09/20/2018 To 09/21/2018
  • Advanced Features => Type of call: Voice, VoIP; Direction: Inbound, Outbound; Extension: 33345
And then clicked on 'Show' button.
3. It displayed me the below records:


4. Now, to test the results of my API, I'm using following PHP code:

$rcsdk = new SDK($this->client_id, $this->client_secret, SDK::SERVER_PRODUCTION);
$platform = $rcsdk->platform();
$platform->login('MY_USERID', MY_EXTENSION, 'MY_PASSWORD');

if ($platform->loggedIn()) {
      $call_log_records = $platform->get('/account/~/extension/33345/call-log', [
            'type' => 'Voice',
            'view' => 'Simple',
            'dateFrom' => '2018-09-20',
            'dateTo' => '2018-09-21'
       ])->json()->records;
      if (!empty($call_log_records)) {
            $call_details[33345] = $call_log_records;
       }
}

pr($call_details);
die('test');
================================================================
Response:
Resource for parameter [extensionId] is not found
================================================================

To find out the reason of above output, I went on seraching what exactly "extensionId" means. I got the information that "extensionId: Internal identifier of an extension or tilde (~) to indicate the extension assigned to the account logged-in within the current session". And, "extensionNumber: Extension number of a user. If specified, returns call log for a particular extension only".

5. Now, I tried this approach:

$rcsdk = new SDK($this->client_id, $this->client_secret, SDK::SERVER_PRODUCTION);
$platform = $rcsdk->platform();
$platform->login('MY_USERID', MY_EXTENSION, 'MY_PASSWORD');

if ($platform->loggedIn()) {
      $call_log_records = $platform->get('/account/~/extension/~/call-log', [
            'extensionNumber' => 33345,
            'type' => 'Voice',
            'view' => 'Simple',
            'dateFrom' => '2018-09-20',
            'dateTo' => '2018-09-21'
       ])->json()->records;
}

pr($call_log_records);
die();

================================================================
Response:
Array ( )
================================================================

Both ways failed for me.

Thanks in advance!

0 Likes 0 ·

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