Photo by Goran Ivos on Unsplash

Customizing Amazon Connect CTI Adapter for Salesforce

Shreyas Vakil
Slalom Technology
Published in
5 min readApr 7, 2020

--

Note : this blog is written for an audience who has basic knowledge about the following concepts; Apex Class, Installing Managed Packages, AWS’s Amazon Connect. To learn more about these concepts please go to Trailhead.

The contents of this blog are written in order to give deep enough knowledge to readers so they can use the referenced features efficiently.

What is Amazon Connect?

Amazon Connect is a cloud-based contact center solution that comes with a CTI adapter to work with Salesforce. Contact center makes it easy for the agents to connect with their customers across many channels like phone and chat to deliver the best customer experience. With only a few clicks you can setup and manage your contact center to engage with your customers and provide personalized service. You can find the documentation to setup the contact center here.

Amazon Connect CTI Adapter for Salesforce

Amazon Connect integrates seamlessly with Salesforce using the CTI Adapter that is available as a managed package. You can install the package from Salesforce AppExchange just like any other managed package. Once installed, you’ll do some basic configuration like updating the Call Center settings, create a Softphone Layout and update the instance alias for the AC CTI Adapter record. All of these steps are explained in this official documentation from Amazon.

Fig. 1: AC CTI Adapter record that comes with the CTI Adapter installation. This is where you setup the Amazon Connect Instance Alias and Single Sign On settings for softphone.

Customizing Amazon Connect in Salesforce

In today’s blog, I want to focus on a couple of examples that showcase how to customize your Amazon Connect instance in Salesforce. While there is extensive documentation on set up, there is little public information about how to tailor the behavior of the CTI Adapter to suit your business processes.

The Amazon Connect CTI Adapter for Salesforce v4.2 added a default CTI Adapter [basically a record under the AC CTI Adapter object in SF] and scripts for click-to-dial, voice contact pop and chat contact pop. You can customize these scripts or create new scripts for the events exposed by the CTI Adapter to suit your use case. I will show you an example of how to update an existing script that comes with the adapter and how to create a new script.

Updating an existing script (onclick-to-dial)

I had a client who wanted to block outbound calling (onclick-to-dial) if the customer had not given consent to call them. For the sake of simplicity, we will assume that there is a checkbox on the Account record that is used to capture the customer’s consent. If it is checked, then outbound calling is allowed using the click-to-dial feature. If it is unchecked, then outbound calling is blocked to the number on the Account record.

Before I go into the details, I also want to highlight that the only way to customize/add new scripts is using the script editor that is included in the CTI Adapter.

Let’s begin, we will first open the script that comes with the adapter for click-to-dial.

Step 1 — Go to the App Launcher, search and open AC CTI Adapters and click on ACLightningAdapter record

Fig. 2: AC CTI Adapter List View

Step 2 — Scroll to the bottom and you will find Default Salesforce UI onClickToDial script

Fig. 3: Default Salesforce UI onClickToDial script

Step 3 — Update the script to look like the below. You will notice that I make a call to an Apex Class which returns Boolean value based on the checkbox. I pass two arguments (Account Id and Phone Number) to the apex method. The callback handles the response and makes a decision whether to allow outbound calling or display an Alert message to the user.

You can reference the Open CTI Developer Guide for runApex() method here.

onClickToDial Script

Step 4 — Write the Apex Class to return the Boolean value, it will look something like below.

Apex Class to return Customer Consent

In this example you can see how easy it is to customize the behavior of CTI Adapter with the combination of the scripts and events exposed by Amazon Connect and Apex class for the business logic.

Adding a new script

In this example, we will add a new script to the CTI Adapter to capture the call details when the call is connected between an Agent and the Customer, store it in a custom object (Call Log) and screen-pop the newly created record. This applies to both inbound and outbound calling.

Step 1 — Go to the App Launcher, search and open AC CTI Adapters and click on ACLightningAdapter record

Fig. 4: AC CTI Adapter List View

Step 2 — Scroll to the bottom and you will see ‘Scripts’ related list. Click ‘New’ to create a new script. Fill in the details for CTI Script Name, Source as ‘Amazon Connect Voice Connect’, Event as ‘onConnected’ and add a Description.

Fig. 5 : Creating new CTI script for AC CTI Adapter

Step 3 — Write the script as shown below.

Here you will notice that I am utilizing all the methods exposed by Amazon Connect which you can find in their documentation. I capture the call details like unique call id which Amazon Connect references as Contact Id, Agent’s Name/Username, Call Type, Customer Phone Number and Queue Name. I used the method ac.Utils.Salesforce.saveLog(type, recordId, fields) to insert a new Call Log record.

voiceContactOnConnected Script

In this example, you saw how to capture and store important call details on a record and popup the same record when the call is connected between the agent and customer utilizing the onConnected event exposed by the CTI Adapter.

You can debug the code by checking the ‘Debugger Breakpoint’ box and opening your Chrome debugger. The execution will stop when it hits that event in the chrome debugger and you can setup breakpoints and step over like any other Javascript code.

Final thoughts

The main goal of this article is to give awareness of what to expect when introducing and customizing Amazon Connect as your organization’s contact center technology. The examples in this article could be used as a starting point on customizing Amazon Connect for Salesforce and if you need any help getting this setup or customized to a greater degree, you can reach out to us.

--

--

Shreyas Vakil
Slalom Technology

Salesforce Solution Architect at Slalom Charlotte’s Technology Practice