Skip to content

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

async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission }) {
    // ------------------------------------
    // ---TODO.4: Implement call logging---
    // ------------------------------------

    // const postBody = {
    //     subject: callLog.customSubject ?? `[Call] ${callLog.direction} Call ${callLog.direction === 'Outbound' ? 'to' : 'from'} ${contactInfo.name} [${contactInfo.phone}]`,
    //     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 CRM Extension`,
    //     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(`with note... \n${note}`);
    console.log(`with additional info... \n${JSON.stringify(additionalSubmission, null, 2)}`);
    mockCallLog = {
        id: 'testCallLogId',
        subject: callLog.customSubject,
        note,
        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 log added.',
            messageType: 'success',
            ttl: 3000
        }
    };
}
            message: `New contact created.`,
            messageType: 'success',
            ttl: 3000
        }
    }
}

async function createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission }) {
    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');
    const postBody = {
        user_id: user.id,
        subject: callLog.customSubject ?? `${callLog.direction} Call ${callLog.direction === 'Outbound' ? 'to' : 'from'} ${contactInfo.name}`,
        duration: callLog.duration,    // secs
        person_id: contactInfo.id,
        org_id: orgId,
        deal_id: dealId,
        note: `<p>[Phone Number] ${contactInfo.phoneNumber}</p><p>[Time] ${moment(callLog.startTime).utcOffset(user.timezoneOffset).format('YYYY-MM-DD hh:mm:ss A')}</p><p>[Duration] ${callLog.duration} seconds</p><p>[Call result] ${callLog.result}</p><p>[Note]${note}</p>${callLog.recording ? `<p>[Call recording link] <a target="_blank" href=${callLog.recording.link}>open</a></p>` : ''}<p><span style="font-size:9px">[Created via] <em><a href="https://www.pipedrive.com/en/marketplace/app/ring-central-crm-extension/5d4736e322561f57">RingCentral CRM Extension</a></span></em></p>`,
        done: true,
        due_date: dateUtc,
        due_time: timeUtc
    }
    const addLogRes = await axios.post(
        `https://${user.hostname}/v1/activities`,
        postBody,
        {
            headers: { 'Authorization': authHeader }
        });
    return {
        logId: addLogRes.data.data.id,

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
  } ]
}