AWS Partner Network (APN) Blog

Intelligent Case Management Using Amazon Connect and Amazon Kinesis Data Streams

By Nasir Mahmood, Director, AWS Global Alliance at PwC US Advisory
By Bharthvajan G., Sr. Cloud Architect at PwC US Advisory Acceleration Center
By Mohit Patil, Technology Strategy Consultant at PwC US Advisory Acceleration Center

Connect with PwC-2

Service excellence has been a critical driver of customer satisfaction, driving loyalty and business growth, especially in customer-centric verticals like retail, travel and hospitality, banking, insurance, and healthcare.

Customer-centric growth continues to be a key focus area for enterprises, along with a more agile and flexible enterprise that can deal effectively with uncertain market activities, scaling up and down when needed.

Despite the many improvements and enhancements made in customer service and support solutions over the last five years, there is a large scope for improvement in meeting the increased levels of customer expectations in the digital world.

The Global Call Center Satisfaction Index, for instance, is still at a meagre 71 percent, according to the global contact center satisfaction index from 2010 to 2020.

The proliferation of emerging technologies is resulting in a flurry of contact center solutions being brought to market, but enterprise customers often find these solutions time-consuming, cost-intensive, and difficult to implement, resulting in low adoption.

In this post, we will show you how to integrate an Amazon Connect instance with Salesforce Service Cloud to automatically create a case in Salesforce using REST APIs and Amazon Kinesis Data Streams. This allows you to proactively handles call drops occurring for customers when they dial into a contact center solution implemented using Amazon Connect.

We’ll explore how PwC used this integration to service customers who experience a disconnection during their interaction with the contact center. We’ll describe the solution using the use case of an airline contact center.

PwC integrated Amazon Connect and Salesforce Service Cloud to develop and offer an easy to set up, multi-channel, and highly scalable cloud-first solution called Intelligent Service Experience (ISE) that meets all the requirements of a next generation digital contact center. This includes true omnichannel capabilities, personalization through advanced analytics and machine learning (ML), increasing self-service, and automation possibilities.

PwC is an AWS Advanced Consulting Partner with AWS Competencies in SAP, Security, Life Sciences, and Financial Services. PwC is also an AWS Public Sector Partner and member of the AWS Well-Architected Partner Program, and has achieved the Amazon Connect Service Delivery designation.

Solution Overview

Amazon Connect is an easy-to-use omnichannel cloud contact center that helps companies provide superior customer service at a lower cost. Our solution uses Amazon Connect as its contact center component, with Salesforce Service Cloud driving the customer service functionality.

As part of the integrated solution, the customer call is routed through the Amazon Connect CTI adapter for Salesforce and to the Salesforce Service Cloud user interface (UI), where the agent can use customer information from multiple sources (Amazon Aurora or third-party data source systems, for example) to address customer issues.

The larger ISE solution also uses certain additional services, such as Pindrop which is integrated into Amazon Connect to provide caller authentication services. Mule is used as the middleware layer for interfacing with external third-party data source systems (in our use case, Amadeus GDS for flight and reservation data).


Figure 1 – High-level architecture view for ISE.

The ISE solution uses various components within the Salesforce environment to drive the integration between Amazon Connect and Salesforce. These components enable access and updates to data stored in Salesforce objects, provide APIs to be accessed and act as identity provider for Amazon Connect user authentication.

Dashboard and reporting components within Salesforce also enable the display of real-time and historical contact center metrics within Salesforce from Amazon Connect.


Figure 2 – Salesforce internal components.

Situations may occur where, after a customer’s call lands in the Amazon Connect contact flow, the call might be disconnected or dropped due to network problems or unforeseen system errors.

As a measure towards improving customer satisfaction, the contact center admin or supervisors want to know how many and which customers faced call drops or disconnections. This allows them to track disconnected customers so agents can reach out to them proactively.

Such disconnected calls are tracked through the creation of a case in the backend Salesforce system. An Amazon Kinesis Data Stream is configured to collect the Contact Trace Record (CTR) for each call coming into the contact center.

Once a call lands in the data stream, an AWS Lambda function is triggered. The Lambda function contains code to identify disconnected calls based on blank contact attributes. For each disconnected call, the Lambda function makes a Salesforce REST API call to create a case.

