HookApiCallbacks

HookApiCallbacks

Methods

(abstract) afterSaveLog(params) → {Promise}

Implement this callback to do additional actions after saving interaction log.

Parameters:
Name Type Description
params object
Name Type Attributes Description
interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

interactionLogData CallLogData | ChatLogData | EmailLogData

Interaction log data

interactionLogId string <optional>

Saved interaction log id (if available)

Returns:
Type:
Promise

Promise represents object

(abstract) afterScreenPop(params) → {Promise}

Implement this callback to do additional actions after screen pop.

Parameters:
Name Type Description
params object
Name Type Attributes Description
screenPopObjects Array.<object>

Objects for screen pop.

interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

screenPopType ScreenPopType

Screen pop type

force boolean <optional>

Do force screen pop (if supported by CRM)

Returns:
Type:
Promise

Promise represents 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
Name Type Description
searchResults SearchResult

CRM search results

Returns:
Type:
Promise

Promise represents object

(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
Name Type Description
click2DialData Click2DialData

Data associated with click 2 dial operation

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
Name Type Description
interactionType InteractionType

Interaction type

interactionData CallData

Interaction data

conferenceData CallConferenceData

Conference data

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
Name Type Description
dispositionId number

Disposition id selected by agent

interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

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
Name Type Attributes Description
destination Destination

Agent/Skill/Speed Dial id or external number (depends on destination type)

callDialog CallDialogType

Five9 Adapter UI component where call was initiated

campaignId string <optional>

Selected campaign Id

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
Name Type Attributes Description
visitedObjects Array.<CrmObject>

Visited objects

objectsToRemove Array.<CrmObject> <optional>

Objects to be removed from visited objects list. There are specific scenarios in some CRMs, for example, in Salesforce Lead can be converted to another objects (Contact, Account etc.). In this case Lead is removed, Contact/Account are added.

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
Name Type Description
interactionType InteractionType

Interaction type

interactionData CallData

Interaction data

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
Name Type Attributes Description
interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

interactionLogData CallLogData | ChatLogData | EmailLogData

Interaction log data

interactionLogId string <optional>

Interaction log id (if it was already created at interaction start)

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
Name Type Attributes Description
screenPopObjects Array.<object>

Objects for screen pop.

interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

screenPopType ScreenPopType

Screen pop type

force boolean <optional>

Do force screen pop (if supported by CRM)

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
Name Type Description
interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction information

interactionSearchData CallSearchData | ChatSearchData

Additional data. Used only when interaction type is 'Call' or 'Chat'

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

Name Type Description
suggestedNumbers Array.<Click2DialData>

list of objects

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
Name Type Description
interactionType InteractionType

Interaction type

interactionData CallData | ChatData | EmailData

Interaction data

transferData CallTransferData | TransferData

Transfer data

Returns:
Type:
Promise

Promise represents object

  • status: HookApiStatus ProceedWithParams status is treated as Proceed