AWS Contact Center

Manage cancelled callback to reduce agent handle time with Amazon Connect

Callback mechanisms play a crucial role in modern contact centers as they allow callers to reserve their position in the queue without having to remain on hold. This not only enhances customer service by reducing wait times but also optimizes telephony costs and agent utilization.

When a callback is requested by a caller, it remains in the queue until it is either cancelled, cleared by an agent before it dials a customer, or when the customer is connected to an agent. This article will guide you through various methods to handle callbacks that are already queued but no longer needed by the customer. Additionally, the solution presented here has functionality to check if callers have previously requested a callback and prevents them from setting multiple callbacks. The solution employs Amazon Connect, AWS Lambda, Amazon DynamoDB and Amazon Kinesis.

Walkthrough

To demonstrate the Interactive Voice Response (IVR) solution described in this blog, let’s consider a scenario where a caller initiates an inbound call and requests a callback through an Amazon Connect contact flow. A DynamoDB record is created to maintain the state and ID of the callback. Initially, the record is set to PENDING status. A Kinesis event triggers a Lambda function to update the DynamoDB record with the callback ID. Subsequently, the record is updated with the appropriate callback state when customers call again to cancel their callbacks (CANCELLED) or when callbacks are handled by the next available agent (COMPLETED).

By leveraging the capabilities of Amazon Connect, Lambda, and DynamoDB, this solution provides an efficient and streamlined approach to managing callbacks in contact centers. It not only improves customer experience by reducing wait times but also ensures effective resource utilization and cost optimization for the organization.

Prerequisites

Working technical knowledge of the following AWS services helps understand the purpose of the resources created and what service created them:

Overall constraints

To remove the callback from the Amazon Connect queue, the solution relies on the Amazon Connect API and the callback ID, which is only available in a Contact Trace Record.

Contact flow constraints

As part of the configuration, the “Transfer to queue” block in the contact flow must have its maximum number of retries set to 0. This ensures that the contact flow does not attempt to transfer the call to the queue multiple times in case of failure, improving the efficiency of the callback handling process.

To collect information prior to deploying solution:

  1. If it does not exist, create an Amazon Connect instance (in the region of your choice) and claim a phone number.
  2. Enable data streaming for your instance and configure an Amazon Kinesis Data Stream to collect “Contact Trace Records”.
  3. Once Connect Instance is available and Data streaming configured/enabled, gather the following information:
    • Collect the Connect Instance ID:
      • Access the Amazon Connect console.
      • Navigate to the Connect instance for which you need to collect the Instance ID.
      • On the Overview page, locate and make note of the Instance ID.
    • Collect the name of the Kinesis Data Streams:
      • Access the Amazon Connect console.
      • Go to the Connect instance where you enabled data streaming.
      • Locate the Kinesis Data Streams name that was configured under “Data Streaming”
      • Make note of the Kinesis Data Streams name for further use.

To deploy resources via CDK:

Ensure the following are installed in your machine:

Solution architecture

Figure 1 – Cancelled callback offered to an agent

If a callback cancellation request does not remove the callback from the Amazon Connect queue before the system attempts to route the callback to an agent, the callback call is still routed to an agent. The agent would be informed to hang up the call before it dials the customer.

  1. The caller initiates an inbound call and is given the option to set a callback.
  2. A contact flow collects the caller’s phone number for the callback. Callback is set in queue; a record is created in DynamoDB and its callback status is set to “PENDING”.
  3. Amazon Connect identifies that a callback is in the queue and offers it to an “AVAILABLE” agent. When an agent selects the “Accept” button for a callback, an Agent Whisper flow is triggered. If callback status is “PENDING”, Amazon Connect starts dialing the callback’s phone number. Otherwise, it instructs the agent to proceed with hanging up the call. If the agent does not hang up the call at this point, Amazon Connect attempts to dial the callback’s phone number.
  4. Amazon Connect triggers the Outbound Whisper flow to initiate a call to the customer. Before the customer is dialed and connected with an agent, the Outbound Whisper flow checks the status of the callback in the DynamoDB table.
    • If the callback status is “PENDING”:
      • The Outbound Whisper flow updates the callback status to “COMPLETED.”
    • It informs the customer that the call is being routed to an agent.
    • The customer and agent are then connected.
    • The agent ends the call.

