Amazon Web Services

Another Short Experiment with the Connect API

In my prior post, A Short Experiment with the Amazon Connect User API, I created an Express web application to explore using the Amazon Connect User API. Since then, Amazon has released new API methods for updating contact attributes and viewing queue metrics. In this post, I update the Express app to demo these new methods.

Let’s start with the end product again. In addition to the existing a list of Connect users and a Connect user detail view, the app now has a form you can use to flag a prior call for follow-up and an auto-updating page to see the current metrics for your queues.

These new screens are shown below.

** The application code is available on GitHub at: ***


Close your eyes to the styling, and let’s talk through what’s going on with each screen.


Update Contact Attributes

This page uses the updateContactAttributes method to add a new contact attribute to a Connect call. In this case a flag to indicate the call needs follow-up.

The updateContactAttributes method hangs off the connectClient object from the AWS SDK and I pass in the contact id, instance id and the new attribute(s).

You can see a before and after of the call’s Contact Trace Record below with the contact id and then the new attribute highlighted.

Amazon Web Services - Avoid Contact Center Outages: Plan Your Upgrade to Amazon Connect
Avoid Contact Center Outages: Plan Your Upgrade to Amazon Connect

Learn the six most common pitfalls when upgrading your contact center, and how Amazon Connect can help you avoid them.

Get the Guide

Using this API was straightforward, although it would be easier to write useful applications if there was a Connect API to retrieve current and past contacts, rather than having to find the contact id from the Admin Site or getting the contact id from an active call in a Streams API app.


Current Queue Metrics

This page gets all the current queue metrics for every queue in the Connect instance. It automatically reloads every two seconds to get the latest metrics (code for which is in the currentMetrics.pug and currentMetrics.js files on GitHub)

I got tripped up a bit by the syntax of this command. It is described reasonably well in the documentation, but I didn’t understand at first that I needed to specify every metric I wanted (metricsList variable) as well as the ARNs of every queue (qArns variable). It was a bit frustrating to dig through the Admin Site to get the queue ARN from the URL.


Once I got past those issues, the API behaved as I expected with one exception. Queues with no activity at all, i.e. no agents signed in and no calls, are not returned at all in the results. Rather than every metric being zero for the queue, it just is not there in the response.

My simple example doesn’t give you all that much, but I could see other uses like creating a small dashboard that lights up when certain thresholds are passed like too many calls in queue or not enough agents signed in.



When I’m running this application from my machine, it’s using my AWS CLI credentials, which have access to everything. If you were running this code in a Lambda under an IAM role with lesser privileges, you’d have to manually assign permissions to the Connect API. For example, “connect:UpdateContactAttributes” targeting the Connect instance id in a custom policy.


Trying it out yourself

Please check out the code on GitHub at:




Thanks for reading. Any questions, comments or corrections are greatly appreciated.

To learn more about what we can do with Amazon Connect, check out Helping You Get the Most Out of Amazon Connect

About the Author

Peter Miller is a Solutions Architect at Perficient focused on call center solutions including Amazon Connect

More from this Author

Thoughts on “Another Short Experiment with the Connect API”

  1. I have been disappointed by the API. Things that should be really simple like “What is the current availability status of each of my agents?” or “What is the URL of the call recording for a given contact” do not appear to be in there? Am I missing something?

  2. Peter Miller Post author

    I would keep an eye out in the forums and from Amazon in general to see what new features are coming out.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up