News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
How to pull call logs with an API
Tags: getting started
Oct 10, 2017 at 8:04am   •   7 replies  •  0 likes
yg-tech

I need to get RC call logs in a csv format every 15 minutes or less to my CRM can someone help with this?

7 Answers
answered on Nov 13, 2017 at 2:49pm  
 Phong Vu, this is working great, but it only pulls down 100 records maximum. I increase the time to more than 15 minutes and I sometimes have more than 100 calls in the time period. How do set the number of records to pull?

 0
answered on Oct 13, 2017 at 7:57am  
Thank you all for the help we are working to implement this into our CRM. Thank you again for your help.

 1
answered on Oct 11, 2017 at 7:45pm  
Hello, this is very helpful.  The code appears to run by displaying the date to console, however a CSV file never saves.

 0
answered on Oct 11, 2017 at 6:37am  
Thank you so much for this you're Awesome.


 1
answered on Oct 10, 2017 at 5:16pm  
Hi,

Here is the working code in Node JS. 

You need to install the RingCentral SDK for Node JS
npm install ringcentral --save

and install the dotenv so you can use the .env to keep your app and login credentials

Code:
var RC = require('ringcentral')
require('dotenv').load()

var rcsdk = new RC({
  server:process.env.SERVER,
  appKey: process.env.APP_KEY,
  appSecret:process.env.APP_SECRET
})

var platform = rcsdk.platform()

login()
function login() {
  platform.login({
    username:process.env.USERNAME,
    password:process.env.PASSWORD
  })
  .then(function(resp){
      readCallLog()
      setInterval(function(){
        readCallLog()
      }, 60 * 15 * 1000); // repeat reading call-log every 15 mins
  })
  .catch(function(e){
    throw e
  })
}

function readCallLog(){
  var date = new Date()
  var time = date.getTime()
  // 15-min period
  var less15Min = time - (60 * 15 * 1000)
  var from = new Date(less15Min)
  var dateFrom = from.toISOString()
  var dateTo = date.toISOString()

  var params = {}
  // See the API reference for more request parameters
  params['type'] = 'Voice'
  params['view'] = 'Detailed'
  params['dateFrom'] = dateFrom.replace('/', ':')
  params['dateTo'] = dateTo.replace('/', ':')
  console.log(params.dateFrom)
  console.log(params.dateTo)
  platform.get('/account/~/extension/~/call-log', params)
  .then(function(resp){
    var json = resp.json()
    if (json.records.length > 0){
      // Check the API documentation for call log data fields then add whatever you are interested
      var cvs = 'uri,startTime,duration,type,direction,action,result,to_name,from_name,transport'
      for (var record of json.records){
        cvs += "\r\n"
        cvs += record.uri + ','
        cvs += record.startTime + ','
        cvs += record.duration + ','
        cvs += record.type + ','
        cvs += record.direction + ','
        cvs += record.action + ','
        cvs += record.result + ','
        if (record.to.name != undefined)
          cvs += record.to.name + ','
        else
          cvs += 'null,'
          if (record.from.name != undefined)
            cvs += record.from.name + ','
          else
            cvs += 'null,'
        cvs += record.transport
      }
      var fs = require('fs')
      // add to your CRM db
      // for demo, I write the data to a file
      fs.writeFile('call_log_'+dateTo+'.csv', cvs, function(err) {
        if(err)
          console.log(err);
        else
          console.log("call log is saved.");
      })
    }
  })
  .catch(function(e){
    throw e
  })
}

I am here to help you. So no payment :)

Bests,
Phong

 1
answered on Oct 10, 2017 at 9:30am  
I was just asking for sample code; really any language would be fine. But if you could get this up and working for me very quickly we might be able to pay for it.

 0
answered on Oct 10, 2017 at 8:35am  
Hi,

Are you looking for a contractor to help with the work or are you asking for sample code showing how to implement that? If you need sample code, let me know what programming language do you expect.

+ Phong

 1



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us