addCallLog
This interface is responsible for creating a new call log record in the associated CRM. The call must be associated with the contact passed in as a request parameter. Other associations may be made depending upon the CRM and the adapter.
Input parameters
Parameter | Description |
---|---|
user |
An object describing the Chrome extension user associated with the action that triggered this interface. |
contactInfo |
An associative array describing the contact a call is associated with. |
authHeader |
The HTTP Authorization header to be transmitted with the API request to the target CRM. |
callLog |
All the metadata associated with the call to be logged. Call Log schema is described in our API Reference. |
note |
The notes saved by the user during and/or after the call. |
additionalSubmission |
All of the additional custom fields defined in the manifest and submitted by the user. |
timezoneOffset |
The timezone offset of the current user in the event you need to use UTC when calling the CRM's API. |
Contact Info
{
id: "<string">,
type: "<string>",
phoneNumber: "<E.164 Phone Number>",
name: "<string>"
}
Return value(s)
An object with following properties:
Parameter | Description |
---|---|
logId |
ID of the log entry created within the CRM |
returnMessage |
message , messageType and ttl |
Example
return {
logId: "xxx-xxxxx", // ID of log entity on CRM platform
returnMessage:{
message: 'Call logged',
messageType: 'success', // 'success', 'warning' or 'danger'
ttl: 30000 // in miliseconds
}
}
Reference
additionalInfo: null,
isNewContact: true
});
//-----------------------------------------------------
//---CHECK.3: In console, if contact info is printed---
//-----------------------------------------------------
return {
matchedContactInfo,
returnMessage: {
messageType: 'success',
message: 'Successfully found contact.',
detaisl: [
{
title: 'Details',
items: [
{
id: '1',
type: 'text',
text: `Found ${matchedContactInfo.length} contacts`
}
]
}
],
ttl: 3000
}
}; //[{id, name, phone, additionalInfo}]
}
// - contactInfo: { id, type, phoneNumber, name }
// - callLog: same as in https://developers.ringcentral.com/api-reference/Call-Log/readUserCallRecord
// - note: note submitted by user
// - additionalSubmission: all additional fields that are setup in manifest under call log page
async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission, aiNote, transcript }) {
// ------------------------------------
// ---TODO.4: Implement call logging---
// ------------------------------------
let body = '';
if (user.userSettings?.addCallLogNote?.value ?? true) { body = upsertCallAgentNote({ body, note }); }
if (user.userSettings?.addCallLogContactNumber?.value ?? true) { body = upsertContactPhoneNumber({ body, phoneNumber: contactInfo.phoneNumber, direction: callLog.direction }); }
if (user.userSettings?.addCallLogResult?.value ?? true) { body = upsertCallResult({ body, result: callLog.result }); }
if (user.userSettings?.addCallLogDuration?.value ?? true) { body = upsertCallDuration({ body, duration: callLog.duration }); }
if (!!callLog.recording?.link && (user.userSettings?.addCallLogRecording?.value ?? true)) { body = upsertCallRecording({ body, recordingLink: callLog.recording.link }); }
if (!!aiNote && (user.userSettings?.addCallLogAiNote?.value ?? true)) { body = upsertAiNote({ body, aiNote }); }
}
const createContactRes = await axios.post(
`https://${user.hostname}/v1/persons`,
postBody,
{
headers: { 'Authorization': authHeader }
});
return {
contactInfo: {
id: createContactRes.data.data.id,
name: createContactRes.data.data.name
},
returnMessage: {
message: `Contact created.`,
messageType: 'success',
ttl: 2000
}
}
}
async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission, aiNote, transcript }) {
const dealId = additionalSubmission ? additionalSubmission.deals : '';
const personResponse = await axios.get(`https://${user.hostname}/v1/persons/${contactInfo.id}`, { headers: { 'Authorization': authHeader } });
const orgId = personResponse.data.data.org_id?.value ?? '';
const timeUtc = moment(callLog.startTime).utcOffset(0).format('HH:mm')
const dateUtc = moment(callLog.startTime).utcOffset(0).format('YYYY-MM-DD');
let noteBody = '<b>Agent notes</b>';;
if (user.userSettings?.addCallLogNote?.value ?? true) { noteBody = upsertCallAgentNote({ body: noteBody, note }); }
noteBody += '<b>Call details</b><ul>';
if (user.userSettings?.addCallLogContactNumber?.value ?? true) { noteBody = upsertContactPhoneNumber({ body: noteBody, phoneNumber: contactInfo.phoneNumber, direction: callLog.direction }); }
if (user.userSettings?.addCallLogDateTime?.value ?? true) { noteBody = upsertCallDateTime({ body: noteBody, startTime: callLog.startTime, timezoneOffset: user.timezoneOffset }); }
if (user.userSettings?.addCallLogDuration?.value ?? true) { noteBody = upsertCallDuration({ body: noteBody, duration: callLog.duration }); }
if (user.userSettings?.addCallLogResult?.value ?? true) { noteBody = upsertCallResult({ body: noteBody, result: callLog.result }); }
Example Call Log Schema
{
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/1477535004/extension/1477535004/call-log/X2AvJPtwNQbNQA?view=Detailed",
"id" : "X2AvJPtwNQbNQA",
"sessionId" : "4503991004",
"telephonySessionId": "s-9a03590172ea4d39a7cf7d5b6dba6a3b",
"startTime" : "2018-09-11T13:24:09.000Z",
"duration" : 7,
"type" : "Voice",
"direction" : "Inbound",
"action" : "Phone Call",
"result" : "Accepted",
"to" : {
"phoneNumber" : "+18662019834",
"name" : "Jane Smith"
},
"from" : {
"phoneNumber" : "+16504445566",
"name" : "John Smith",
"location" : "Palo Alto, CA"
},
"extension" : {
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/1477535004/extension/1477535004",
"id" : 1477535004
},
"transport" : "PSTN",
"lastModifiedTime" : "2018-09-11T13:24:12.003Z",
"billing" : {
"costIncluded" : 0.000,
"costPurchased" : 0.000
},
"legs" : [ {
"startTime" : "2018-09-11T13:24:09.000Z",
"duration" : 7,
"type" : "Voice",
"direction" : "Inbound",
"action" : "Phone Call",
"result" : "Accepted",
"to" : {
"phoneNumber" : "+18662019834",
"name" : "Jane Smith"
},
"from" : {
"phoneNumber" : "+16504445566",
"name" : "John Smith",
"location" : "Palo Alto, CA"
},
"extension" : {
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/1477535004/extension/1477535004",
"id" : 1477535004
},
"transport" : "PSTN",
"legType" : "Accept",
"master" : true
} ]
}