Skip to content

getCallLog

Loads an existing CRM call activity so App Connect can show/edit it and compose safe updates.

Signature

async function getCallLog({
  user,
  telephonySessionId,
  callLogId,
  contactId,
  authHeader,
  proxyConfig
}) {
  return {
    callLogInfo: {
      subject: 'Inbound call',
      note: 'Agent note',
      fullBody: 'Full CRM activity body',
      fullLogResponse: {}
    }
  };
}

Input

Field Description
user Connected CRM user.
telephonySessionId Local call-log ID used by App Connect.
callLogId CRM activity/log ID previously returned by createCallLog.
contactId CRM contact ID stored with the local call log.
authHeader Prepared CRM auth header.
proxyConfig Proxy configuration when applicable.

Return

Field Description
callLogInfo.subject Current CRM subject/title.
callLogInfo.note Current editable note.
callLogInfo.fullBody Full body/description saved in the CRM. Used by core as the base for composed updates.
callLogInfo.fullLogResponse Full CRM response. Passed later to updateCallLog as existingCallLogDetails.
callLogInfo.contactName Optional contact display name.
callLogInfo.dispositions Optional current disposition values keyed by manifest field.
returnMessage Optional UI feedback.
extraDataTracking Optional analytics/tracing data.

Reference

const axios = require('axios');

async function getCallLog({ user, callLogId, authHeader }) {
    const path = require('path');
    const mockCallLogsPath = path.join(__dirname, '..', 'mockCallLogs.json');
    const mockCallLogs = require(mockCallLogsPath);
    const callLog = mockCallLogs.find(callLog => callLog.id === callLogId);
    const subject = callLog.subject;
    const note = callLog.note ? callLog.note.split('- Note: ')[1].split('\n')[0] : '';
    //-------------------------------------------------------------------------------------
    //--- CHECK: In extension, for a logged call, click edit to see if info is fetched ----
    //-------------------------------------------------------------------------------------

    //--------------------------------------
    //--- TODO: Add CRM API call here ------
    //--- TODO: Delete above mock JSON -----
    //--------------------------------------
    // const getLogRes = await axios.get(
    //     `https://api.crm.com/activity/${callLogId}`,
    //     {
    //         headers: { 'Authorization': authHeader }
    //     });
    return {
        callLogInfo: {
            subject,
            note,
            fullBody: callLog.note,
            dispositions: {
                testDispositionId: 'test disposition value'
            }
        },
        returnMessage: {
            message: 'Call log fetched.',
            messageType: 'success',
            ttl: 3000
        }
    }
}

module.exports = getCallLog;