AWS Contact Center
How to play prompts in an Amazon Connect contact flow from an Amazon S3 bucket
Amazon Connect, our cloud contact center on demand, allows playing prompts uploaded to the Amazon Connect instance, or playing dynamic TTS prompts (Text to Speech) using Amazon Polly. This works well for the majority of customers; however, some need to use prompts without going through the Amazon Connect admin user interface for various reasons. For example, customers with a massive library of pre-recorded prompts for specific languages, or in a voice they use consistently to represent their brand. Amazon Connect has added the ability to play prompts directly from Amazon S3 without loading them through the admin user interface to help with these cases. This allows customers to access their files directly from Amazon S3, our simple object storage in the cloud, to play these prompts. Additionally, storing the prompts in Amazon S3 allows for structured file storage based on languages or Line of Business separation.
There are three supported ways to reference these files to play via the play prompt block in the contact flow editor:
- Object URL/S3 URI
- Example: https://
- Example S3://
- Attribute to populate S3 URI or Object URL
- Concatenate to build path
Below we will walk you through how to configure permissions and contact flows in order to use this new feature.
The screenshots below show a simple file structure based on language, for storing prompts in Amazon S3. This will allow customers to upload prompts in a folder structure based on language (shown) or line of business.
This will allow you to programmatically select prompts to be played based on customer journey, selections, or stored preferences like language, support or sales paths, or menu options presented.
Let’s dive in.
Overview of solution
This solution uses Amazon S3 to store pre-recorded prompts which will we be utilized by “Prompt” blocks in Amazon Connect contact flows. When a customer calls a number that you have claimed in your Amazon Connect instance, a contact flow is executed to drive the customer experience. In the contact flow, you will point the Prompt block to play the pre-recorded recording from the S3 bucket using either one of the following formats:
S3://{bucket-name}/{folder-name-which-is-optional}/{pre-recorded-file.wav}
OR
https://{bucket-name}. s3.amazonaws.com/{folder-name-which-is-optional}/{pre-recorded-file.wav}.
Pre-recorded files should follow the specifications mentioned in the Amazon Connect documentation prior to uploading them into the Amazon S3 bucket.
Prerequisites
For this blog post, you should have the following prerequisites:
- An AWS account
- An existing Amazon Connect instance
- Access to AWS services
- Amazon S3 with access to create and modify permissions
Setting up the solution
These instructions assume a working knowledge of Amazon Connect and Amazon S3. For details on how to perform basic administration tasks with these services, see the following:
Step 1 : Create an S3 bucket and setup the permissions for Amazon Connect to access the bucket
- Sign in to your AWS Management Console and go to S3 Service. Choose Create bucket button at top-right
- Enter a bucket name and leave the rest with rest of the options with their default settings.
- Scroll to the bottom and choose Create bucket button.
- Open the bucket that you created in the step 2 from the S3 console.
- Choose Permissions tab.
- Choose Edit button and paste the following and ensure you replace your bucket name in the policy below:
- Choose Save changes button at the bottom right.
- It is very important to set the Condition in the S3 policy to ensure ONLY accounts and instances that you own have access to the bucket .
- Download this sample audio file.
- Goto the S3 bucket that you created, choose Upload button.
- Choose Add file button on the top-right and load the file that you downloaded.
- Choose Upload button on the bottom-right.
- Once the file is uploaded, choose Close button on the top-right.
- Choose Create folder button, enter “en” under Folder name text box and choose Create folder button at the bottom right.
- Choose “en” folder from the list.
- Choose Upload button on the top-right.
- Choose Add file button on the top-right and select the file that you downloaded.
- Choose Upload button on the bottom-right.
- Once the file is uploaded, choose Close button on the top-right.
{
"Version": "2012-10-17",
"Id": "Policy1634763725216",
"Statement": [
{
"Sid": "Stmt1634763712285",
"Effect": "Allow",
"Principal": {
"Service": "connect.amazonaws.com"
},
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::{replace_with_your_bucket_name}",
"arn:aws:s3:::{replace_with_your_bucket_name}/*"
],
"Condition": {
"StringEquals": {
"aws:SourceAccount": "{your-aws-account-number}",
"aws:SourceArn": "arn:aws:connect:{region}:{your-aws-account-number}:instance/{your-amazon-connect-instance-id}"
}
}
}
]
}
Step 2 : Create a contact flow in Amazon Connect assign a phone number to it
- Download a pre-built contact flow.
- Sign into your Amazon Connect instance.
- Navigate to the Routing tab within your Amazon Connect instance.
- Choose Contact flows.
- Choose Create contact flow button at the top-right.
- Select drop down next to Save, choose Import contact flow at the top right.
- Choose Select, and select the A-S3-Play-Prompt file that you download in step 1.
- Open the Play prompt blocks one by one and replace “amazon-connect-s3-prompts” with the bucket you created in the Step 1.
- Save and publish your contact flow.
- Navigate to the Routing and choose Phone number.
- Select a phone number and load the contact flow named A-S3-Play-Prompt.
Step 3 : Testing playing pre-recorded file from S3 bucket in Amazon Connect
- Dial the number that you connected to the contact flow A-S3-Play-Prompt, you will be prompted to choose option 1 through 4, which will demonstrate Amazon Connect playing a pre-recorded prompt associated with the A-S3-Play-Prompt contact flow using different techniques.
- Option 1 will load the prompts from the S3 bucket using “https:”, for ex. https://{your_bucket_name}.s3.amazonaws.com/customer-jaz.wav. Below is an excerpt from the CloudWatch logs that is written to by the Amazon Connect contact flow :
- Option 2 will load the pre-recorded prompt from the S3 bucket using the “s3” prefix, for example: s3:// {your_bucket_name}/customer-jaz.wav, below is an excerpt from the CloudWatch logs written to by the Amazon Connect contact flow :
- Option 3 will load the pre-recorded prompts from the S3 bucket using contact attributes and dynamically generate the link, for example: https://{your_bucket_name}/en/customer-jaz.wav, below is the excerpt from CloudWatch logs written by Amazon Connect contact flow :
- Option 4 will demonstrate, where the file does not exist in the S3 bucket and Amazon Connect will follow the Error path in the Play prompt block, below is the excerpt from CloudWatch logs written to by the Amazon Connect contact flow :
{
"ContactId": "957e5c1b-5636-4722-bfc5-08d8e0aa10aa",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:47:11.153Z",
"Parameters": {
"PromptLocation": "https:// {your_bucket_name}.s3.amazonaws.com/en/customer-jaz.wav",
"PromptSource": "S3"
}
}
{
"Results": "Success",
"ContactId": "4b73d936-8314-4bbd-8901-eede52e2069b",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:46:52.653Z"
}
{
"ContactId": "c9cc4fa9-9ca5-4215-a948-78cd99f6ec9d",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T19:00:56.602Z",
"Parameters": {
"PromptLocation": "s3://{your_S3_bucket}/customer-jaz.wav",
"PromptSource": "S3"
}
}
{
"Results": "Success",
"ContactId": "c9cc4fa9-9ca5-4215-a948-78cd99f6ec9d",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T19:01:03.043Z"
}
{
"ContactId": "957e5c1b-5636-4722-bfc5-08d8e0aa10aa",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:47:11.153Z",
"Parameters": {
"PromptLocation": "https://{your_S3_bucket}.s3.amazonaws.com/en/customer-jaz.wav",
"PromptSource": "S3"
}
}
{
"Results": "Success",
"ContactId": "957e5c1b-5636-4722-bfc5-08d8e0aa10aa",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:47:21.807Z"
}
{
"ContactId": "9d5cb566-7dd9-4d8b-92e6-095c7682f8d4",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:48:03.163Z",
"Parameters": {
"PromptLocation": "s3://{your_bucket_name}/customer-jaz2.wav",
"PromptSource": "S3"
}
}
{
"Results": "Unable To Download Prompt From S3.",
"ContactId": "9d5cb566-7dd9-4d8b-92e6-095c7682f8d4",
"ContactFlowId": "arn:aws:connect:us-west-2:{your-aws-account-number}:instance/193f1b67-3fea-46ff-abf7-8a25ca45866f/contact-flow/25523937-59f3-436f-8d80-e218c25a5747",
"ContactFlowName": "A-S3-Play-Prompt",
"ContactFlowModuleType": "PlayPrompt",
"Timestamp": "202X-XX-29T18:48:03.726Z"
}
Cleaning up
To avoid incurring future charges, delete the S3 bucket that you created under your account.
Conclusion
This post demonstrates how to configure Amazon Connect contact flows to play a recording that is stored in an Amazon S3 bucket. Using the new functionality, you can now:
- Play pre-recorded prompts from S3 bucket in Amazon Connect contact flow using “Play prompt” block.
- Play pre-recorded prompts by applying more dynamic logic based on the contact attributes in the contact flow.
- Error handling in the prompt block, making the customer experience more seamless in the event of errors.
Related links
To learn more about the technologies or features used to create this solution, see the following: