createCallback
Creates one CRM record when a user schedules a call-back. The call-back list stays in App Connect. Implement this only when the CRM should also receive the new call-back, for example as a task, activity, or reminder.
App Connect calls createCallback before saving the local call-back. Connectors that do not export it only get the App Connect entry.
Signature
async function createCallback({
user,
authHeader,
proxyConfig,
callback
}) {
return {
thirdPartyId: 'crm-task-id',
returnMessage: {
message: 'Callback created.',
messageType: 'success',
ttl: 2000
}
};
}
Input
| Field | Description |
|---|---|
user |
Connected CRM user. |
authHeader |
Prepared CRM auth header. OAuth connectors receive a refreshed bearer token. API-key connectors receive Basic auth. |
proxyConfig |
Proxy connector configuration when the user connected through proxy mode. Code connectors can ignore it. |
callback |
The call-back being scheduled. It is not in the database yet. |
Callback object
| Property | Description |
|---|---|
id |
App Connect call-back id. |
contactId |
CRM contact id, or null. |
contactType |
Connector-defined contact type. |
phoneNumber |
Phone number from the current client request, when the client sent it. Not stored. |
status |
scheduled. |
scheduledAt |
ISO-8601 callback time, or null. |
lastCallAt |
null for a new call-back. |
The callback object does not include a contact name or note. The client does not send those fields.
Return
| Field | Required | Description |
|---|---|---|
thirdPartyId |
No | CRM record id. App Connect stores this on the call-back and passes it to updateCallback, markCalledCallback, and deleteCallback. |
returnMessage |
No | UI feedback. |
Return { successful: false, returnMessage } or throw when the CRM write fails. App Connect keeps the local entry, does not store thirdPartyId, and shows returnMessage, or a generic warning when none is provided. The call-back request still succeeds.
Reference
// Optional. App Connect keeps the call-back list and calls this before the local row is saved.
// Connectors that do not export it only get the App Connect entry.
// Export this from the connector only when scheduling a call-back should also create a CRM record.
//
// Wire it from the connector entry file:
// exports.createCallback = require('./interfaces/createCallback');
//
// callback.id is the App Connect id. Return thirdPartyId so later update and delete calls can find the CRM record.
// phoneNumber is present only when the current request sent it.
// authHeader is the CRM authorization header prepared by App Connect.
async function createCallback({ authHeader, callback }) {
// const response = await axios.post('https://api.crm.com/tasks', callback, {
// headers: { Authorization: authHeader }
// });
if (!authHeader || !callback?.id) {
return {};
}
return {
thirdPartyId: 'crm-callback-id'
};
}
module.exports = createCallback;
export {};