updateCallLog
This interface is called when a call log activity record needs to be updated. This interface is invoked in response to the following user actions:
- The user of App Connect's Chrome extension updates the subject or notes associated with a call log.
- When a recording has become available for a phone call.
Adding a recording to a call log entry
Events are triggers the moment a phone call is completed so that it can be logged properly. However, recordings take additional time to process and encode to make available to users. Therefore, for any given call you will receive an event when the call ends, and a subsequent event when a record is made available (assuming a recording of the call was made).
It is the developer's responsibility to update the call log record contents as they see fit to make a call recording available.
Input parameters
| Parameter | Description |
|---|---|
user |
An object describing the Chrome extension user associated with the action that triggered this interface. |
existingCallLog |
All the metadata associated with the call to be logged. Call Log schema is described in our API Reference. |
authHeader |
The HTTP Authorization header to be transmitted with the API request to the target CRM. |
recordingLink |
If the call has a recording associated with it, then this field will contain a link to the voicemail. |
subject |
The subject or summary of the call activity. The value may have been changes by the user. |
note |
The notes saved by the user. The value may change if the user has updated the notes they have taken. |
startTime |
Updated value of start date/time of this call. |
duration |
Updated value of duration of this call. |
result |
Updated value of result of this call. |
aiNote |
AI summary of the phone call |
transcript |
Transcript of the phone call |
composedLogDetails |
Formated log details that can be directly put into log body |
existingCallLogDetails |
Formated log details that's stored in log entity |
- Why need
startTime,durationandresult? Call info could be not as accurate right after the call. Our app uses call info from user local data until it's updated by RingCentral server. If users create call logs before RingCentral server updates the data, another API call will be triggered to call thisupdateCallLogfunction with true call data.
Contact Info
{
id: "<string">,
type: "<string>",
phoneNumber: "<E.164 Phone Number>",
name: "<string>"
}
Return value(s)
An object with following properties:
| Parameter | Description |
|---|---|
updatedNote |
updated note on CRM |
returnMessage |
message, messageType and ttl |
Example
return {
updatedNote: "Some random notes",
returnMessage:{
message: 'Call logged',
messageType: 'success', // 'success', 'warning' or 'danger'
ttl: 30000 // in miliseconds
}
}
Reference
// - note: note submitted by user
// - subject: subject submitted by user
// - startTime: more accurate startTime will be patched to this update function shortly after the call ends
// - duration: more accurate duration will be patched to this update function shortly after the call ends
// - result: final result will be patched to this update function shortly after the call ends
// - recordingLink: recordingLink updated from RingCentral. It's separated from createCallLog because recordings are not generated right after a call. It needs to be updated into existing call log
async function updateCallLog({ user, existingCallLog, authHeader, recordingLink, subject, note, startTime, duration, result, aiNote, transcript, composedLogDetails, existingCallLogDetails }) {
const fs = require('fs');
const path = require('path');
const mockCallLogsPath = path.join(__dirname, '..', 'mockCallLogs.json');
const mockCallLogs = require(mockCallLogsPath);
const callLog = mockCallLogs.find(callLog => callLog.id === existingCallLog.thirdPartyLogId);
callLog.subject = subject;
callLog.note = composedLogDetails;
fs.writeFileSync(mockCallLogsPath, JSON.stringify(mockCallLogs, null, 2));
//-----------------------------------------------------------------------------------------
//--- CHECK: In extension, for a logged call, click edit to see if info can be updated ----
//-----------------------------------------------------------------------------------------
//--------------------------------------
//--- TODO: Add CRM API call here ------
//--- TODO: Delete above mock JSON -----
//--------------------------------------
// const existingLogId = existingCallLog.thirdPartyLogId;
// const getLogRes = await axios.get(
// `https://api.crm.com/activity/${existingLogId}`,
// {
// headers: { 'Authorization': authHeader }
// });
// const originalNote = getLogRes.data.body;
// let patchBody = {};
// patchBody = {
// data: {
// subject: subject,
// body: note
// }
// }
// const patchLogRes = await axios.patch(
// `https://api.crm.com/activity/${existingLogId}`,
// patchBody,
// {
// headers: { 'Authorization': authHeader }
// });
return {
updatedNote: note,
returnMessage: {
message: 'Call log updated.',
messageType: 'success',
ttl: 2000
}
};
}
module.exports = updateCallLog;
async function updateCallLog({ user, existingCallLog, authHeader, recordingLink, subject, note, startTime, duration, result, aiNote, transcript, additionalSubmission, composedLogDetails, existingCallLogDetails, hashedAccountId }) {
let extraDataTracking = {};
const existingPipedriveLogId = existingCallLog.thirdPartyLogId;
// Use passed existingCallLogDetails to avoid duplicate API call
let getLogRes = null;
if (existingCallLogDetails) {
getLogRes = { data: { data: existingCallLogDetails } };
} else {
// Fallback to API call if details not provided
getLogRes = await axios.get(
`https://${user.hostname}/api/v2/activities/${existingPipedriveLogId}`,
{
headers: { 'Authorization': authHeader }
});
}
let assigneeId = null;
if (additionalSubmission?.isAssignedToUser) {
const adminConfig = await AdminConfigModel.findByPk(hashedAccountId);
assigneeId = adminConfig.userMappings?.find(mapping => typeof (mapping.rcExtensionId) === 'string' ? mapping.rcExtensionId == additionalSubmission.adminAssignedUserRcId : mapping.rcExtensionId.includes(additionalSubmission.adminAssignedUserRcId))?.crmUserId;
}
let patchBody = {};
patchBody.note = composedLogDetails;
if (subject) {
patchBody.subject = subject;
}
if (duration) {
patchBody.duration = secondsToHoursMinutesSecondsInPipedriveFormat(duration);
}
if (assigneeId) {
patchBody.owner_id = Number(assigneeId);
}
const patchLogRes = await axios.patch(
`https://${user.hostname}/api/v2/activities/${existingPipedriveLogId}`,
patchBody,
{
headers: { 'Authorization': authHeader }
});
extraDataTracking = {
ratelimitRemaining: patchLogRes.headers['x-ratelimit-remaining'],
ratelimitAmount: patchLogRes.headers['x-ratelimit-limit'],
ratelimitReset: patchLogRes.headers['x-ratelimit-reset']
};
return {
updatedNote: patchBody.note,
returnMessage: {
message: 'Call log updated.',
messageType: 'success',
ttl: 2000
},
extraDataTracking
};
}