Figure 2 – Cancelled callback handled via Amazon Connect API – stopContact

  1. A caller initiates an inbound call and is given the option to set a callback.
  2. A contact flow collects the caller’s phone number for the callback. Callback is set. A record is created in DynamoDB and its callback status is set to “PENDING”.
  3. A Kinesis event is raised and updates callback record in DynamoDB with CallbackId (NextContactId).
  4. The same caller initiates another inbound call and is given the option to set a callback. This time an existing callback request is found in the DynamoDB and the caller is prompted to cancel the callback. Caller chooses to cancel the callback and disconnects. Callback status is updated to “CANCELLED”.
  5. Before the call is disconnected, the callback is removed from the queue using an Amazon Connect API – stopContact – which leverages the CallbackId to identify and remove the callback.

The following are the contact flows and descriptions referenced in both figures:

  • cfSetCallbackflow: This contact flow is responsible for placing the callback request into the queue,inserting a record into DynamoDB with the initial status set as “PENDING.” It also provides the functionality for the caller to cancel the callback which updates the state of the callback to “CANCELLED” if the callback has been removed from the queue.
  • cfAgentCallbackWhisperflow: When an agent accepts a callback request, this whisper flow is invoked to check if the callback has been cancelled. It checks the DynamoDB table to see if a cancellation record exists for this callback. If a cancellation record is found, the agent is notified and the callback is not connected. Otherwise, the call proceeds as normal and is connected to the agent.
  • cfOutboundFlowWhisperflow: This contact flow connects the customer callback to the agent after verifying it is still active. Before connecting the customer with the agent, the whisper flow updates the callback status to “COMPLETED” in the DynamoDB table if the previous status was “PENDING”.

The following are the callback status definitions referenced in both figures.

These statuses are managed within a DynamoDB table and are independent of how Amazon Connect handles callbacks. The Time to Live (TTL) in DynamoDB is enabled and defined to delete records after 24 hours.

  • PENDING: This status indicates that a caller has requested a callback. Amazon Connect places the callback in the queue, maintaining its position, and waits for an available agent. A corresponding record is created in DynamoDB to track the callback.
  • CANCELLED: If a caller who previously requested a callback decides to call again and cancel the callback, the status is set to CANCELLED in the DynamoDB table.
  • COMPLETED: After a successful callback or a cancellation, the callback status is updated to COMPLETED in the DynamoDB table. This update is performed through “cfAgentCallBackWhisperflow”, which also informs the agent to end the call.

Deploying solution (console)

To create the list of resources:

  1. Set the IAM user credentials as environment variables by performing the following commands via CLI
    • export AWS_ACCESS_KEY_ID=<REPLACE WITH ACTUAL ID>
    • export AWS_SECRET_ACCESS_KEY=<REPLACE WITH ACTUAL KEY>
  2. Go to https://github.com/aws-samples/amazon-connect-callbackmgmt 
  3. Initiate the download process
  4. Once the download is complete, locate the downloaded zip file on your local machine.
  5. Unzip file locally, right-click on the zip file and select the “Extract” or “Extract All” option.
  6. Open a terminal, navigate to the directory where the zip file was extracted, and run `npm install` to download dependencies.
  7. Run cdk deploy --all -c stream-name=<kinesis-stream-name> -c instance-id=<connect-instance-id>
    • Note: to run the command with an aws profile run cdk deploy --all -c stream-name=<kinesis-stream-name> -c instance-id=<connect-instance-id> --profile <profile-name>

To download the contact flows:

  1. The Contact flows are located under the /flows folder from the newly downloaded and unzipped repo on local machine.

