AWS Contact Center

Provide easy communication with doctors and streamline billing for patients with Amazon Connect

The COVID-19 pandemic has forced many service industries to provide remote alternatives. The contact center has become a valuable resource for their customers. For healthcare providers, telehealth visits are a core service that may be supported by a contact center. However, legacy contact centers often make it difficult for patients to connect with their health care providers in an efficient, personal and secure manner. Implementing solutions such as streamlined billing can require complex integrations and multiple vendors. With more companies providing voice-based services, they must enable these secure solutions quickly.

Amazon Connect makes it easy for companies to implement custom integrations with their contact center and offers the ability to build telehealth solutions tailored to their use cases. In one example, our team helped MedStar Health implement a solution that integrates payment processes with their contact center launched during the pandemic. This blog post walks through how to deploy the solution.

MedStar Health

MedStar Health is the largest not-for-profit healthcare provider for patients in the Maryland and Washington, D.C. region. To support clinical staff in providing care for patients remotely, MedStar Health built a telehealth contact center using Amazon Connect.

For that contact center, MedStar Health enables patients to connect directly with specific clinical staff and to receive general medical assistance. Patients can specify an extension number when they call to reach their assigned healthcare provider. Further, if that healthcare provider isn’t available to take their call, the patient can leave a voicemail. This capability is provided by an existing solution called Voicemail for Amazon Connect.

Integrating the telehealth support solution with the rest of the healthcare partner ecosystem is crucial since telehealth billing is handled by a third party. Custom billing records are required for each contact, including data fields such as the healthcare provider’s extension number. The solution collects metadata about the patient’s visits with their healthcare providers so that bills can be accurately calculated.


This solution has the following prerequisites:

Solution overview

The solution to generate the metadata necessary for billing revolves around the Amazon Connect contact trace record (CTR) since each contact generates a CTR record. By streaming the records to Amazon Kinesis, a Lambda function transforms each record into the format needed by the third-party billing platform.

Connect Architecture

This can be accomplished by setting user-defined contact attributes within the Amazon Connect flow so they are part of the CTRs.

In this example solution, comma-separated values (CSV) files with the following fields are generated:

  • Call type (inbound or outbound)
  • Call initiation date and time
  • Duration of the call (in seconds)
  • Patient phone number
  • Healthcare provider extension
  • Total hold duration (in seconds)

The format and content of this file can be easily customized by modifying the Lambda function. These files are stored in a S3 bucket that can be shared with the third-party billing vendor.

CSV records are created for telehealth visits where the patient is connected to a healthcare provider, and not when they leave a voicemail. This is intentional since the patient should only be billed for a telehealth interaction with a healthcare provider.

Since healthcare data is sensitive, this solution was built using HIPAA eligible services. Further, all data in transit and at rest is encrypted using keys managed by AWS Key Management Service (AWS KMS). Least privilege permissions are employed by using AWS Identity and Access Management (IAM) policies that limit the rights granted for human and system interactions.


