GetContactMetrics API
AWS Connect API that returns real time metrics per contact including POSITION_IN_QUEUE and ESTIMATED_WAIT_TIME using the caller’s ContactId
POSITION_IN_QUEUE
Metric returned by GetContactMetrics giving the caller’s actual position in queue at that moment
ESTIMATED_WAIT_TIME
Metric returned by GetContactMetrics giving predicted wait time in seconds based on handle time history
Why not use ContactsInQueue for position
ContactsInQueue returns total queue size not the individual caller’s position. Every caller would hear the same number
MessageParticipantIteratively
Connect block that plays a message on a loop and fires MessagesInterrupted on a set interval to trigger recalculation logic
MessagesInterrupted
Condition on MessageParticipantIteratively that fires when the interrupt frequency timer hits. Used to trigger the recalculation path in a queue loop
Why the recalculation path must reinvoke Lambda
Connect does not re-evaluate contact attributes automatically. If you don’t call the Lambda again on each loop the caller hears stale values every time
EndFlowExecution in a customer queue flow
Ends the current flow module and returns control to the queue. Used at the end of the recalculation path to loop back to the hold music and announcement
GetMetricData block
Connect block that pulls real time queue metrics like queue size and oldest contact age. Runs before the Lambda in the recalculation path to refresh queue-level attributes
Why remove input parameters from Lambda invocation
The new GetContactMetrics Lambda pulls ContactId and InstanceARN directly from ContactData. Passing old parameters like ContactsInQueue is unnecessary and can cause confusion or errors
boto3-latest Lambda layer
Required when using newer boto3 API calls like get_contact_metrics. The bundled Lambda runtime boto3 version does not include newer APIs
InstanceARN vs InstanceId in Connect Lambda
Connect passes the full InstanceARN in ContactData. You must split on forward slash to extract the InstanceId before passing to boto3 API calls
Flat string map Lambda response
Connect requires Lambda to return a flat key-value dict with string values. Nested objects are not accessible via $.External in the flow
$.External in Connect flow
Namespace for accessing Lambda return values in Set Attributes or Compare blocks after an Invoke Lambda block
ContactData in Lambda event
Contains ContactId
Why SSML does not resolve contact attributes
Connect does not interpolate $.Attributes values inside SSML tags. Use plain Text message type to dynamically read contact attributes like customerPosition and waitTime
AccountName check in queue loop
Used to route different accounts down different recalculation paths. Accounts not matching any condition fall through to the default path
IAM inline policy for Lambda
Scope connect:GetContactMetrics to the specific instance ARN. Do not use wildcard resource for Connect IAM permissions
Execution role vs inline policy
Execution role is the Lambda’s identity. Inline policy is attached directly to that role granting specific permissions like calling Connect APIs
Environment-specific Lambda naming
Each environment gets its own Lambda with env suffix (dev
How to safely test a prod flow in sandbox
Export the prod flow JSON and do a string replace on all ARNs swapping instance IDs