The following high-level implementation outline was followed for the implementation of PwC’s solution:

  • Set up an Amazon Connect instance.
  • Integrate the Amazon Connect CTI adapter with the Salesforce Lightning.
  • Design the data model and implement data integration.
  • Create a contact flow for the airline customer service use case.
  • Enable the Kinesis Data Stream in the Amazon Connect instance.
  • Configure to trigger the AWS Lambda function from the Kinesis Data Stream.
  • Write the Lambda function to connect to Salesforce using a REST API and create a case object.

Create an Amazon Connect Instance

An Amazon Connect instance is used to hold together all of the resources and settings related to the contact center. Upon creation of an AWS account, using the AWS Management Console, an Amazon Connect instance can be created.

For more information about setting up your instance, read the Get Started section of the Amazon Connect Administrator Guide.

Integration Between Amazon Connect and Salesforce

In order to launch the Amazon Connect contact center within the Salesforce CRM, the Contact Center Panel (CCP) needs to be integrated into Salesforce to establish a connection between the two systems. We integrated the Connect CTI with Salesforce using the CTI Adapter Managed Package, which is available at no cost in the AppExchange Marketplace.

The integration process involves the following steps.

Step 1: Install the Amazon Connect CTI Adapter

The Amazon Connect CTI Adapter for Salesforce provides the core integration between the two platforms. It embeds the Amazon Connect CCP into Salesforce, which provides telephony control as well as access to event data coming from Amazon Connect.

Using this adapter, you can configure screen pops based on customer data, automate contact center telephony functions like click-to-dial, and establish presence syncing rules for integration with Salesforce Omni-Channel. This is the base of the integration.

Step 2: Configure a Salesforce Call Center

This step will configure the CTI Adapter for Service Console (Lightning Experience).

For a detailed walkthrough and instructions on setting up the Amazon Connect CTI integration with Salesforce Lightning, see the Amazon Connect CTI Adapter v4 for Salesforce Lightning Setup and Installation Guide.

Step 3: Test the Amazon Connect CTI Adapter

Once the integration is complete, you need to test the integration. For instructions on testing the integration using Amazon Connect instance login and the Service Console, see Test the Amazon Connect CTI Adapter.

Step 4: Configure Salesforce as an Identity Provider for Amazon Connect

An identity provider is a trusted provider that lets you use single sign-on (SSO) to access other websites. A service provider is a website that hosts apps. Users can access other apps directly from Salesforce using SSO, which is a great help to users. Instead of having to remember many passwords, they only need to remember one.

In our architecture, Salesforce lets users log into Amazon Connect using SSO from our Salesforce org configured as an identity provider.

For instructions on configuring Salesforce as an identity provider specifically for Amazon Connect, see Appendix B: Configuring Salesforce as Your Identity Provider in the Amazon Connect CTI Adapter v4 for Salesforce Lightning Setup and Installation Guide.

For instructions on enabling users to log into AWS using SSO from your Salesforce org configured as an identity provider, see Configure SSO from Salesforce to AWS in the Salesforce Help documentation.

Configuring Salesforce as an identity provider for AWS involves these steps:

  • On Salesforce, configure a subdomain with My Domain and get a certificate.
  • On Amazon Connect, supply the required information from your Salesforce configuration.
  • On Salesforce, create a connected app to run Amazon Connect in Salesforce.

Data Integration

We use Amazon Aurora database as the primary backend database for the solution. Near real-time data transfer between Salesforce and Aurora takes place through OData REST APIs. The following connection paths are used for data transfer.


Figure 3 – AWS and Salesforce integration points.

Salesforce to AWS

  • Salesforce Service Cloud UI acts as the single source of truth for the agent to get any customer-related information required for solving customer queries. Diverse real-time information such as customer details, case history, order/booking history, or previous interaction history is available in an intuitive and easily comprehensible manner.
  • Salesforce reads the external data from Aurora through OData REST APIs, which are exposed by API gateways. Native Salesforce object information like Cases is stored and accessed internally.
  • Easy access to information for the agent leads to faster resolution times, increased first call resolution, and better customer experience.

AWS to Salesforce

  • Every customer interaction is stored in a Salesforce Case object.
  • For each call/chat initiated by a customer, cases are created in Salesforce through calling composite REST APIs.
  • If the call is transferred to live agents, the automatically created case is presented to the agent to work on.

