AWS Contact Center

Routing contacts based on performance objectives in Amazon Connect: Agent Occupancy (part 2)

Enterprise contact centers have performance objectives (service levels, agent occupancy, average speed to answer) to ensure a high-quality customer service. The methods used to route incoming contacts have a direct influence on these performance metrics. Amazon Connect makes it possible to route contacts based on objectives that are important to the business. Part 1 of this multi-part blog post series focused on customer facing metrics like service level. Part 2 focuses on resource management metrics like agent occupancy (utilization). Part 3 will focus on the routing actions and automated scaling of resources in a queue to balance these objectives optimally.

Occupancy is the percentage of time that the agent was active on contacts. It is a metric of agent productivity during a given period. Contact centers prefer to maximize this metric to save resource costs. Higher occupancy can drive lower service levels, and increase agent burn out risk. Legacy providers did not have an easy way to calculate occupancy metric real time. Contact center managers found themselves walking a tight rope balancing occupancy and service level based on historical reports.

This blog post demonstrates how to calculate and track occupancy at an agent level. Using this solution, contact centers can take quicker actions. You can build automation comparing current occupancy level to a configured threshold and take timely automated intraday actions to balance occupancy. These actions can include routing profile updates, prioritization, and taking agents offline to cover training backlog.

Solution Overview 

This blog post deploys an application to calculate agent level occupancy. Occupancy is the percentage of time that agents actively worked on contacts. For example, an agent spent six minutes on a contact (work), and one minute on after contact (work). They then spent three minutes waiting (idle) for an incoming contact. The agent occupancy in this scenario is 70% {(6+1) / (6+1+3)}. The solution provides a framework for calculating occupancy over a period, and across all the agents in the Connect instance. Occupancy is measured over a time period, and occupancy objectives could differ between queues (sales vs service).

Solution Flow 

  1. Amazon Connect streams agent state data to the Kinesis data stream.
  2. The processAgentEvents Lambda function is invoked for each event.
  3. The Lambda function:
    1. Retrieves the user name (agent login name) from either “CurrentAgentSnapshot” or “PreviousAgentSnapshot” agent events.
    2. Identifies the following agent status transitions:
      • Offline to available
      • Available to on-contact
      • On-contact to after-call-work (or other state)
    3. Stores the idle start time, available time, after-contact-work time, and on-call time in agentOccupancyDuration DynamoDB table.
  4. An update of agentOccupancyDuration DynamoDB table invokes a DynamoDB stream. The DynamoDB stream is enabled so that the occupancy results can be calculated asynchronously as soon as agent events are received from Amazon Connect.
  5.  The DynamoDB stream invokes calculateAgentOccupancy Lambda function to calculate agent occupancy percentage.
  6. The calculateAgentOccupancy Lambda function stores agent occupancy in agentOccupancy DynamoDB table. This table contains an attribute called occupancy for each user with value of occupancy in percentage.

The occupancy metric is constantly updated for each agent in agentOccupancy DynamoDB table based on new agent events streamed from Amazon Connect.


For this solution, you should have the following:

In addition, you should have knowledge and understanding of following services and features:

Deployment walkthrough

Step 1: Get Agent Event Kinesis data stream Name

  1. Sign in to the AWS Management Console and open the Amazon Connect console.
  2. Click on the Amazon Connect instance alias name, and select Data streaming from the left navigation panel. Follow the directions to enable agent event streams, if Kinesis Data Stream is not already enabled for your Amazon Connect instance.
  3. Make a note of name of the Agent Events Kinesis data stream.