To create contact flows:

To import your saved file and configure the Lambdas for each contact flow, follow the steps below:

  1. Login to the Amazon Connect Dashboard through the appropriate URL.
  2. Navigate to the Routing menu and select Contact Flows to view the list of contact flows.
  3. Choose the appropriate flow type option: Create Contact Flow, Create Agent Whisper Flow, or Create Outbound Whisper Flow.
  4. In the top-right corner, locate the drop-down menu next to the Save button . Click on it and select Import flow. This will load the flow previously downloaded.
  5. After the import is complete, click on the Save button.
  6. Select the title of the Invoke AWS Lambda function block to access its properties page.
  7. Within the properties page, go to the Function ARN section and choose the relevant Lambda function from the list of functions added to the Connect Instance.
  8. Once you have updated the Lambda function blocks for the contact flow, click on Save and then OK.
  9. Before publishing the flows, refer to the Note below for further guidance.
  10. Repeat steps #1 through #8 for the remaining flows.

Note: Due to contact flow dependencies, create and import the contact flows in the specified order, assigning the respective Lambdas using the following table before publishing the flows.

Order Name Lambda Function Name Flow Type
001 cfAgentCallBackWhisperflow -callback-read-callback-fn
-callback-get-10-digit-phone-fn
Agent whisper
002 cfOutboundWhisperflow -callback-get-current-time-fn
-callback-update-callback-fn
Outbound whisper
003 cfSetCallBackflow -callback-get-10-digit-phone-fn
-callback-read-callback-fn
-callback-get-current-time-fn
-callback-update-callback-fn
-callback-stop-contact-fn
-callback-write-callback-fn
Contact flow

To configure contact flows:

  1. To configure the Connect flows, go to the Routing menu and select Queues. From the options presented, choose Basic Queue. In the Settings section, select “cfOutboundWhisperflow” from the available options for the Outbound Whisper flow.
  2. Next, navigate to the Routing menu and select Contact Flows. Locate the “cfSetCallBackflow” contact flow and open it. In the Set working queue block, choose the Basic queue that you previously configured. Once done, click on Publish and then Ok to save the changes.

To publish contact flow – cfSetCallBackflow :

  1. After publishing the “cfAgentCallBackWhisperflow” and “cfOutboundWhisperflow” contact flows, open the “cfSetCallBackflow” contact flow for further configuration.
  2. In the contact flow editor, find the Set Whisper flow block and choose “cfAgentCallBackWhisperflow” as the Whisper flow for this block.
  3. Once you have made these modifications, click on Publish and then Ok to save the changes to the “cfSetCallBackflow” contact flow.

To attach a phone number to contact flow:

  1. Access the Amazon Connect console.
  2. Navigate to the Routing menu and select Phone Numbers.
  3. Choose the test phone number that you want to associate with the contact flow.
  4. Under the “Contact Flow” section, click on the drop-down menu.
  5. From the drop-down menu that appears, select “cfSetCallBackflow” as the main contact flow to be attached to the test phone number.
  6. After selecting the contact flow, click on the Save button to apply the changes.

For more detailed information on setting up phone numbers, please refer to the Claiming Phone Numbers documentation, which provides additional guidance on the process.

Validation

To validate the solution, follow these steps in order to set a Callback and test the cancellation scenarios:

To set a callback:

  1. Dial the test phone number to go through the flow.
  2. Follow the prompts and set a Callback as instructed.

To validate solution:

In order to validate the solution, follow the steps on the following scenarios:

  • Cancel Callback within 60 seconds (Handled by Agent):
    1. Place another call and when prompted, select the menu option to cancel the Callback.
    2. Login as a Connect agent and set your status to AVAILABLE.
    3. On the agent interface, a Callback will be offered on the screen. Click “Accept”.
    4. A message will inform the agent to hang up the call, indicating that the Callback has been cancelled.
    5. Open Connect Real-Time reports and verify that the queue for Callbacks has been cleared.
  • Cancel Callback after 60 seconds (Handled via Connect API):
    1. After approximately 60 seconds, place another call and when prompted, choose the menu option to cancel the Callback.
    2. Login as a Connect agent and set your status to AVAILABLE. No Callbacks will be offered to the agent.
    3. Open Connect Real-Time reports and verify that the queue for Callbacks has been cleared.

