AWS Contact Center

Caller Scheduled Callback in Amazon Connect

Introduction

Contact center managers are always looking for ways to reduce the time callers spend in a queue waiting for available agents. Providing a callback option significantly improves the customer experience and optimizes the operational costs of your contact center. Callback capabilities are offered natively with Amazon Connect. Callers leave their phone number so the agent can call them back when they become available. What happens though if the caller needs to schedule a specific time to be called back?

Using the solution described here, contact center managers will be able to offer scheduled callbacks. In this blog post, you can expect to understand how Amazon Connect uses Amazon DynamoDB, AWS Lambda, and AWS Step Functions to build an architecture allowing customers to schedule a callback during specific hours of operation.

OverviewSolution Architecture diagram

Fig 1 – High-level architecture diagram

Caller Experience

In this architecture, the caller calls into an Amazon Connect contact center. They are passed to a contact flow where an Amazon Lex chatbot can provide a conversational experience for the customer, requesting them to schedule a time to be called back. The Amazon Lex chatbot returns the requested date and time to the contact flow as slots. An AWS Lambda function then takes the date and time as input and queries an Amazon DynamoDB table to check if the requested time is available. If the requested time is valid the caller can confirm their time and hang up. If it is invalid they are told the next available time and prompted again. When the scheduled time arrives an agent is reserved using Amazon Connect queued callback. Then, it places an outbound call to the user.

Determining Callback Availability

Callback availability is determined by the following steps:

  1. The contact center sets the number of available callback requests per hour as an AWS Lambda environment variable. By default this is set to 10 callbacks per hour.
  2. The contact center can also set how many days in advance a customer can schedule a callback using an AWS Lambda environment variable. By default this is set to 7 days in advance.
  3. Hours of operation details are stored in an Amazon DynamoDB table. This information is captured using an AWS Lambda function which calls the Amazon Connect HoursOfOperation API. When the hours of operation are updated you will need to run this function to update the Amazon DynamoDB table.
  4. Another AWS Lambda function uses the data in the hours of operation Amazon DynamoDB table to generate hourly entries for the number of available callback slots and stores them in a separate DynamoDB table. For example, let’s say your contact center is open from 9AM to 5PM everyday. Once this AWS Lambda function is ran there will be a total of 56 time slots created (1 time slot for each of the 8 hours open, for seven days) with a capacity of 10 callbacks per slot.
  5. When the caller requests a callback time, the time slots DynamoDB table is queried to see if the requested time 1) matches a corresponding time slot and 2) the corresponding time slot has available callback capacity. If both these conditions are met the time slot capacity decreases by 1 and the user’s callback is scheduled using an AWS Step Function state machine. Otherwise, the caller is told the next available time and prompted again.

Note that callbacks that have been successfully scheduled are logged in a separate Amazon DynamoDB table.

Predefined configuration

By default:

  • The solution allows 10 callbacks per hour within the hours of operation and scheduling up to 7 days in advance.
    • These parameters can be configured by adjusting the DAYS_IN_ADVANCE and the HOURLY_SLOTS environment variables found in the CbCreateAvailabilitySlotData and CbAddAdditionalDayAvailabilitySlots AWS Lambda functions.
  • The solution assumes you are using “Basic Hours” for your hours of operation.
    • If you have a different name for your hours you will need to manually adjust the “hoo name” attribute when invoking your Lambda function from the contact flow.
  • The solution assumes the caller is in the same timezone as your contact center hours of operations.
    • Additional configuration and development is required to enable multiple time zones
  • The solution expects times to be in 24 hour time
    • Additional processing will need to be added to adjust how the time is presented to the caller based on your specific use case.

Prerequisites

To follow along with the solution presented in this blog post, you must understand the following AWS services and features:

You also need an active AWS account with permission to create and modify AWS IAM roles and an Amazon Connect contact center with at least 2 claimed phone numbers

Walkthrough

Security Disclaimer

Please note that this solution is meant to serve as an example for how you can get started building a scheduled callbacks solution. We recommend performing additional code review, functional testing, and IT validation before releasing this solution in a production environment. Always make sure to thoroughly test your solution and follow AWS Security Best Practices.

Resources Created