Step 2: Launch CloudFormation template

    1. Sign in to AWS Management Console, and select the same Region as your Amazon Connect instance.
    2. Click on the button to launch the AWS CloudFormation template.

    1. Accept the default values and choose the Next button.
    2. Accept the default stack name (agOcc) or provide the stack name of your choice. Note that the resources that the CloudFormation template will create will be prefixed with the stack name. (agOcc-processAgentEvents).

    1. Enter name of the Kinesis data stream name used to stream the Amazon Connect agent events, and choose the Next button.
    2. On Configure stack options page, scroll down and choose the Next button.
    3. On the Review stack page, scroll down to the bottom of the page.

  1. Acknowledge IAM resources creation, and choose the Create stack button. This will take couple minutes to provision the resources. The AWS CloudFormation template creates the following resources for this solution:
    1. Two AWS Lambda functions processAgentEvents, and calculateAgentOccupancy.
    2. Two DynamoDB tables – agentOccupancyDuration, and agentOccupancy.
    3. One DynamoDB stream.
    4. Two IAM policies and IAM roles for two AWS Lambda functions.
    5. Configuration to invoke Lambda functions from Kinesis data stream and DynamoDB streams.

Step 3: Testing

Amazon Connect agent events generated when a state change occurs for the agent (such as going available, accepts a contact, goes in after-contact-work). These state changes are streamed from Amazon Connect to the Amazon Kinesis data stream.

  1. On your web browser, navigate to CCP login URL (https://<your-instance-alias>
  2. Enter Amazon Connect agent credentials to log in to CCP.
  3. On the CCP, change state from “Offline” to “Available”.
  4. Place a call to your Amazon Connect instance and route it to the logged in agent.
  5. On the CCP, accept the incoming call.
  6. Stay connected for couple of minutes, and disconnect.
  7. Leave agent in After-contact-work for a minute or so, and then end the ACW to go available.
  8. The occupancy for the agent is calculated and updated as agent enters different states (available, connected, end call, in ACW, end ACW).
  9. After each call, check the calculated occupancy metric.
    1. Log in to AWS Management Console and navigate to DynamoDB service.
    2. Check the “agentOccupancy” table to check the occupancy metric.
  10.  After a minute, repeat the process preceding from step 4.

You’ve successfully configured and tested Agent Occupancy. This can be used to make routing decisions based on least-occupied-agent and checking the agent state.

Clean up

    1. Navigate to Amazon Connect console
    2. Log in to your Amazon Connect Admin console, and select Routing, Phone Numbers from the left navigation panel.
    3. Navigate to CloudFormation console, select the agOcc stack (or the stack name you provided), and choose the Delete button. Delete the stack resources by choosing Delete stack button on confirmation screen


This post provides the framework to calculate agent occupancy. Using this, you can take manual actions or automated actions to manage your contact centers:

  • Use it in tandem with the outcome of part 1, to balance service levels and occupancy.
  • Determine time slots where highly occupied agents can be pulled out to complete other goals like training and offline work.
  • Update routing profiles and call prioritization logic to balance the incoming contact work load across agent population.


In this post, we implemented and demonstrated calculating agent Occupancy percentage from Amazon Connect agent event data. Deployed CloudFormation stack that included AWS Lambda functions and Amazon DynamoDB tables. Amazon Connect agent event data is used to calculate the occupancy when agent state change occurs. Tested the solution by logging in an agent and placing calls to Amazon Connect. You can enhance the solution based on your organization’s requirements.

With Amazon Connect, you pay for what you use. There are no upfront payments, long-term commitments, or minimum monthly fees. The price metrics are detailed on Amazon Connect pricing.

Should you need help with setting this up, you can get assistance from AWS Professional Services. You can also seek assistance from Amazon Connect partners available worldwide.

Meet the Authors

Parind Poi is a Senior Practice Leader at AWS Professional Services. He leads a specialized practice with deep expertise in customer experience (CX) on AWS. Parind is passionate about helping customers modernize their customer engagement workloads on cloud.
Prashant Desai is a Senior Consultant at AWS Professional Services. He is experienced in designing and migration of large contact centers to the cloud. Prashant is always looking for innovative ways to simplify customer experience.
Mehul Patel is a Senior Consultant at AWS Professional Services. Mehul has more than 20+ years of experience in Contact Center and telecommunications field with traditional and cloud-based contact centers, working as a solution architect supporting large enterprise customers.
Join us for AWS Contact Center Day, a free virtual event where you’ll learn about the future of customer service, how machine learning can optimize customer and agent experiences—and more. Register now »