AWS Contact Center

Provide call sentiment analytics to agents using real-time contact analysis segment streams in Contact Lens for Amazon Connect

Agent experience is a crucial aspect of contact centers and their interactions with end consumers define the customer experience of a business. In such a scenario, providing agents the right tools and information in a timely fashion is key to ensuring first call resolution, decreased average handling times and increased customer satisfaction score. Call sentiment analytics plays an important role in understanding what can be improved in interactions both in real time and historically. Providing real time transcription of the call, sentiment attached to it along with any keywords or categories can help agents take appropriate action to resolve issues.

Contact Lens for Amazon Connect is a feature that helps you to follow the sentiment and trends of customer conversations in real time to identify crucial company and product feedback. Contact Lens now also supports real-time streaming (real-time contact analysis segment streams) that helps businesses access Contact Lens analytics in near real-time. The real-time contact analysis segment streams provide transcription of the call, categories as well as utterances. Utterances allows businesses to obtain partial transcripts that makes it easy to for businesses to assist agents on calls in real-time with low latency results. Customers and partners have been looking forward to this new feature to bring data even faster to their applications.

The new Amazon Connect Contact Lens streaming feature  is a gamechanger for our ability to deliver digital contact centers to our customers through TrueServe™ by Deloitte Digital.  It empowers us to deliver high performance, real-time transcriptions to agents at enterprise scale.  With the new streaming segments we can do all that with a completely serverless architecture for calls of any length.” – Erik Golden, TrueServe™ by Deloitte Digital Chief Product Architect

In this blog post, we will walk you through on how to set up an enhanced agent desktop experience that leverages the Contact Lens real-time contact analysis segment streams. This ‘art of the possible’ agent desktop will then provide real-time transcription, categories and sentiment attached to the call. You can use these examples as an extension in your existing solutions or modify them based on your specific needs.

Overview of solution

This solution will be deployed using an AWS CloudFormation template. The solution creates an Amazon Kinesis Data stream and associates it with Amazon Connect Contact Lens to enable streaming. Additionally, it creates an AWS AppSync API to publish the insights from Contact Lens to a custom Amazon Connect Contact Control panel (CCP) that renders the transcript, categories and a sentiment graph. It also creates the custom CCP which is deployed using Amazon CloudFront and an Amazon Simple Storage Service (S3) bucket. The architecture diagram for this solution is given below:

In the above architecture, the customer makes a phone call which invokes an Amazon Connect Contact flow. This flow in turn invokes an AWS Lambda function that generates an authentication token which is stored in an Amazon Dynamo DB table as well as an Amazon Connect contact attribute. When the agent answers the call on the CCP, the contact ID of that call as well as the token is passed to the AWS AppSync API. An authorization lambda function is invoked to validate the token in the Dynamo DB table. Once validated the Amazon Connect Contact Lens utterances and transcripts are streamed using Kinesis Data streams and published to the agent CCP using AWS Appsync.

Note: This is a sample project designed to be easily deployable for experimentation. The AWS Identity and Access Management(IAM) policy permissions use least privilege, however the Amazon CloudFront and AWS AppSync resources deployed will be publicly accessible.

Please take the appropriate measures to secure your Amazon CloudFront distribution and AWS AppSync as required. 


For this walkthrough, it is assumed that you understand and have access to the following resources:

Deploy the solution

For deploying the solution, you will need the following information:-

  1. Amazon Connect instance name
  2. Amazon Connect instance ID
  3. Amazon resource name for the Service-Linked role associated with your Connect instance

Note: To note the ARN of the Service-Linked role , click on the service-linked role in the instance overview page.

This will take you to the AWS IAM console. Once you are in the IAM console, note down the role Amazon resource name (ARN) associated with the role.

Once you have the Amazon Connect instance ID, instance name and ARN for the Service-Linked role, you are all set to deploy the solution.

Overview of the steps:

  1. Deploy the AWS CloudFormation stack
  2. Associate a phone number to the Amazon Connect contact flow created by the AWS CloudFormation stack
  3. Launch the custom CCP and sign-in as an agent
  4. Test the solution by making a phone call

Deploy the AWS CloudFormation stack

  1. Log in to the AWS Management Console.
  2. Click on the Launch Stack button below to create a stack in the AWS Oregon region.
  3. In the parameters section, enter a globally unique name for an Amazon S3 bucket and your connect instance ID, instance name and the ARN of the Service-Linked role that you noted down earlier (refer screenshot below for details) and click on Next.
  4. Check the box for “I acknowledge that AWS CloudFormation might create IAM resources.”
  5. Choose Create Stack.
  6. The AWS CloudFormation template may take 15-30 minutes to create all the resources. Once done, it will show the status as “CREATE_COMPLETE”.

Associate a phone number to the Amazon Connect contact flow

After the CloudFormation stack has completed deploying all the resources, you will need to associate a phone number with a contact flow created by the CloudFormation. To associate the phone number:-

  1. Log in to your Amazon Connect admin console
  2. Navigate to the Phone numbers page by clicking on Phone numbers under the Routing section.
  3. Associate a phone number with the ContactLensStreamingDemoContactFlow contact flow, created by the CloudFormation stack and click on Save.

Launch the custom CCP and sign-in as an agent

  1. Log in to your AWS Management Console and navigate to AWS CloudFormation by typing the service name in the search bar.
  2. Select the name of the stack you just created.
  3. Go to the Outputs section of the newly created stack. Copy the CloudFrontEndpoint URL from the Value column.
  4. Paste the URL in a new web browser tab /window to navigate to the CloudFront web UI which is our custom CCP
  5. Login to the custom CCP as a configured agent who can receive calls from  the Basic Queue.

Test the solution

  1. Call the phone number that you associated with the Amazon Connect contact flow in Step 3.
  2. Accept the call as an agent on the custom CCP.
  3. Speak as a customer citing phrases that will trigger the Contact lens rules that you have configured.
  4. On the agent desktop you will be able to see transcription, categories/rules( if triggered) and a sentiment graph.

Cleaning up
To avoid incurring future charges, remove all created resources by deleting the AWS CloudFormation stack.

This post demonstrated an example of how one can use the real-time contact analysis event streams of Contact Lens to provide sentiment analytics to agents on live conversation. AWS AppSync powers the real time data and the React app renders the changes instantly. We provided some UI example of how you could use this data, and you can use this starting point to create your own insights.