Setting Up Your First Call Center on AWS: A Step By Step Guide
Tags: serverless, contactcenter, tutorial, aws
Published: 2023-12-20 13:00:00

> _Discover how to set up your first Amazon Connect instance with this step-by-step guide. Explore features, pricing, and secure call center management._

## Introduction
In today's digital age, where customer service is essential, having an efficient and scalable call center solution is crucial. Amazon Connect, a cloud-based contact center service by Amazon Web Services (AWS), offers a robust and flexible platform to create and manage your call center operations seamlessly.

In this step-by-step guide, we will walk through the process of creating an Amazon Connect instance, exploring its key features, understanding the pricing model, ensuring the secure storage of call recordings and contact trace records, and after that, we can test it out!🛠️

Whether it's a small business or a large enterprise, Amazon Connect certainly has a lot to bring to the table. Let's get started! 🚀
> _⚠️ About Me: I have been working with Amazon Connect since November 2022, and our instance successfully handles 10,000 concurrent calls every single day. Through this series, I aim to share my hands-on experience in building and managing a contact center on AWS._

---

## What is Amazon Connect
Let's get down to the basics and understand what Amazon Connect is all about. Imagine we have a business, be it small or large, and we're looking to enhance our customer service operations. Well, Amazon Connect is the solution we've been searching for.

In essence, Amazon Connect is a cloud-based, managed service provided by Amazon Web Services (AWS). It's designed to simplify how you handle customer interactions. One of the significant advantages of Amazon Connect is its ease of use. We won't need to invest in costly hardware💲, worry about maintenance, or navigate through intricate software installations. Everything is managed in the cloud, eliminating the need for outdated, on-premises systems.

Okay, we are only scratching the surface. AWS's service has a lot more to offer. Yes, we can make inbound calls, but we can also handle outbound calls. We can use its chat functionality or manage agents' scheduling, even guiding them to improve customer satisfaction. It has many more features, but for now, we will cover only the basics. I don't want this post to become bloated with content 🌋.

Now, let's address the question on everyone's mind: How much does Amazon Connect cost?

---

## Amazon Connect Pricing
The service offers a pay-as-you-go pricing model, which means you only pay for what you use! Essentially the billing motto is: you pay based on the minutes you spend talking📞. With that in mind, let's provide an example of a real bill, assuming our call center works exclusively in Italy:
* **End customer minutes used:** $0.018 per minute. This means that AWS charges based on the total accumulated minutes of voice calls that the contact center handles.
* **Outbound calls:** $0.0200 per minute.
* **Inbound calls (DID):** $0.0040 per minute. I used DID as an example. If you had a Toll-Free or UIFN number, the price per minute changes.
* **Claimed Phone Numbers (Toll-Free):** $0.32 per number per day. This charge applies when you claim a phone number. If you had a DID or UIFN number, the price changes.

To sum it up with an example, here are the assumptions:
*10 Toll-Free numbers claimed = 10 * $0.32 = $3.2
* On average, call duration is 5 minutes, and we have 500 calls per day, totaling 75,000 minutes = 75,000 * $0.018 = $1,350
* 60,000 minutes are from Inbound calls = 60,000 * $0.0040 = $240
* 15,000 minutes are from Outbound calls = 15,000 * $0.0200 = $300

This leaves us with a grand total of $1,893.2 per month for 500 daily calls💲.

Now that we've got a solid grasp of Amazon Connect pricing, it's time to roll up our sleeves and dive into the practical side of things🤿.

> _⚠️Note: we are going to use Terraform as our Infrastructure as Code (IaC) tool. Every resource will be created using it._

---

## Infrastructure
It may seem simple at first - in fact, it is straightforward! However, to ensure the call center is fully prepared and compliant, we need to include the following essential resources:
* KMS Key for **data encryption**. This is critical to secure sensitive data.
* S3 Bucket for storing **call recordings**. This is crucial for compliance, as regulations often require call recordings to be stored for several years, depending on the location of the call center.
* Kinesis Stream with Lambda for retrieving **Agent Events**. Agent Events play a vital role in custom agent logic.
* Kinesis Stream with Lambda for retrieving **Contact Trace Records**. Compliance is not the only reason to use Contact Trace Records; you'll also discover their incredible potential when integrated into a Data Warehouse.
* **Phone number** associated with a Contact Flow. Contact Flows define the customer experience within a contact center. They consist of a series of instructions that determine how customer interactions are handled and routed within the system. For instance, in the example below, we set the logging and recording behavior, play a prompt to customers, and then redirect them to available Agents.

