AWS Contact Center

Use Contact Lens for Amazon Connect to streamline call transfers with real-time AI powered insights

In the contact center world, agents frequently transfer calls, whether it is because the customer is routed to the incorrect department, or the customer’s situation requires an escalation. In some of these cases, the contact information collected by the first agent is not always available when a second agent or supervisor is talking to the customer. This results in increased time needed for the agent or supervisor to get the context needed for addressing the customer issue, which frustrates customers.

With the Contact Lens real-time API, the transcript of the customer conversation, as well as the matched categories and sentiment analysis for both customer and agent, can be automatically made available to the recipient of the transfer so customers don’t have to repeat themselves or wait on hold while the agent or supervisor gets up to speed.

This post provides an example of how to use the Contact Lens real-time API to provide the recipient of a transfer with the information required to address the customer concern right away, without asking them to repeat themselves.

Overview of the solution

In our previous blog, we explained how to setup Contact Lens for Amazon Connect for real-time notifications.

In this blog, you will learn to use the new real-time API, retrieve the matched categories and conversation transcript between the customer and agent for a transfer call, and announce to the recipient of the transfer who is transferring the call and why, using the agent whisper flow.


This example uses an AWS CloudFormation template.

The template creates an incoming call flow, a queue transfer contact flow, an agent whisper contact flow, a quick connect for transferring the call to an escalation queue, and a Lambda function that implements the ListRealtimeContactAnalysisSegments API.

The high-level steps we will follow in this solution are as follows:

  • Configure Queues, Routing profiles and Users
  • Create and deploy the CloudFormation stack
  • Add the Lambda function created as a resource to your Amazon Connect instance
  • Configure Contact Lens rules in your Amazon Connect instance
  • Associate the Quick Connect with your Basic Queue
  • Associate a phone number with the new contact flow
  • Test and validate the solution


For this walkthrough, you should have the following prerequisites:

Step-by-step instructions

Configure Queues, Routing profiles and Users

  1. Log in to your Amazon Connect contact center.
  2. Amazon Connect creates a default BasicQueue when the instance is created, but some users prefer to rename that queue. If you do not already have a BasicQueue, create a queue named BasicQueue.
  3. Copy the ARN of the BasicQueue in a separate file. To access the Queue ARN, click on the ‘Show additional queue information’ link.
  4. Create another queue named FraudQueue that will be used to transfer a call.
  5. Amazon Connect creates a default routing profile named Basic Routing Profile that has the BasicQueue assigned to it. If you do not have this in your environment, create a routing profile with this name and add the BasicQueue to it.
  6. Create a second routing profile named Fraud Routing Profile and add the FraudQueue to it.
  7. Copy the ARN of the FraudQueue in the same file where you saved the Basic Queue ARN.
  8. Create two users in your instance. You will need them for your test.
    • For ease of understanding, we will refer to the first user as “first agent”. Assign the Basic Routing Profile to this user.
    • In your test step, we will refer to the second user as “second agent”. Create the user and assign the Fraud Routing Profile.

Create and deploy the CloudFormation stack

  1. Select the button to deploy the code in your preferred region:
    • US East (North Virginia)         
    • US West (Oregon)                    
    • Asia Pacific (Sydney)               
      Note: To deploy in other regions, download the solution from this GitHub repository.
  2. Select next at the bottom of the screen.
  3. The stack name is prepopulated. Update it, if needed.
  4. Enter the Amazon Connect instance ID.
  5. Copy and paste the BasicQueue ARN and FraudQueue ARN saved in the previous step.
  6. On the next page, leave everything as default and click next to continue.
  7. On the following page, check the radio button for acknowledgement of statement, and then click on create stack button.
  8. Wait for confirmation that the stack creation is complete. In your Amazon Connect instance, you should now see three new contact flows and one queue quick connect.

Add the Lambda function to your Amazon Connect instance

  1. Navigate to the Resource tab of the newly deployed CloudFormation stack and check the full name of the Lambda function created with the template. The Lambda function you need contains getRealTimeCallAnalytics in the name.
  2. Add the Lambda function to your Amazon Connect instance configuration.

