Simplify number management in Amazon Connect with dynamic routing
Overview of the solution
Corporations today can accumulate hundreds or even thousands of telephone numbers, making it difficult to keep an accurate inventory or know the treatment for each number. Sales and marketing departments can have a different number for every marketing campaign, or customer service may have numbers for every support center. Businesses want to have a consistent customer experience no matter what department is being reached, but how can they do so when they manage so many different numbers in different parts of the company? This blog presents a solution for managing such scenarios with Amazon Connect by dynamically routing to contact flows based on the number dialed.
With this solution, the telephone numbers in your Amazon Connect instance are assigned to a single contact flow. AWS Lambda queries an Amazon DynamoDB table to retrieve all the settings to drive the contact flow. This simplifies managing your telephone number as you only have to maintain one contact flow instead of one contact flow per phone number.
This solution describes how to handle three different experiences for your customers with custom emergency messaging, queue settings, and messaging.
To follow along with the solution presented in this post, you should understand the following AWS services and features:
- AWS CloudFormation – Model and provision all your cloud infrastructure resources
The AWS CloudFormation template deploys two Lambda functions, an IAM role for Lambda, and a DynamoDB table for phone number configuration.
- Amazon DynamoDB – NoSQL database service
The DynamoDB table is used to store your Amazon Connect telephone numbers and any attributes you want to associate to a particular contact flow. The table has a primary key of dialed_number.
- AWS Lambda – Serverless compute service
One Lambda function uses the Amazon Connect system attribute dialed_number to query the DynamoDB table and retrieve all attributes associated with the number.
The other Lambda function builds a DynamoDB table to store the settings for your numbers and contact flows.
- Amazon Connect – Omnichannel cloud contact center service
You will claim three telephone numbers in Amazon Connect and assign them to the entry point contact flow.
Amazon Connect configuration
Import the contact flows
A contact flow defines how a customer experiences your contact center from start to finish. Contact flows enable you to customize your IVR (interactive voice response) system.
- Download the sample contact flows.
- Log in to your contact center using your access URL.
- In the Amazon Connect console, choose Routing, Contact flows.
- Choose Create contact flow. This opens the contact flow designer and creates an inbound contact flow (Type = Contact flow).
- Select the down arrow next to the Save button and choose Import flow (beta).
- Choose Select.
- Navigate to the downloaded “EntryPointFlow” file, then choose Open.
- Choose Import.
- Choose Publish.
- Repeat steps 3 through 9 for the DemoSales, DemoService, and DemoMarketing contact flows.
- Capture the ARN for the DemoSales, DemoService, and DemoMarketing contact flows by expanding Show additional flow information in each flow. Copy the ARNs to your text editor.
Claim phone numbers in Amazon Connect
- In the Amazon Connect console, choose Routing, Phone numbers.
- Claim three new phone numbers. Refer to the Claim a phone number section of the Administrator Guide for additional information.
- For the Contact flow / IVR value, choose EntryPointFlow.
- Enter a description for the flow.
- Choose Save.
- Repeat these steps for the other two numbers.
- Copy the three phone numbers to your text editor for use with each of the contact flows that were imported. You now have the name, ARN, and phone number to be assigned to each flow in your text editor. These will be used for the AWS CloudFormation template in the next step.
Create queues for each department
- In the Amazon Connect console, choose Routing, Queues.
- Select Add new queue.
- Enter Sales for the name of the queue.
- Select Basic Hours for the Hours of operation.
- Choose the Add new queue button to create the queue.
You now have three queues, one for each department.
Update CloudFormation template
Now we must collect the ARN for each queue to input into the AWS CloudFormation template. Save each of the ARNs to your notes.
- In the Amazon Connect console, choose Routing, Queues.
- Select the Sales queue.
- Choose the Show additional queue information link to display the queue ARN.
- Copy the ARN to your clipboard and paste in your text editor.
- Repeat steps 2 through 4 for the other two queues created previously.
- After all the preceding steps, your notes should look similar to this example.
In this step, we use CloudFormation to automatically create the IAM role, the AWS Lambda functions, and the DynamoDB table. The CloudFormation process also adds the phone number configuration items to the DynamoDB table.
- Log in to the AWS Management Console.
- Confirm that the selected AWS Region contains the target Amazon Connect instance.
- Select the following Launch Stack button to open the CloudFormation template in the AWS Management Console.
- Copy and paste the inbound numbers (in E.164 format, including the + sign) and ARNs for contact flows and queues collected in your text editor into the stack parameters.
- Read and agree to the acknowledgement by checking the box.
- Choose Create stack
Add Lambda function to Amazon Connect
After the stack is deployed, you will have a Lambda function named InboundNumberMapLambda. This Lambda function queries the AmazonConnectInboundNumberMap DynamoDB based on the dialed number and returns the session attributes for that particular number. The Lambda function returns session attributes that Amazon Connect can act upon, such as contact flow ARN, emergency message enabled flag, line of business, queue, and greeting. Using DynamoDB to store attributes makes it easy to add additional parameters to the configuration for each number dialed. This enables you to manage the user experience of your Amazon Connect instance contact flows.
Enable your Amazon Connect instance to access this newly created Lambda function by following these steps.
- In the AWS Management Console, open the Amazon Connect service console and choose the Amazon Connect instance you are using.
- Choose Contact flows from the menu and scroll to the bottom of the page to the AWS Lambda section.
- On the Function drop-down menu, select the InboundNumberMapLambda function
- Choose +Add Lambda Function.
- Open the Amazon Connect management console.
- Open the EntryPointFlow contact flow.
- Open the Invoke AWS Lambda function contact flow block.
- Select the InboundNumberMapLambda function from the drop-down.
- Choose Save and exit the object.
- Choose Publish to publish the EntryPointFlow contact flow.
Testing the configuration
Now that the setup is complete, dial each of the numbers to test the configuration. Notice that each number plays a different message. Confirm that the marketing number plays a message stating that it is closed due to an emergency.
Add all the queues you created to your test agent’s routing profile, log in the agent, and test calling into different numbers to see the call route to the queue specified in DynamoDB table. The different queue names are whispered to the agent as the call arrives.
If you would like to change the settings in the contact flows, edit the DynamoDB parameters. For example, change the call recording value to “N” in one of the number configuration items to stop calls from being recorded.
Session attributes returned to the contact flow from a Lambda function invocation are returned as external attributes. External attributes can be referenced in the contact flow until the next Lambda execution. If you want the attributes to persist throughout the contact flow, save the attributes as user defined attributes with the Save contact attributes block. This will enable you to continue to reference the attributes after another Lambda function is called.
For troubleshooting the contact flow experience, look at the Amazon CloudWatch Logs for the Amazon Connect instance to view the contact flow logs for each of the calls.
To avoid incurring future charges, disconnect the contact flow from the phone numbers that you used and release the claimed phone numbers. The remaining resources can be removed by deleting the CloudFormation stack, including the Lambda function, DynamoDB table, and IAM resources used in this sample.
In this blog, you learned how to use AWS Lambda, DynamoDB, and contact flow attributes to manage phone numbers and caller treatment based on the number that was called in Amazon Connect. This infrastructure helps simplify management of your phone numbers and contact flows while creating a consistent customer experience across your lines of business.
A suggested future enhancement beyond what is shown in this blog is addition of a web front end to the DynamoDB table to enable your line-of-business managers to control messaging and settings directly. This puts the control of the customer experience in the hands of the line-of-business users without granting them access to your Amazon Connect instance or AWS Management Console.