getCallLog
This interface retrieves a previously logged call log record in the target CRM. This information is used to render a form to allow an end user to view or edit that record within the App Connect client.
Request parameters
| Parameter | Description |
|---|---|
user |
TODO |
callLogId |
The ID of the activity or call log record within the CRM. |
authHeader |
The HTTP Authorization header to be transmitted with the API request to the target CRM. |
Return value(s)
This interface should return the associated call log record in a prescribed format.
| Parameter | Description |
|---|---|
callLogInfo |
Contain subject, note and optionally additionalSubmission |
returnMessage |
message, messageType and ttl |
Example
{
callLogInfo:{
subject: "A new call from John Doe",
note: "Delivery location changed.",
additionalSubmission: {
address: "12 Some Street, CA"
}
},
returnMessage:{
message: 'Log fetched',
messageType: 'success', // 'success', 'warning' or 'danger'
ttl: 30000 // in miliseconds
}
}
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;
headers: { 'Authorization': authHeader }
});
logBody = getLogRes.data.data.note;
const newMessageLog =
`<li>${message.direction === 'Inbound' ? `${contactInfo.name} (${contactInfo.phoneNumber})` : userName} ${moment(message.creationTime).utcOffset(user.timezoneOffset).format('hh:mm A')}<br>` +
`<b>${message.subject}</b></li>`;
// Add new message at the end (before the closing </ul> tag inside BEGIN/END block)
logBody = logBody.replace('</ul>------------<br>', `${newMessageLog}</ul>------------<br>`);
const regex = RegExp('<br>Conversation.(.*) messages.');
const matchResult = regex.exec(logBody);
logBody = logBody.replace(matchResult[0], `<br>Conversation(${parseInt(matchResult[1]) + 1} messages)`);
}
patchBody = {
note: logBody,
deal_id: dealId
}
if (!dealId && leadId) {
patchBody.lead_id = leadId;
}
const patchLogRes = await axios.patch(
`https://${user.hostname}/api/v2/activities/${existingLogId}`,
patchBody,
{
headers: { 'Authorization': authHeader }
});
extraDataTracking = {
ratelimitRemaining: patchLogRes.headers['x-ratelimit-remaining'],
ratelimitAmount: patchLogRes.headers['x-ratelimit-limit'],
ratelimitReset: patchLogRes.headers['x-ratelimit-reset']
};
return {
extraDataTracking
}
}