Mule ESB to AWS and Salesforce

  • Mule ESB is used for continuous migration of specific business data from Aurora to Salesforce through REST API endpoints.
  • For certain Salesforce objects (agent performance metrics, for example) where continuous batch processing is required, Mule Anypoint Platform endpoints are used to get data from Aurora tables using OData REST APIs and post it into the Salesforce objects using SF REST APIs.

Creation of Contact Flow

A contact flow is the most primitive configuration element of the Amazon Connect contact center implementation. It determines how callers will be routed through the contact center based on a series of interactions between the user and the interactive voice response (IVR) system.

To implement our solution, we created a simple contact flow in Amazon Connect and published it to start handling contacts. We’ll describe the voice flow as part of this post, but our overall ISE solution is implemented with both call and chat flows.


Figure 4 – Simple contact flow to handle inbound call.

The following processing takes place as part of the configured flow:

  • The first step is to automatically recognize a caller based on the phone number used for dialing. Then, information from the backend Aurora database system is accessed to get the caller information like name, flight loyalty status, etc. This is achieved through the initial AWS Lambda function to handle a data dip.
  • The virtual agent/IVR then greets the customer with her name and flight loyalty status.
  • The virtual agent prompts the customer, saying “How can we help you today?”
  • The virtual agents can provide natural language-based interactions to improve customer experience, by integrating with Amazon Lex which provides automatic speech recognition and natural language processing (NLP) capabilities. These virtual agents can handle repetitive and standard customer queries like booking status without the need to talk to an agent, freeing live agents to handle the more complex queries.
  • The customer can transfer to a live agent if she wishes to.

Case Creation as Part of the Contact Flow

Cases are created in Salesforce for all calls/chats between customers and live or virtual agents through Salesforce REST API calls made in AWS Lambda.

There are two scenarios involved:

  1. Happy Path Scenario – Customer resolution through virtual agent or call successfully transfers to live agent.
    Our ISE solution provides for automatic case creation in Salesforce, when a virtual agent is able to successfully resolve a caller request or when it transfers the call to a live agent. This helps record interactions in which participation of live agents is not required; when a caller asks a query about her flight status, for example.
    Even in the scenario where the call needs to be transferred to a live agent for more action and information, the virtual agents reduce time and effort required by the live agent to collect information from the caller.
    When a call handoff takes place, call context information collected by the virtual agent is handed over to the live agent through an automatically created case, thus avoiding the need to repeat the entire information again to the live agent.
  2. Call Disconnect Scenario – Call gets disconnected before customer is serviced.
    In typical call flows, virtual agents or live agents process the customer’s request. There might occur situations where, after a customer’s call lands in the Amazon Connect contact flow, the call could be disconnected or dropped due to network problems or unforeseen system errors. We track such calls by creating a case in Salesforce through Rest API calls.
    To identify between happy path versus call drop scenarios, intelligence is embedded in AWS Lambda functions, which analyzes Contact Trace Records (CTR) to check Contact attributes set from call flows. A CTR is a unique information record for each contact landing in Connect. CTRs capture the events associated with a contact in your contact center.
    In the CTR records, if agent-related information exists or any specific status attribute says “processed by virtual agent,” then it’s treated as a happy path. Otherwise, it’s treated as an exception scenario.
    The diagram in Figure 4 shows the logical solution architecture implemented to achieve this. Amazon Connect will stream all the created CTRs to Amazon Kinesis through a configured data stream that further triggers our Lambda functions to create cases.


Figure 5 – Creating case by processing CTR records stream.

Enable the Kinesis Data Stream in Amazon Connect

We performed all of the following steps to enable case creation in case of disconnected calls.

  • First, go to the AWS console and select Services > Kinesis. Click on Create Data Stream.
  • Key in Data stream name and enter “1” as the Number of open shards. Click on Create Data Stream, and a success message will appear upon creation of the data stream.


  • Go to the AWS console and select Services > Amazon Connect, and then choose Data Streaming on the left menu.
  • Tick the checkbox for Enable Data Streaming.
  • Select the Kinesis Data Stream created earlier from the drop-down.