![Contact Flow Example](https://content.cloudnature.net/images/bfac6388-a5fe-4df7-a16d-c2c7277baf3b)

These components work together to create a robust and compliant call center infrastructure. 

Oh, and one more thing! This architecture is designed for high availability across 3 different Availability Zones. Pretty cool, right? No added cost for in-region disaster recovery. ❤️️

> _⚠️Note: for the sake of simplicity, our Lambda function simply prints the event. Normally, you would want your Lambda function to incorporate custom logic for your CRM or even attach a Kinesis Firehose to the Kinesis Stream to save data to S3 for compliance purposes._

---

## Creating Your Amazon Connect Instance
As I mentioned before, it’s really straightforward!

```
resource "aws_connect_instance" "this" {
  instance_alias            = [YOUR_INSTANCE_ALIAS]
  identity_management_type  = "CONNECT_MANAGED"
  inbound_calls_enabled     = true
  outbound_calls_enabled    = true
  contact_flow_logs_enabled = true
}
```

Yes, that’s really all there is to it! With these few lines, we were able to create our Call Center. Does it work? Yes, it does! It even includes a few Contact Flow examples you can run.

But what do these lines mean? With this configuration, we’ve enabled contact flow logs for our instance, along with the ability to receive inbound and outbound calls. We could have also enabled contact lens, but it’s not necessary for now.

Anyway, the purpose of this post is to show how to set up a real call center. So, we can’t stop here, we have a few building blocks to create. 🧱

---

## Securely Storing Call Recordings
Guess what? We can natively store Call Recordings in Amazon S3 with just a few lines of code. But there are a couple of really handy features of S3 that we need to keep an eye on:

1. **Object lock** configuration: this feature gives us an extra layer of protection against changes or deletions of recordings for compliance purposes. You can also set up the retention period as needed.
2. Server-side **encryption**: of course, there’s no real “Security” without KMS, so we need to ensure that we create a key and use it to encrypt everything.
In the end, we’ll have this configuration for storing call recordings:

```
resource "aws_connect_instance_storage_config" "call_recordings" {
  instance_id   = module.connect_instance.id
  resource_type = "CALL_RECORDINGS"

  storage_config {
    s3_config {
      bucket_name   = module.s3_bucket.s3_bucket_id
      bucket_prefix = "CallRecordings"

      encryption_config {
        encryption_type = "KMS"
        key_id          = module.kms_key.key_arn
      }
    }
    storage_type = "S3"
  }
}
```
These steps ensure that your call recordings are securely stored in Amazon S3.

---

## Saving Contact Trace Records and Agent Events
I highly recommend saving them to S3 as well! But first, we need to go through a Kinesis Stream, which enables future custom real-time development. In this demo, I’ve created a Kinesis stream and a Lambda function that reads from the stream and prints records. Linking the Stream to Amazon Connect is seamless. Here’s the configuration for Contact Trace Records (it’s the same for Agent Events):

```
resource "aws_connect_instance_storage_config" "contact_trace_records" {
  instance_id   = module.connect_instance.id
  resource_type = "CONTACT_TRACE_RECORDS"

  storage_config {
    kinesis_stream_config {
      stream_arn = module.kinesis_contact_trace_records.arn
    }
    storage_type = "KINESIS_STREAM"
  }
}
```
And there you have it — our contact center is now ready to be safely used! 🚀

---

## Configuring Phone Numbers
A Call Center without a phone number is almost useless. Let’s explore how we can claim one and what steps we need to follow afterward.

Claiming a phone number isn’t automated; you’ll need to open a ticket or request it directly in the Amazon Connect instance.

First, we need to log in to our instance. Since it’s the first time, and we don’t have any users created, we’ll need to use the emergency access feature 🚨.

![Emergency Log In](https://content.cloudnature.net/images/f3dc58ca-297d-480d-9553-2d71778b1193)

Next, navigate to the **“Phone numbers”** section and click the **“Claim a number”** button in the top-right corner. Find the country from which you need the number, select the number, and you’re all set!

> _⚠️Note: if there are no numbers available for that country, it’s because some countries require verification even for Toll-Free numbers. You can find more information for each country here: https://docs.aws.amazon.com/connect/latest/adminguide/phone-number-requirements.html.
P.S. You can select another country without verification requirements if needed._

With our first number claimed, the only thing left is to test our Call Center.

---

## Testing the Call Center
Now that we’ve claimed our phone number, we can associate it with a Contact Flow. Let’s do just that! Click on the newly claimed phone number and select “Sample recording behavior.”

One more thing we need to do is have an Agent available. To do this, select “Agent Workspace” or “Contact Control Panel” from the top-right header bar, and then select “Available.”

Now, we can call the number we claimed. After a few steps in the sample Contact Flow, we’ll call an agent (ourselves), and our Panel should ring ☎️.

![Contact Control Panel with incoming call](https://content.cloudnature.net/images/82465637-fd42-4a56-97be-cb9d2f5865ec)

Once we’ve had a few minutes of fun with ourselves, we can close the call and check the results:

* The S3 bucket has a new folder named “CallRecordings,” which contains our recording.
* CloudWatch logs have a log group named after your instance. With this sample flow, we won’t see any logs, but if we had added the “Set logging behavior” block to the contact flow, we would have seen everything that happened during the interaction.
* CloudWatch logs have two new log groups for our Lambda functions. In these, we can find the agent events and contact trace records that were passed from the Kinesis Stream to our Lambda function.
Pretty cool, isn’t it? With just a few configurations, we’ve managed to create a polished Call Center!

## Conclusion
Congratulations, you’ve successfully embarked on the journey of setting up your very own Amazon Connect call center! But remember, setting up your call center is just the beginning. Amazon Connect offers endless possibilities for customization and optimization.

> _Here you can find the GitHub repository: https://github.com/Depaa/amazon-connect-terraform/tree/main 😉_

If you enjoyed this article, please let me know in the comment section or send me a DM. I’m always happy to chat! ✌️

Thank you so much for reading! 🙏 Keep an eye out for more AWS-related posts, and feel free to connect with me on LinkedIn 👉 https://www.linkedin.com/in/matteo-depascale/.

References
* https://docs.aws.amazon.com/connect/latest/adminguide/what-is-amazon-connect.html
* https://docs.aws.amazon.com/connect/latest/adminguide/phone-number-requirements.html
* https://aws.amazon.com/connect/pricing/