Methods
(abstract) afterSaveLog(params) → {Promise}
Implement this callback to do additional actions after saving interaction log.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
(abstract) afterScreenPop(params) → {Promise}
Implement this callback to do additional actions after screen pop.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
(abstract) afterSearch(params) → {Promise}
Implement this callback to filter/modify/sort search results. Adapter will keep the order of returned search results.
hookApi.registerApi({
afterSearch: function(params) {
// Do not add Leads to search results
const filtered = params.searchResults.filter(item => item.type !== "Lead");
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.ProceedWithParams },
searchResults: filtered
});
}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus
- searchResults: Array of CrmObject Transformed search results
(abstract) beforeClickToDial(params) → {Promise}
Implement this callback to change click 2 dial data or cancel the action.
hookApi.registerApi({
beforeClickToDial: function(params) {
if (params.click2DialData.crmObject && params.click2DialData.crmObject.type === 'Account') {
return Promise.resolve({
status: {
statusCode: Five9.CrmSdk.HookStatusCode.Error,
message: 'You cannot call to Account phone numbers.'
}
});
}
if (campaign) {
params.click2DialData.preselectedCampaignName = campaign;
}
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.ProceedWithParams },
params: params
});
}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus
- params - Click 2 dial data in the same format as in the function argument.
(abstract) beforeConference(params) → {Promise}
Implement this callback to make custom actions before making a call conference. This method is called before any internal checks. The internal checks will be done only if this method doesn't cancel a call conference.
hookApi.registerApi({
beforeConference: function(params) {
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.Cancel }
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed
(abstract) beforeDisposition(params) → {Promise}
Implement this callback to make custom actions before setting disposition. This method is called before any internal checks. The internal checks will be done only if this method doesn't cancel setting disposition.
hookApi.registerApi({
beforeDisposition: function(params) {
return Promise.resolve({
status: {
statusCode: Five9.CrmSdk.HookStatusCode.Confirmation,
message: `Do you want to finish this ${params.interactionType.toLowerCase()}?`,
messageHeader: 'Confirmation'
}
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed
(abstract) beforeMakeCall(params) → {Promise}
Implement this callback to make custom actions before making a call. This method is called before any internal checks. The internal checks will be done only if this method doesn't cancel a call.
hookApi.registerApi({
beforeMakeCall: function(params) {
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.Cancel }
});
}
});
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed
(abstract) beforeObjectVisited(params) → {Promise}
Implement this callback to change visited object data or cancel the action. Adapter matches objects by id.
hookApi.registerApi({
beforeObjectVisited: function(params) {
// Do not add Leads
const filtered = params.visitedObjects.filter(item => item.type !== 'Lead');
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.ProceedWithParams },
params: { visitedObjects: filtered }
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus
- params - Visited objects data in the same format as in the function argument.
(abstract) beforeRecord(params) → {Promise}
Implement this callback to make custom actions before call recording. This method is called before any internal checks. The internal checks will be done only if this method doesn't cancel call recording.
hookApi.registerApi({
beforeRecord: function(params) {
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.Cancel }
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed
(abstract) beforeSaveLog(params) → {Promise}
Implement this callback to add fields to interaction (Call, Email, Chat) log. If you don't want to change anything return HookApiStatusCode.Proceed.
If you want to add/modify interaction log fields: return HookApiStatusCode.ProceedWithParams and 'newFields' object.
If you return HookApiStatusCode.Cancel the interaction log won't be saved and afterSaveLog hook won't be called.
hookApi.registerApi({
beforeSaveLog: function(params) {
const newFields = {};
// Update field
newFields.subject = params.interactionLogData.subject + ' Update: important note.';
// Add new field to interaction log
newFields.transferredAgent = 'Jolly Roger';
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.ProceedWithParams },
newFields
});
}
});
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus
- newFields: {object} (optional) - New interaction log fields in key-value format.
(abstract) beforeScreenPop(params) → {Promise}
Implement this callback to replace screen pop to the CRM object or cancel the action. If you don't want to change anything return HookApiStatusCode.Proceed.
If you want to replace adapter's screen pop with your custom screen pop: return HookApiStatusCode.Cancel. In this case afterScreenPop hook won't be called.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed. Screen pop parameters customization isn't supported.
(abstract) beforeSearch(params) → {Promise}
Implement this callback to replace search for CRM objects or cancel the action. If you don't want to change anything return HookApiStatusCode.Proceed.
If you want to replace adapter's search with your custom search: return HookApiStatusCode.Cancel and search results. Adapter will keep the order of returned search results. In this case afterSearch hook won't be called. If search results are not provided the action will be cancelled.
hookApi.registerApi({
beforeSearch: function(params) {
// Cancel Five9 adapter's CRM search and return custom search results.
const crmObjects = [
{ id: "123", type: "Contact", label: "Contact", name: "Homer Simpson", isWho: true, isWhat: false,
fields: [{ displayName: "Company", value: "Springfield Nuclear Power Plant" }] },
{ id: "456", type: "Contact", label: "Contact", name: "Marge Simpson", isWho: true, isWhat: false, fields: [] }
];
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.Cancel },
searchResults: crmObjects
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed. Search parameters customization isn't supported.
- searchResults: Array of CrmObject Search results
(abstract) beforeSuggestedNumbers(params) → {Promise}
Implement this callback to change suggested numbers data or cancel the action.
hookApi.registerApi({
beforeSuggestedNumbers: function(params) {
// Do not suggest Case phone numbers
const filtered = params.suggestedNumbers.filter((item) => {
return item.crmObject === undefined || item.crmObject && item.crmObject.type !== 'Case';
});
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.ProceedWithParams },
params: { suggestedNumbers: filtered }
});
}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
Objects and configuration that will be used to populate suggested numbers menu
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus
- params - Suggested numbers data in the same format as in the function argument.
(abstract) beforeTransfer(params) → {Promise}
Implement this callback to make custom actions before interaction transfer. This method is called before any internal checks. The internal checks will be done only if this method doesn't cancel transfer.
hookApi.registerApi({
beforeTransfer: function(params) {
return Promise.resolve({
status: { statusCode: Five9.CrmSdk.HookStatusCode.Cancel }
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise represents object
- status: HookApiStatus ProceedWithParams status is treated as Proceed