createCallLog
Creates one CRM activity/log record for a RingCentral call.
Signature
async function createCallLog({
user,
contactInfo,
authHeader,
callLog,
note,
additionalSubmission,
aiNote,
transcript,
ringSenseTranscript,
ringSenseSummary,
ringSenseAIScore,
ringSenseBulletedSummary,
ringSenseLink,
composedLogDetails,
hashedAccountId,
isFromSSCL,
proxyConfig
}) {
return {
logId: 'crm-log-id',
returnMessage: {
message: 'Call logged.',
messageType: 'success',
ttl: 2000
}
};
}
Input
| Field | Description |
|---|---|
user |
Connected CRM user. |
contactInfo |
Contact selected for the call. Shape: { id, phoneNumber, type, name }. |
authHeader |
Prepared CRM auth header. |
callLog |
RingCentral call log object. Includes id, sessionId, telephonySessionId, direction, from, to, startTime, duration, result, recording, and legs when available. |
note |
Agent note submitted by the user or cached from server-side logging. |
additionalSubmission |
Values from manifest page.callLog.additionalFields[]. |
aiNote, transcript |
Smart Notes/AI summary and transcript when enabled for the user. |
ringSenseTranscript, ringSenseSummary, ringSenseAIScore, ringSenseBulletedSummary, ringSenseLink |
ACE/RingSense artifacts when available. |
composedLogDetails |
Body composed by core when getLogFormatType() returns text/plain, text/html, or text/markdown. Empty when the connector uses a custom format. |
hashedAccountId |
Hashed RingCentral account ID from request headers when available. |
isFromSSCL |
True when the call is logged by server-side call logging. |
proxyConfig |
Proxy configuration when applicable. |
Return
| Field | Required | Description |
|---|---|---|
logId |
Yes | CRM activity/log ID. Core stores this as thirdPartyLogId for later update and lookup. |
returnMessage |
Optional | UI feedback. |
extraDataTracking |
Optional | Analytics/tracing data. Core adds withSmartNoteLog and withTranscript. |
If logId is missing, core treats the operation as unsuccessful.
Notes
Create a single CRM activity for the call. App Connect assumes one CRM log maps to one RingCentral call session.
When possible, write composedLogDetails directly to the CRM body. That keeps user log-format settings, recordings, AI artifacts, and later update behavior consistent across connectors.
Reference
const axios = require('axios');
// callLog: same as in https://developers.ringcentral.com/api-reference/Call-Log/readUserCallRecord
async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission, aiNote, transcript, composedLogDetails }) {
console.log(`adding call log... \n${JSON.stringify(callLog, null, 2)}`);
console.log(`body... \n${composedLogDetails}`);
console.log(`with additional info... \n${JSON.stringify(additionalSubmission, null, 2)}`);
const newCallLog = {
id: `CRM log id ${Date.now()}`,
subject: callLog.customSubject,
note: composedLogDetails,
contactName: contactInfo.name
}
// Using mock JSON as CRM response
const fs = require('fs');
const path = require('path');
const mockCallLogsPath = path.join(__dirname, '..', 'mockCallLogs.json');
const mockCallLogs = require(mockCallLogsPath);
mockCallLogs.push(newCallLog);
fs.writeFileSync(mockCallLogsPath, JSON.stringify(mockCallLogs, null, 2));
//----------------------------------------------------------------------------------
//--- CHECK: In extension, try create a new call log against an unknown contact ----
//----------------------------------------------------------------------------------
//--------------------------------------
//--- TODO: Add CRM API call here ------
//--- TODO: Delete above mock JSON -----
//--------------------------------------
// const postBody = {
// subject: callLog.customSubject ?? `[Call] ${callLog.direction} Call ${callLog.direction === 'Outbound' ? 'to' : 'from'} ${contactInfo.name} [${contactInfo.phone}]`,
// body: composedLogDetails,
// type: 'PhoneCommunication',
// received_at: moment(callLog.startTime).toISOString()
// }
// const addLogRes = await axios.post(
// `https://api.crm.com/activity`,
// postBody,
// {
// headers: { 'Authorization': authHeader }
// });
return {
logId: newCallLog.id,
returnMessage: {
message: 'Call logged',
messageType: 'success',
ttl: 2000
}
};
}
module.exports = createCallLog;