This solution uses an AWS CloudFormation template to deploy the required resources in any AWS region with the AWS services outlined in the architecture above. It will create the following resources along with corresponding IAM permissions:

  • ACBlogCallbackHelperFlow: Contact flow used to meet with StartOutboundVoiceContact API requirement. This is a helper contact flow and does not impact customer experience.
  • ACBlogCallbackPlacingFlow: Contact flow used to support the agent first scheduled callback strategy before placing the outbound call.
  • ACBlogCallbackWelcomeFlow: Contact flow used by caller to schedule a callback.
  • CbAbortSfn: AWS Lambda function used to cancel CbSlotDateTimeUpdateSfn if the caller disconnects before confirming their callback.
  • CbAddAdditionalDayAvailabilitySlots: AWS Lambda function used to create callback time slots for an additional day. This function should be run nightly to ensure that there is always additional callback slots available. For instance, if the last available callback time slot is for January 1, running this function will create slots for January 2.
  • CbAddLambdasToConnect: AWS Lambda function for automatically adding relevant AWS Lambda function to your Amazon Connect instance.
  • CbAddLexToConnect: AWS Lambda function for automatically adding the Amazon Lex chatbot to your Amazon Connect instance.
  • CbCreateAvailabilitySlotData: AWS Lambda function for populating your Amazon DynamoDB table with the initial callback availability slot data.
  • CbGetFirstAvailableSlot: AWS Lambda function for suggesting the first available callback slot to the caller should they provide an invalid time.
  • CbGetHooFromConnectApi: AWS Lambda function for populating your Amazon DynamoDB table with you Amazon Connect instance hour of operations.
  • CbHoursOfOperationDetailsTable: Amazon DynamoDB table for storing hours of operation details.
  • CbIncrementAvailabilitySlot: AWS Lambda function for incrementing the capacity for a specific callback time slot. This function is executed by CbSlotDateTimeUpdateSfn.
  • CbLexTemplateBot: Amazon Lex bot for helping the caller schedule a callback. There is also a corresponding bot alias and version.
  • CbPlaceCallbackRequest: AWS Lambda function for scheduling the callback request. It is responsible for adjusting the DynamoDB table and creating an AWS Step Function state machine to fulfill the callback.
  • CbPlaceOutboundCall: AWS Lambda function responsible for placing the outbound call when the specific callback time arrives. This function makes a StartOutboundVoiceContact API call which is associated with the ACBlogCallbackPlacingFlow contact flow.
  • CbPlaceOutboundCallSfn: AWS Step Function state machine for triggering CbPlaceOutboundCall at the scheduled time.
  • CbProcessRequestedDateTime: AWS Lambda function for validating a callback request time and re-adjusting time slot capacities should the caller choose not to schedule the callback.
  • CbSlotAvailabilityTable: Amazon DynamoDB table for storing callback availability time slot data and available slot capacity.
  • CbSlotDateTimeUpdateSfn: AWS Step Function state machine for triggering CbIncrementAvailabilitySlot 60 seconds after the caller requests the callback time. This state machine is cancelled (using CbAbortSfn) if the caller confirms their callback time. This step function ensures that even if the caller is disconnected the time slot capacity is always accurate.
  • CbStepFunctionTable: Amazon DynamoDB table for storing details about a callback that has been scheduled.
  • CustomResourceCopySourceFunction: AWS Lambda function for getting all the source code and storing in a local S3 bucket. This function pulls from the public Amazon S3 bucket hosting the solution artifacts.
  • callbackblogartifacts: Amazon S3 bucket for storing the relevant artifacts in your local account to create this solution.

Deployment steps

    1. Sign in to the AWS Management Console.
    2. Download the AWS CloudFormation template from here onto your local machine.
    3. In the same region as your Amazon Connect contact center, create an AWS CloudFormation stack using the template file downloaded in step 2
    4. Enter the following parameters when prompted to specify stack details.
        1. Stack Name <required>: Enter a logical stack name (e.g., callback-request)
        2. LogLevel <required>: Enter the amount of info you want the AWS Lambda functions to be logging. By default this is set to ERROR.
        3. helperPhoneNumber <required>: Enter one of your Amazon Connect phone numbers in E.164 format. This number will be assigned to AC-Blog-CallBack-Helper contact flow later to allow for an agent first experience. This number will not be used to place the outbound call.
        4. instanceId: <required>: Enter your Amazon Connect Instance ID. This is NOT your ARN. To find your Amazon Connect Instance ID see this guide.
        5. queueId: <required>: Enter your callback queue ID. To find this go to your Amazon Connect Admin console and select queues. Select the queue that you want callbacks to be added to e.g., basic queue. Copy the last part, which indicates the queue ID (do NOT copy the Queue ARN)

      Screenshot for the CloudFormation template

    5. Keep the defaults on the remaining options page and select “I acknowledge that AWS CloudFormation might create IAM resources”. Then select Create Stack.
    6. Go to the Amazon Connect Admin console and edit the “AC-Blog-CallBack-Welcome” contact flow.
    7. Associate the Amazon Lex Bot in the “AC-Blog-CallBack-Welcome” contact flow. Click “get customer input” box.Contact Flow screen shot to update the Lex bot pointing
    8. Select the Lex bot with name “CallBackRequestBotV2” and alias “CbLexBotV2Alias.”
    9. For each of the “Invoke AWS Lambda Function” blocks, update the function ARN to match the corresponding AWS Lambda function deployed in your environment. Make sure to save and publish after updating. Note that these blocks may be pre-populated with AWS Lambda function names but you must go in and select the specific AWS Lambda function deployed in your environment. Following is the list of Lambda functions.
      1. CbProcessRequestedDateTime
      2. CbGetFirstAvailableSlot
      3. CbPlaceCallbackRequest
      4. CbProcessRequestedDateTime
      5. CbAbortSfn (used in 2 different blocks)Placement of Lambdas in AC-Blog-Callback-Welcome
    10. Go to the Hours of Operation table and define your Office hours. Note that by default this solution assumes your hours of operation are named “Basic Hours”. If this is not the case you will need to adjust the function input parameter “HOONAME” value in each Invoke Lambda contact flow block where it is given. Additionally, this solution can only be configured with one hours of operation. Additional development is needed to support multiple hours of operations.Hour of operation screen shot to update operating hours
    11. Go to Phone Numbers and assign the phone number entered in the AWS CloudFormation template to the “AC-Blog-CallBack-Helper” contact flow.
    12.  Assign one free number to the “AC-Blog-CallBack-Welcome” contact flow. This will be the phone number that callers will use to request callback.Phone number management screenshot
    13. Run a Test (use any input event data) of the CbGetHooFromConnectApi Lambda function. This will populate the Hours of Operation DynamoDB table.
    14. Run a Test (use any input event data) in the CbCreateAvailabilitySlotData Lambda function. This will populate the Slot Availability DynamoDB table. By default it will add 7 day’s worth of callback slots, one slot for each hour your contact center is open with a capacity of 10 callbacks per slot. See the Predefined Configuration section for more detail.
    15. (Optional) Setup automatic updating for availability slot data
      1. Included in this solution is a function for updating your Amazon DynamoDB table to add additional availability slots based on the day. By default, the “CbCreateAvailabilitySlotData” Lambda adds 7 days’ worth of callback slots to your DynamoDB table (the current day plus 6 more days).
      2. In order to add the next day, run “CbAddAdditionalDayAvailabilitySlotData.” This function will add the next available day open for scheduling. For example, if today is Monday, May 2nd then running “CbCreateAvailabilitySlotData” adds all the available callback slots through Sunday, May 8th. Running “CbAddAdditionalDayAvailabilitySlotData” will then add callback slots for Monday, May 9th.
      3. In order to keep your available callback slots table up to date, we recommend running this function once a day. To learn more about creating scheduled events that run AWS Lambda functions see this article.