Configure Contact Lens rules in your Amazon Connect instance

  1. Navigate to your Amazon Connect instance user interface.
  2. On the Navigation menu, choose Rules.
  3. Create a rule for Contact Lens real time analysis. For the purpose of this blog post, please enter rule name exactly as defined- Fraud. Your rule may contain key phrases such as ‘I do not recognize this transaction’, ‘I did not purchase this item’, or ‘I never shopped at this store’. Please ensure that the rule type you create is for real-time analysis. Feel free to add any other phrases, keywords, or conditions as you see fit.
  4. Make sure that under Words or phrases –Pattern Match the logic is changed to customer.

Example: Logic: Any of the following words or phrases were mentioned during the entire length of the contact, where speaker is: Customer

Associate the Quick Connect with your Basic Queue

  1. On the navigation menu, chose Routing and then Queues.
  2. Select BasicQueue.
  3. At the bottom of the screen, add the newly created Quick Connect.
  4. Save

Associate a phone number with the new contact flow

  1. On the navigation menu, choose Routing and then Phone Numbers.
  2. If you do not have any numbers claimed at this point, choose Claim a phone number and select the type of phone number you want to use for this test.
  3. If you have a phone number, simply attach it to the contact flow named contact-lens-real-time-blog-CLRT-Contact-Flow.

Test and validate the solution

To test this solution, you need to login two users into your instance.

  1. Login the first agent (with the Basic Routing Profile) using the softphone URL for your instance. Make the agent available.
  2. Login the second agent (with the Fraud Routing Profile) and make the phone state available for the transfer call.
  3. Dial the phone number assigned with the contact-lens-real-time-blog-CLRT-Contact-Flow contact flow. We will refer to you as “customer” in the description of the following steps. The call is presented to your first agent. Accept the call.
  4. As a customer, start describing the reason why you are calling in your conversation and mention some of the key phrases configured in your contact center Rule at Step 4.
  5. On the first agent’s softphone, select the Quick connect named contact-lens-real-time-blog-CLRT-Quick-Connect to transfer the call to the Fraud queue.
  6. A new call arrives on the second agent’s soft phone.
  7. As the second agent accepts the call, they hear as an agent whisper: the name of the agent transferring the call to them, as well as the matched category for the conversation that the customer had with the first agent. For example, if your first user is configured with your name, the second user will hear upon accepting the transfer “Transfer from <your-name> for reason Fraud”.
  8. The transcript of the conversation between the customer and first agent, as well as the customer and agent sentiment are available as a contact attribute named transcriptSummary that is associated with the call. You can display it in a custom Contact Control Panel (CCP), or in your system of record application that has a CCP integration. The contact attribute is visible in the Contact Trace Record, and you can see it in the Contact Search view of your Amazon Connect instance as soon as the call is complete.

Cleaning up

To avoid incurring future charges, you can turn off Contact Lens processing by disabling the “Contact Lens speech analytics” option in the Set recording and analytics behavior block in the contact-lens-real-time-blog-CLRT-Contact-Flow contact flow.

If you created an Amazon Connect instance for this blog, you can delete the Amazon Connect instance in the Amazon Connect service console.


In this post, you learned how to use the Contact Lens real-time API to retrieve and attach (as contact attributes to the call) the context of call conversations for transferred calls as well as to present the recipients of a call transfer with the reason for the transfer. By using this feature, you can reduce customer frustration, improve customer retention, and decrease customer churn. From an agent experience perspective, having access to the full context of the conversation for a transferred call, can not only reduce the contact resolution time, but also help reduce agent attrition.

To learn more about how this solution was built, refer to the GitHub repository.


Girish Mallenahally is a senior solutions architect at AWS. Previously, he worked at Intuit building Contact Center Solutions using Amazon Connect. Prior to that he worked at Intel, Accenture and Sify. He has a Bachelor of Engineering in Mechanical Engineering. He is passionate about technology and innovation as a named inventor on 18 issued patents and author of several publications. You can read about his creative work here.

Magdalena Nedelcu is the Worldwide Technical Leader for Amazon Connect with a demonstrated history of implementations in the Contact Center space for 20 years, over 10,000 agent seats. She is passionate about building innovative solutions using AWS services to help customers navigate their journey to the cloud to achieve their business outcomes.