Skip to content

updateCallLog

Updates an existing CRM call activity. Core calls this when the user edits the log, when finalized call data arrives, when a recording becomes available, or when AI artifacts are added later.

Signature

async function updateCallLog({
  user,
  existingCallLog,
  authHeader,
  recordingLink,
  recordingDownloadLink,
  subject,
  note,
  startTime,
  duration,
  result,
  aiNote,
  transcript,
  legs,
  ringSenseTranscript,
  ringSenseSummary,
  ringSenseAIScore,
  ringSenseBulletedSummary,
  ringSenseLink,
  additionalSubmission,
  composedLogDetails,
  existingCallLogDetails,
  hashedAccountId,
  isFromSSCL,
  proxyConfig
}) {
  return {
    updatedNote: note,
    returnMessage: {
      message: 'Call log updated.',
      messageType: 'success',
      ttl: 2000
    }
  };
}

Input

Field Description
user Connected CRM user.
existingCallLog Local App Connect linkage record. Use existingCallLog.thirdPartyLogId as the CRM log ID.
authHeader Prepared CRM auth header.
recordingLink View/listen link for the recording when available.
recordingDownloadLink Download link when the caller supplied one.
subject, note Latest user-editable log fields.
startTime, duration, result, legs Finalized RingCentral call details.
aiNote, transcript Smart Notes/AI summary and transcript when available.
ringSenseTranscript, ringSenseSummary, ringSenseAIScore, ringSenseBulletedSummary, ringSenseLink ACE/RingSense artifacts when available.
additionalSubmission Values from manifest page.callLog.additionalFields[].
composedLogDetails Updated body composed by core for plain text, HTML, or Markdown formats.
existingCallLogDetails Full CRM response returned by getCallLog() before the update, when core could fetch it.
hashedAccountId Hashed RingCentral account ID from request headers when available.
isFromSSCL True when invoked by server-side call logging.
proxyConfig Proxy configuration when applicable.

Return

Field Description
updatedNote Optional note/body value to send back to the client.
returnMessage Optional UI feedback.
extraDataTracking Optional analytics/tracing data.

Core already knows the CRM log ID from existingCallLog.thirdPartyLogId; you do not need to return it.

Avoid Overwriting User Edits

Users may edit the CRM activity directly after createCallLog and before a later recording/final-data update. Prefer targeted replacement or the centrally composed composedLogDetails update strategy used by existing connectors instead of blindly replacing unrelated fields.

Reference

const axios = require('axios');

// - 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;