Testing

To test your solution, call the phone number you associated with the AC-Blog-Callback-Welcome contact flow and follow the spoken instructions.

  1. Call the phone number associated with the “AC-Blog-CallBack-Welcome” contact flow and follow the spoken instructions. Indicate a time that you’d like to request a callback e.g. “I want a callback tomorrow at 2 PM” or “I want a callback on [Date] at 3:30 PM”.
  2. If the callback is scheduled successfully you will see a new entry in your CbStepFunctionTable DynamoDB table with relevant information.
  3. Login as an agent and make yourself available. Make sure the agent is set to use a routing profile connected to the callback queue you referenced in the CloudFormation parameter “queueId”. When the callback time arrives the agent should automatically receive the callback. Accepting it will trigger an outbound call to the phone number that scheduled the initial callback.
  4. Ensure you receive the outbound call and are automatically connected with an agent.

Clean up

In order to delete the resources created by the stack:

  1. Disconnect the AC-Blog-Callback-Welcome and AC-Blog-Callback-Helper Contact flows from your phone numbers.
  2. Abort any active CbPlaceOutboundCallSfn state machine executions.
  3. Delete the AWS CloudFormation template.
  4. Delete the objects and the Amazon S3 bucket created by the AWS CloudFormation template.

Pricing

You are responsible for all costs incurred with the infrastructure deployed by this solution. You can estimate the scheduled callback pricing by reviewing this spreadsheet. As an example, for 1000 callbacks, with an average of 5 minutes per call, the solution will cost approximately $200 per month.

Conclusion

In this blog post, we showed you how to deploy scheduled callbacks by running a provided AWS CloudFormation template. The template deploys the necessary Amazon DynamoDB, AWS Step Functions, Amazon Lex, and AWS Lambda resources. The flexibility to offer your customers the option to receive a callback at a designated time improves the success rate of connecting with your customers and your customer’s satisfaction scores. In addition, it optimizes your Amazon Connect costs. To update the solution as a customer first callback experience, modify the StartOutboundVoiceContact API parameters in the CbPlaceOutboundCall Lambda function to use the correct outbound number and contact flow ID. To customize the scheduled callback solution further, refer to the callback function available within Amazon Connect and the start outbound contact API.

Author Bio

Ankur Taunk is a Senior Specialist Solutions Architect at AWS. He helps customer achieve their desired business outcomes in the Contact Center space leveraging Amazon Connect.
David Kocen (he/they) is a Builder Solutions Architect at Amazon Web Services (AWS) based in Seattle, Washington. He helps accelerate customer’s cloud journey through the creation of open-source starter projects and sample code.
Satish Somasundaram is a Senior Consultant for Amazon Connect at AWS. He provides thought leadership and guidance to customers on their contact center migration journey to Amazon Connect.
Sven Heinig is a Senior Solutions Architect for Amazon Connect at AWS. In this position he helps our customers navigate their journey to the cloud to achieve their business outcomes.
He worked in different roles and demonstrated history of architecture and implementation in the Contact Center space for 10+ years, over 6,000 agent seats.
Kevin Moore is a Senior Sales Specialist on the Customer Experience and Engagement team at AWS. He supports Public Sector customers across state and local government agencies and education including K-12 and HED.