Follow the steps in this section to deploy the solution to your AWS account.

  1. Deploying voicemail solution.
    1. If this has not been done previously, follow the instructions to deploy voicemail solution to your AWS account.
  2. Deploying the CTR processor for Amazon Connect AWS CloudFormation stack
    1. Sign in to the AWS Management Console.
    2. To launch the stack, click the following button.
      Launch Stack
    3. On the Specify template page, the template should be defaulted. Choose Next.
    4. On the Specify stack details page, set a descriptive stack name. Specify the Amazon Resource Name (ARN) for the DynamoDB table created by the Voicemail for Amazon Connect stack. Then, choose Next:CloudFormation stack details
    5. On the Configure stack options page, add tags as appropriate, and leave all other values as defaulted. Choose Next.
    6. On the Review page, select the check box to acknowledge creation of IAM roles. Then, choose Create stack:
      Launch CloudFormation stack
    7. You can view the status of the stack in the AWS CloudFormation console in the Status column. The status should change to CREATE_COMPLETE in approximately 5 minutes.
    8. Review the Outputs tab for the CloudFormation stack. Take note of these values for future reference:
      1. ContactTraceRecordsBucket: S3 bucket where raw CTRs are stored
      2. ContactTraceRecordsCSVBucket: S3 bucket where CSV files are stored
      3. ContactTraceRecordsStream: Kinesis data stream for CTR records
      4. ProcessCTRLambda: Lambda function for transforming the CTRs
  3. Enabling Amazon Connect to look up agent extensions
    1. Navigate to the Amazon Connect console and select the instance you deployed in step 1.
    2. In the Contact flows settings page, scroll to the AWS Lambda section. Select the function with GetAgentExtensionByAgentId in the name:
      Connect Lambda Function
      Choose Add Lambda Function to allow it to be invoked from a contact flow.
  4. Configuring Amazon Connect to use the new CTR processor Kinesis data stream.
    1. Navigate to the Amazon Connect console and select the instance you deployed in step 1.
    2. In the Data streaming settings page, select the data stream with ContactTraceRecordsStream in the name. This stream was created by the CTR processor for Amazon Connect AWS CloudFormation stack.
    3. Navigate to the AWS Lambda console.
    4. Find the function with KvsProcessRecording in the name.
    5. Navigate to the Permissions tab, and select the IAM role associated with the function.
    6. Expand the KvsProcessRecordingPolicy, and choose Edit policy to modify the JSON policy. Replace the Kinesis data stream ARN created by the stack with the ContactTraceRecords Kinesis data stream.
      IAM Role for Kinesis
    7. Navigate back to the Configuration tab for the Lambda function.
    8. In the Designer section, select the Kinesis trigger and delete it.
    9. Choose Add trigger, select the ContactTraceRecords Kinesis data stream, leave all the defaults, and choose Add.

Contact flow configuration

Several example contact flows are included with Amazon Connect. The voicemail solution also installs a contact flow. These can be customized to meet specific requirements. The following is an example for a telehealth visit.

If a patient knows their healthcare provider’s extension, they can enter the extension and be routed directly to the provider. Otherwise, the patient’s call is routed to a general queue for the next available healthcare provider. If a healthcare provider isn’t available, the patient can leave a voicemail message. The following example shows the VM-Greeting flow modified to prompt the patient accordingly.

Connect Flow

To capture an agent’s extension number in the CTR record, it must be set as a contact attribute with a key of extensionNumber. There are two ways to set the extension number:

  • Inbound flow where caller specifies the extension number as input
  • Looking up the extension by the agent’s ARN for outbound flows and from agent whisper flow when connecting from a queue

Configure the Invoke AWS Lambda function step in the contact flow to get the agent’s extension.

Lookup Extension Flow

  1. In the Function ARN section, select the function with GetAgentExtensionByAgentId in the name.
  2. In the Function input parameters section, select Use attribute.
    1. Enter AgentArn as the destination key.
    2. Select Agent as the type.
    3. Select ARN as the attribute.
  3. Choose Save.
    Invoke Lambda Function

Configure the Set contact attributes step to store the agent’s extension.

  1. In the Attribute to save section, select Use attribute.
    1. Enter extensionNumber as the destination key.
    2. Select External as the type.
    3. Enter extension as the attribute.
  2. Choose Save.
    Set Contact Attribute

Using this configuration, the CTR records are generated for every call and stored in the ContactTraceRecordsBucket. Corresponding CSV records including the agent’s extension number are stored in the ContactTraceRecordsCSVBucket for completed contacts.

Cleaning up

To avoid incurring future charges, remove all created resources by deleting the CloudFormation stack. Note, the S3 buckets created by the CloudFormation stack are NOT deleted automatically to avoid accidental loss of data. Therefore, those S3 buckets must be cleaned up manually.


This blog post demonstrates how to integrate external billing solutions with your contact center. The solution in this post is an example of how this contact flow might look for a telehealth visit. Using this approach, information about the telehealth visits can be shared with downstream systems. Electronic Medical Records (EMR), care coordination systems, and healthcare data lakes are examples of such downstream systems.