Using API's to query our Amazon Connect instance, I need to be able to tell in real time what number a given agent is answering. Very well could be I'm not understanding the vocabulary of Connect to figure this out, but I can't seem to find a path to this data in the API docs.
Basically, given an agentId, what contact is the agent talking to and what phone number did the contact dial in?
I've seen references to Dialed number in Contact Attributes
https://docs.aws.amazon.com/connect/latest/adminguide/connect-attrib-list.html
but not how to get this info via API. Do I need to use data streams via Kinesis to get this information?
You can achieve this without using Kinesis, but it involves several steps.
First, assuming you're starting with a username, you would need to use the ListUsers API to map usernames to user IDs.
Next, with the user ID in hand, you can find out which contact they are currently communicating with. This can be accomplished using the GetCurrentUserData API, filtering the results by the user ID. Once you have the results, refer to the Contacts array (which contains information about the active contacts) to determine which ContactID they're engaged with.
Finally, utilize the GetContactAttributes API to check what phone number is associated with the contact. Please note that the phone number is considered a system attribute, and it may not be returned by GetContactAttributes by default. If this is the case, you can store it in contact attributes right at the beginning of the contact flow.
This approach is suitable for scenarios with a relatively small number of users, where you might run this kind of query ad-hoc. If you anticipate more frequent invocations, it's important to be aware of the API rate limit. For situations involving high-frequency queries, it's advisable to consider subscribing to EventBridge to retrieve the data, as Kinesis, while useful, primarily provides post-call data.