Type | Phone Number | Name | Date / Time | Action | Result | Length | Recording |
---|
There are several major use cases for accessing call logs and call recordings including the following:
Call Log retrieval is done using the call log API end point. This can be done for all extensions if the authorizing user is the admin user or on a per extension level for extension-based authorization.
var Call = helpers.call();
// This call may be repeated when needed, for example as a response to incoming Subscription
platform.send(Call.loadRequest(null, {
query: { // this can be omitted
page: 1,
perPage: 10
}
})).then(function(response) {
console.log("RESPONSE_CALLS: " + response.text());
calls = Call.merge(calls, response.json().records); // safely merge existing active calls with new ones
t.populateCalls(calls);
}).catch(function(e) {
console.log("E_RESPONSE_CALL_LOG: " + e);
alert('Recent Calls Error: ' + e.message);
});
The following is an example report with an optional Call Recording object:
{
"uri": "https.../restapi/v1.0/account/401190149008/extension/401190149008/call-log/IXPCm_tIkCduk4I?view=Simple",
"id": "IXPCm_tIkCduk4I",
"sessionId": "404412141008",
"startTime": "2015-06-25T14:57:30.000Z",
"duration": 60,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"to": {
"phoneNumber": "18772160007",
"name": "Something New"
},
"from": {
"phoneNumber": "18882400004",
"name": "Something New"
},
"recording": {
"uri": "https.../restapi/v1.0/account/401190149008/recording/401547458008",
"id": "401547458008",
"type": "OnDemand",
"contentUri": "https.../restapi/v1.0/account/401190149008/recording/401547458008/content"
}
}
To retrieve call recordings you can simply add the access token to the uri provided or add the access token as a header. The URL method is shown below:
var recordingUrl = call['recording']['contentUri'];
var recordingUrl = rcsdk.platform().createUrl(uri, {addToken: true});
This approach can be used to batch download or individual streaming playback.
The easiest way to stream audio is directly from the RingCentral servers using HTML5. When you do this you can use the JavaScript SDK to automatically add an access token to the URI provided by the Call Recording API endpoint which you can use to create HTML5 audio as follows:
<audio controls="controls">
<source src="https://platform.ringcentral.com/...?access_token=myAccessToken" type="audio/mpeg" />
<em>HTML5 Audio is required for playback</em>
<audio>
This demo uses jQuery to create the HTML5 audio element as follows:
var recordingUrl = call['recording']['contentUri'];
recordingUrl = rcsdk.platform().createUrl(uri, {addToken: true});
var recordingEl = $('<audio>').attr('controls', 'controls').append(
$('<source>').attr('src', recordingUrl).attr('type', 'audio/mpeg')
.append(
$('<em>').append('HTML5 Audio is required for playback')
)