Resolve QueueARN by Queue Name Dynamically for Amazon Connect
Frequently when architecting and constructing a call experience for Amazon Connect, there are complexities to maintaining a unified experience while arriving at a specific Queue to ensure prompt service for the caller's need. These situations often arise based on Country, Region, Dialed Number, Call Type, Intent, and Service.
Create the function.
You create a Node.js Lambda function using the Lambda console. Lambda automatically creates the default code for the function.
To create a Lambda function with the console
- Open the Functions page of the Lambda console.
- Choose to Create function.
- Select the Author from Scratch option (Default).
- Under Basic information, do the following:
- For the Function name, enter GetQueueARNByName.
- For Runtime, confirm that Node.js 16.x is selected.
- Choose to Create function.
Paste the Lambda code below and select Deploy.
Grant Lambda Permissions
- Select the Configuration tab.
- Select the Role Name link.
- Within the new IAM service tab select Add Permissions dropdown, then select Create inline policy.
- Click Service and type Connect in the search box.
- Click Action and type listQueues in the search box and select listQueues.
- Click Resources and determine the resource to be allowed, updating the: Region, AccountId, and Connect Instance ARN.
- Select Review policy.
- Enter a name for the policy then select Create policy.
Testing the Lambda
Invoke your Lambda function using the sample event data provided in the console.
To invoke a function
- After selecting your function, choose the Test button.
- In the Test event section, choose New event. Enter a Name for this test and paste the following sample event template:
3. Choose Save changes, and then choose Test. The function handler receives and then processes the sample event. Upon successful completion, view the results in the console:
Add the Lambda function to your Amazon Connect instance
Before you can use a Lambda function in a flow, you need to add it to your Amazon Connect instance.
Add a Lambda function to your instance
- Open the Amazon Connect console at: https://console.aws.amazon.com/connect/.
- On the instances page, choose your instance name in the Instance Alias column.
- In the navigation pane on the left, choose Contact Flows.
- In the AWS Lambda section, use the Function drop-down box to select the GetQueueARNByName function to add to your instance.
- Choose Add Lambda Function.
Invoke a Lambda function from a flow
- Open or create a flow.
- Add an Invoke AWS Lambda function block (in the Integrate group) to the grid. Connect the branches to and from the block.
- Choose the title of the Invoke AWS Lambda function block to open its properties page.
- Under Select a function, choose the GetQueueARNByName function you've added to your instance.
- Under Function input parameters, choose to Add a parameter. Specify key-value pairs as queueName and connectARN. queueName may be dynamically referenced based on user-defined session attributes as detailed below.
- In Timeout (max 8 seconds), specify how long to wait for Lambda to time out. After this time, the contact routes down the Error branch.
Note: The queueName will have the spaces removed in the Lambda function, the queue names should be named appropriately within the Connect instance to ensure accuracy in resolving by queue name.
The solution provided is a simple and effective way to dynamically resolve queues based on some simple conventions that can handle a fair bit of complexity in requirements. It does have some limitations. It scans all the queues for every match. It can’t handle a resolution that might depend on something else, like a CRM lookup (gold, silver, bronze) or hours of operation. That said, it's easy to imagine ways in which the concept can be extended further. By adding a table driven approach to the lookup it would be possible to avoid hitting the Connect API every time, and would be easy to incorporate additional fields that might be dependent on more complex scenarios. Taking such an approach would also allow for some simple management functions to allow call center managers to make changes without having to modify contact flows.
For help configuring dynamic Queues for your business or organization, contact us today!