What is a “dynamic” configuration?
Amazon Connect contact flow editor allows you to configure IVR settings easily through a graphical interface. Dynamic configuration comes in handy for more complex use cases. That way, it’s possible to manage the setup through a central place, usually a database.
A good example of that is international contact flows. Let’s say you want exactly the same customer experience in five or more different languages. You can leverage a single Amazon Connect contact flow for that and load the configuration dynamically based on language preference.
What can you configure dynamically in Amazon Connect?
Currently, you can configure the following resources dynamically in a contact flow:
- Text-to-speech prompt
- Pre-recorded audio prompt
- Menu options
- Queue
- Contact flow transfer
- Hold flow
- Whisper flow
- Contact attribute
- Outbound caller ID
Sample step-by-step configuration
In this example, we load dynamically all text-to-speech prompts, audio prompts and queues. We will use a single Amazon Connect contact flow to handle calls in English, German and French, based on the dialed in-country number.
No menus here! We will make the routing decision based on the dialed number.
- UK number –> route to prompts in English and English-speaking agents
- Germany number ->route to prompts in German and German-speaking agents
- France number -> route to prompts in French and French-speaking agents
Step 1
Create new queues in Amazon Connect and add them to the appropriate routing profiles.
Step 2
Prepare a list of text-to-speech prompts and audio prompt ARNs. We will use this to populate the database in Step #3.
Tip: you can find Audio PromptARN by navigating to Amazon Connect Prompts and clicking on the prompt in question.
This is a unique prompt identifier that will be referenced within the contact flow.
Step 3
From AWS, navigate to DynamoDB service and create a new Database. In this example, we use the local contact center number as the primary key.
Here is a sample DynamoDb database structure:
Step 4
Create a new NodeJs Lambda function based on the sample below.
- Configure Environment variables for your environment – region and DynamoDb Database name.
- Sample Lambda function:
const AWS =require('aws-sdk'); const region = process.env["region"]; const dbTableName = process.env["tableName"]; let dynamoDb = new AWS.DynamoDB.DocumentClient({region: region}); exports.handler = (event, context, callback) => { console.log('Lambda function start'); console.log(JSON.stringify(event)); let dialedNumber = event.Details.ContactData.SystemEndpoint.Address; const params ={ TableName:dbTableName, Key:{ "dialedNumber": dialedNumber }, FilterExpression: "dialedNumber = :number", ExpressionAttributeValues: { ":number": dialedNumber } }; console.log('Scanning dynamodb database...'); var result = {}; dynamoDb.scan(params, function(err,data){ if(err){ console.log(err); console.log('err'); callback(err); } else{ console.log(data); result = { "prompt0": data.Items[0].prompt0, "promptHold" : data.Items[0].promptHold, "queue" : data.Items[0].queue }; callback(null, result); } }); };
- Sample test event:
{ "Details": { "ContactData": { "SystemEndpoint": { "Address": "+1234567899" //this number has to live in the DynamoDb database in E164 format } } } }
- Lambda function execution role
Make sure the Lambda execution role has appropriate access to the DynamoDb table resource. Here’s a sample IAM policy that could be attached to the IAM Lambda execution role:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "dynamodb:Scan", "Resource": "arn:aws:dynamodb:us-east-1:123456789999:table/dh-dynamic-call-flow" } ] }
Step 5
Add Lambda function invoke permissions for Amazon Connect. Check out the following blog post if you’re not sure how to do that: https://blogs.perficient.com/2018/11/30/invoking-lambda-functions-with-amazon-connect/
Step 6
Reference all resources in an Amazon Connect contact flow.
Part 1:
Part 2:
Reference a text-to-speech prompt:
Reference an Audio prompt:
Great article btw. I’m trying to get a play prompt to simply say “Please hold. Your are 10th” in the queue (or whatever their position is). From some research it looks like it needs DynamoDB, Lambda functionality and more – which seems way too complicated for a simple requirement. Do you have any advice?