Sync RingCentral Call Log into Google Sheets with Google Apps Script
As a user of RingCentral, you must have requirements to archive and analysis your calls, messages and meeting data. Google Sheets is a great tool to collect and analysis data. And how can we import or archive RingCentral data into Google Sheets?
In a previous article, I introduce how to use RingCentral API in Google Apps Script. In this article, I would like to show you to how to create a Google Sheets add-on to help people sync RingCentral call log into spreadsheets.
Prerequisites
- Base knowledge about RingCentral API in Google Apps Script
- A free RingCentral Developer account to create a RingCentral app
- Google Apps Script
- Node.js ≥ 10 in local environment
Please create a RingCentral app and Google Apps Script account as we mentioned in this article.
Setup project
We open sourced this project in the Github repository. So first let’s start by cloning it:
$ git clone https://github.com/embbnux/ringcentral-data-for-google-sheets.git
$ cd ringcentral-data-for-google-sheets
Install dependencies:
$ yarn
Create app_credentials.ts
file in a project root path:
$ touch app_credentials.ts
Add the following code into theapp_credentials.ts
file:
Note: we need to add permission `ReadAccount` and `ReadCallLog` into your RingCentral app.
We build this project based on the Google Apps Script CLI tool clasp and TypeScript.
Log into Google Apps Script and Create project with CLI
After you use the upper commands, we will create a new Google Apps Script. You can get it here.
Compile and upload code into Google Apps Script
yarn watch
Before we test, we need to add the following redirect URI into your RingCentral app on the RingCentral Developer website as we mentioned in the previous article:
https://script.google.com/macros/d/{GOOGLE SCRIPT ID}/usercallback
Go to your Google Apps Script project to test it as an add-on with a spreadsheet.
How it works
There are two steps to sync the RingCentral call log into Google Sheets.
Sync call log data from RingCentral platform API
We can get full document from RingCentral call log guide. For requesting RingCentral API in Google Apps Script, you can get the base knowledge here.
- Request the RingCentral call log list API
2. Full sync RingCentral call log data
Notice: When call log records are more than 250, we can’t get all data in a request. So we will request older data with
fetchCallLogList
.
3. Incremental Sync of the RingCentral call log
Note: In the`incremental sync` API, when incremental records are more than 250, it will throw an error. So we need to use the `full sync` instead of the `incremental sync`.
4. Sync and store syncInfo
in Google Apps Script properties service
Show call log sync options dialog
We allow user to select Sync Type
, Date From
, Account Level
and Insert Type.
To show the dialog:
Insert call log into sheet:
Conclusion
In this article, we introduced how to get the full RingCentral call log data using Google Apps Script to be able to insert the data into Google Sheets. Hopefully this article was helpful. You can get full source code here.
Please let us know what you think by leaving your questions and comments below.
To learn even more about other features we have make sure to visit our developer site and if you’re ever stuck make sure to go to our developer forum.
Want to stay up to date and in the know about new APIs and features? Join our Game Changer Program and earn great rewards for building your skills and learning more about RingCentral!