Salesforce requires uploading 3rd party javascript libraries as resources to your Salesforce org. Download latest version of Five9 Plugin SDK https://app.five9.com/dev/sdk/crm/latest/five9.crm.sdk.js and store it as static resource in your Salesforce org:
Create Lightning Component:
Load Five9 Plugin SDK as static resouce in your Salesforce Lightning component
//Component_with_Five9_Plugin_Api.cmp
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<ltng:require scripts="{!$Resource.five9_plugin_api}" afterScriptsLoaded="{!c.f9libLoaded}"/>
</aura:component>
Subscribe to SDK events using Salesforce afterScriptsLoaded callback in Lightning component controller:
//Component_with_Five9_Plugin_ApiController.js
({
f9libLoaded : function(cmp, evt, helper) {
const hookApi = window.Five9.CrmSdk.hookApi();
const interactionApi = window.Five9.CrmSdk.interactionApi();
interactionApi.subscribe({
callFinished: (params) => {}
});
hookApi.registerApi({
beforeDisposition: (params) => {}
});
})
Add Lightning Component to the page where Five9 Plus adapter for Salesforce Lightning is present
For this example we can use Salesforce Utility bar. We recommend enabling 'Start automatically' for Lightning component so that it is loaded into page before Five9 adapter iframe. If Five9 library is loaded to CRM page after Five9 adapter it can take up to 10 seconds to establish connection between library and Five9 adapter.
You can find here the full source code of the example above: https://github.com/Five9DeveloperProgram/Five9CRMSDKSamples