createCallLog
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.
There is an underlying assumption of the framework that there is a one-to-one mapping between notes (or activities) and phone calls. Therefore, when logging a call in the target CRM only create a single log entry.
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,messageTypeandttl | 
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
    //     body: `\nContact Number: ${contactInfo.phoneNumber}\nCall Result: ${callLog.result}\nNote: ${note}${callLog.recording ? `\n[Call recording link] ${callLog.recording.link}` : ''}\n\n--- Created via RingCentral App Connect`,
    //     type: 'PhoneCommunication',
    //     received_at: moment(callLog.startTime).toISOString()
    // }
    // const addLogRes = await axios.post(
    //     `https://api.crm.com/activity`,
    //     postBody,
    //     {
    //         headers: { 'Authorization': authHeader }
    //     });
    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)}`);
    mockCallLog = {
        id: 'testCallLogId',
        subject: callLog.customSubject,
        note: composedLogDetails,
        contactName: contactInfo.name
    }
    const addLogRes = {
        data: {
            id: mockCallLog.id
        }
    }
    //----------------------------------------------------------------------------
    //---CHECK.4: Open db.sqlite and CRM website to check if call log is saved ---
    //----------------------------------------------------------------------------
    return {
        logId: addLogRes.data.id,
        returnMessage: {
            message: 'Call logged',
            messageType: 'success',
            ttl: 2000
        }
    };
}
async function upsertCallDisposition({ user, existingCallLog, authHeader, callDisposition }) {
    const existingLogId = existingCallLog.thirdPartyLogId;
    if (callDisposition?.dispositionItem) {
        // If has disposition item, check existence. If existing, update it, otherwise create it.
    }
    return {
        logId: existingLogId
    }
}
async function getCallLog({ user, callLogId, authHeader }) {
    // -----------------------------------------
    // ---TODO.5: Implement call log fetching---
    // -----------------------------------------
        postBody,
        {
            headers: { 'Authorization': authHeader }
        });
    extraDataTracking = {
        ratelimitRemaining: createContactRes.headers['x-ratelimit-remaining'],
        ratelimitAmount: createContactRes.headers['x-ratelimit-limit'],
        ratelimitReset: createContactRes.headers['x-ratelimit-reset']
    };
    return {
        contactInfo: {
            id: createContactRes.data.data.id,
            name: createContactRes.data.data.name
        },
        returnMessage: {
            message: `Contact created.`,
            messageType: 'success',
            ttl: 2000
        },
        extraDataTracking
    }
}
function secondsToHoursMinutesSecondsInPipedriveFormat(seconds) {
    if (typeof seconds !== 'number') {
        return '00:00';
    }
    const hours = Math.floor(seconds / 3600);
    const minutes = Math.floor((seconds % 3600) / 60) + 1;
    if (hours > 0) {
        return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
    }
    else {
        return `00:${String(minutes).padStart(2, '0')}`;
    }
}
async function getUserList({ user, authHeader }) {
    const userListResp = await axios.get(
        `https://${user.hostname}/api/v1/users`,
        {
            headers: { 'Authorization': authHeader }
        });
    const userList = userListResp.data.data.filter(user => !user.is_deleted).map(user => ({
        id: user.id,
        name: user.name,
        email: user.email
    }));
    return userList;
}
async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission, aiNote, transcript, composedLogDetails, hashedAccountId }) {
    const dealId = additionalSubmission ? additionalSubmission.deals : '';
    const leadId = additionalSubmission ? additionalSubmission.leads : '';
    const personResponse = await axios.get(`https://${user.hostname}/api/v2/persons/${contactInfo.id}`, { headers: { 'Authorization': authHeader } });
    const orgId = personResponse.data.data.org_id ?? '';
    const timeUtc = moment(callLog.startTime).utcOffset(0).format('HH:mm')
    const dateUtc = moment(callLog.startTime).utcOffset(0).format('YYYY-MM-DD');
    let extraDataTracking = {
        withSmartNoteLog: !!aiNote && (user.userSettings?.addCallLogAiNote?.value ?? true),
        withTranscript: !!transcript && (user.userSettings?.addCallLogTranscript?.value ?? true)
    };
    let assigneeId = null;
    if (additionalSubmission?.isAssignedToUser) {
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
  } ]
}