Trigger AWS Lambda from the Kinesis Data Stream

  • Go to the configuration page of the desired Lambda function (Lambda > Function) from the AWS console. Click on Add trigger.


  • In the Add trigger configuration page, start by selecting Kinesis as a trigger from the Select Trigger drop-down options.
  • Next, select the same Kinesis Data Stream created earlier.
  • Provide the ideal Batch Size for the CTR records you want your Lambda function to process at a time. You may also provide an optional Batch window.
  • Select the Starting position as per your requirement. In this example, we are selecting Latest.
  • Tick the Enable trigger checkbox to create this trigger in enabled state. This enables Lambda to start receiving events from the Kinesis Data Stream.
  • Click the Add button to create this trigger, and a success message will show on the Lambda function page.

This marks the successful configuration of the Kinesis Data Stream trigger for our Lambda function.

Write the Lambda Function to Connect to Salesforce

The Lambda function configured to be triggered by the Kinesis Data Stream is invoked to create a case.

The following code (Python 3) is for iterating through Kinesis CTR records and process records:

def lambda_handler(event, context):"event: %s, context:%s" % (json.dumps(event), context))
        for record in event['Records']:
            #Kinesis data is base64 encoded so decode here
            null = None
            temp = payload.decode('utf-8')
            stringPayload = json.loads(temp)
  "Decoded payload: %s" % stringPayload)

            if 'Agent' in stringPayload and (stringPayload['Agent'] != None):
      "Agent connected record - skipping case creation")
            elif 'Queue' in stringPayload and (stringPayload['Queue'] != None):
      "Queued record - skipping case creation")
      "Perform Case creation")
                response = #sign in to salesforce & #call salesforce case api
      "response: %s" % response)
        return {
            'statusCode': 200
    except Exception as ex:
        logger.error('Error occurred while trying to process the event')
        raise ex

This code is for Salesforce OAuth sign-in:

class Salesforce:

    def __init__(self, config_values_dict):
        this method is used to initialize required attributes for connecting to salesforce

        :param config_values_dict: contains attribute values for initialization
        self.version = config_values_dict.get("sf_version") = config_values_dict.get("sf_host")
        self.consumer_key = config_values_dict.get("sf_consumer_key")
        self.consumer_secret = config_values_dict.get("sf_consumer_secret")
        self.username = config_values_dict.get("sf_username")
        self.password = config_values_dict.get("sf_password") + config_values_dict.get("sf_access_token")

        self.login_host =
        self.access_token = None
        self.auth_data = {
            'grant_type': 'password',
            'client_id': self.consumer_key,
            'client_secret': self.consumer_secret,
            'username': self.username,
            'password': self.password
    def sign_in(self):
        This method is used to sign into salesforce
        """"Salesforce: Sign in")
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        response = post_request(url=self.login_host + "/services/oauth2/token", params=self.auth_data,
        sf_api_response = response.json()
        self.access_token = sf_api_response['access_token'] = sf_api_response['instance_url']
        self.headers = {
            'Authorization': 'Bearer %s' % self.access_token,
            'Content-Type': 'application/json'

This code is for creating case in a Salesforce object:

    def call_case_api(self, payload):
        This method is used to call case api of salesforce.

        :param payload: this basically act as request body while making request to composite api
        :return: return the json response returned by salesforce composite api
        """"Salesforce: case")
        sf_case_api_url = '%s/services/data/%s/sobjects/Case' % (, self.version)
        response = post_request(url=sf_case_api_url, payload=payload, headers=self.headers)
        return response.json()

Clean Up

To avoid incurring future charges, delete the resources.


Amazon Connect can work seamlessly with Salesforce CRM to provide a fully functional contact center solution that is quick and easy to set up and provides improved overall customer experience through intelligent call and case handling.

The PwC solution detailed in this post can be augmented with analytics and personalization capabilities, automation, and self-service through conversational interfaces for a digital experience, which we achieve as part of our larger ISE solution.

The content and opinions in this blog are those of the third party author and AWS is not responsible for the content or accuracy of this post.


PwC – AWS Partner Spotlight

PwC is an AWS Competency Partner that helps customers drive innovation throughout IT and the business to compete in today’s service economy.

Contact PwC | Practice Overview

*Already worked with PwC? Rate the Partner

*To review an AWS Partner, you must be a customer that has worked with them directly on a project.