By following these instructions and testing the cancellation scenarios, you can validate the solution’s functionality. Additionally, ensure to review the Amazon Connect Real-Time reports to verify that the Callback queue has been successfully cleared in both scenarios.

Cleaning Up

To avoid incurring future charges, follow the steps below to clean up the deployed resources that you created when implementing this solution.

To delete the Amazon Connect instance:

  1. In the Amazon Connect console, under Instance alias select the name of the Amazon Connect instance, and choose Delete.
  2. When prompted, type the name of the instance, then choose Delete.

To delete the resources created via the CDK stack:

  1. From a Terminal. run the command cdk destroy –all -c stream-name=<kinesis-stream-name> -c instance-id=<connect-instance-id>

Resources

Amazon Connect Amazon Connect is an easy-to-use omnichannel cloud contact center that provides superior customer service at a lower cost.
Amazon DynamoDB Amazon DynamoDB is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale.
Amazon S3 Amazon S3 is an object storage service offering industry-leading scalability, data availability, security, and performance.
Amazon Kinesis Amazon Kinesis makes it easy to collect, process, and analyze real-time, streaming data so you can get timely insights and react quickly to new information.
AWS Lambda AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend.
AWS CloudFormation AWS CloudFormation lets you model, provision, and manage AWS and third-party resources by treating infrastructure as code.

Conclusion

In this blog, you learned about implementing a callback feature and managing unwanted callbacks using a series of Amazon Connect contact flows. Additionally, you learned the process of creating AWS resources through CloudFormation, importing contact flows, and configuring data streaming for capturing Kinesis events. The solution allows you to effectively handle unwanted callbacks either through the Amazon Connect API or with the assistance of an Amazon Connect agent.

If you require assistance in setting up this solution, AWS Professional Services is available to provide guidance and support. Additionally, you can seek assistance from Amazon Connect partners located worldwide, who specialize in implementing and optimizing Amazon Connect solutions.

To further enhance your understanding of Amazon Connect and explore more features, we recommend referring to the comprehensive Amazon Connect Administrator Guide, which provides detailed information and instructions on various aspects of Amazon Connect.

 

Herbert Guerrero

Herbert is a Senior Proserve Consultant for Connect. He enjoys designing and developing high-usability and scalable solutions. Understanding success criteria helps Herbert work backwards and deliver well-architected solutions. His engineering background informs the way he engages with customers’ mental models of what their solutions should look like.

Amit Bagga

Amit Bagga is an Amazon Connect Specialty Consultant with Amazon Web Services Professional Services group. With over 15 years of contact center experience, Amit is passionate about diving deep with customers in building solutions that is simple but yet powerful and most importantly delivers the utmost customer benefit.

Ed Valdez

Ed is a Specialty Consultant with Amazon Web Services. As a software development professional with over 23 years of experience, he specializes on designing and delivering customer-centric solutions within the contact center domain.

Peter Villiers

Peter is a Principal Consultant in the Amazon Connect Center of Excellence. He is a software development professional with over 30 years of experience in application development, cloud infrastructure, Amazon Connect and related services. He enjoys working with customers on complex opportunities, defining ideal outcomes then working backwards to a technical implementation.

Karl White

Karl White is a Senior Amazon Connect Specialty Consultant within the Amazon Web Services (AWS) Professional Services group. With 23 years of experience in the contact center domain, Karl has dedicated his career to the art and science of customer engagement. He is passionate about leveraging Amazon Connect to craft dynamic, configuration-driven experiences to solve complex customer problems.