upsertCallDisposition
Some platforms may have the ability to associate the log activity to other entities, which is independent from the logging call action itself. We provide another interface for dispositioning the call.
Input parameters
| Parameter | Description |
|---|---|
user |
An object describing the Chrome extension user associated with the action that triggered this interface. |
existingCallLog |
All the metadata associated with the call to be logged. Call Log schema is described in our API Reference. |
authHeader |
The HTTP Authorization header to be transmitted with the API request to the target CRM. |
callDisposition |
Contain call disposition data in log form |
Return value(s)
An object with following properties:
| Parameter | Description |
|---|---|
logId |
existing log id |
Reference
async function upsertCallDisposition({ user, existingCallLog, authHeader, callDisposition }) {
//--------------------------------------
//--- TODO: Add CRM API call here ------
//--------------------------------------
const existingLogId = existingCallLog.thirdPartyLogId;
if (callDisposition?.dispositionItem) {
// If has disposition item, check existence. If existing, update it, otherwise create it.
}
return {
logId: existingLogId
}
}
module.exports = upsertCallDisposition;
async function upsertCallDisposition({ user, existingCallLog, authHeader, dispositions }) {
let extraDataTracking = {};
if (!dispositions.deals && !dispositions.leads) {
return {
logId: null
};
}
const existingPipedriveLogId = existingCallLog.thirdPartyLogId;
const patchBody = {};
if (dispositions.deals) {
patchBody.deal_id = dispositions.deals;
patchBody.lead_id = null;
}
else if (dispositions.leads) {
patchBody.lead_id = dispositions.leads;
patchBody.deal_id = null;
}
const patchLogRes = await axios.patch(
`https://${user.hostname}/api/v2/activities/${existingPipedriveLogId}`,
patchBody,
{
headers: { 'Authorization': authHeader }
});
extraDataTracking = {
ratelimitRemaining: patchLogRes.headers['x-ratelimit-remaining'],
ratelimitAmount: patchLogRes.headers['x-ratelimit-limit'],
ratelimitReset: patchLogRes.headers['x-ratelimit-reset']
};
return {
logId: existingPipedriveLogId,
extraDataTracking
}
}