Amazon Connect chat handoff
Hand off a live webchat or SMS conversation from your PolyAI agent to an Amazon Connect chat agent. PolyAI calls the Connect StartChatContact API and then proxies messages between the end user and the Connect agent for the rest of the session.
Prerequisites
- An Amazon Connect instance with chat enabled.
- A chat contact flow in Connect that routes the conversation to the queue you want PolyAI to escalate into.
- An IAM role PolyAI can assume that grants
connect:StartChatContactand the matching session policies. The role’s trust policy must allowsts:AssumeRoleandsts:TagSessionfrom the PolyAI worker account (PolyAI uses IRSA, which adds session tags on the assume-role call).
1. Configure Amazon Connect
- In the AWS console, open Amazon Connect and note the Instance ID for the instance you want PolyAI to hand off into.
- Open or create the chat contact flow that should receive PolyAI’s handoff and note the Contact flow ID. Make sure the flow routes to a queue that has live agents assigned.
- Create or reuse an IAM role for PolyAI (for example
PolyAIAccessConnect) and note the Role ARN.
2. Connect from Studio
In Agent Studio, open Integrations and click Connect on the Amazon Connect tile. Paste:
If your worker defaults to us-east-1 but your Connect instance lives in eu-west-2, set aws_region explicitly. Without it the handoff fails with ResourceNotFoundException.
3. Write the handoff function
The handoff payload can include the Connect configuration inline. This is useful for testing or when different topics hand off to different Connect instances:
You can also pass an optional user_display_name to set the name the live agent sees for the user.
4. Assign the function to a topic
Open the Knowledge topic that should escalate, add an Action, and select transfer_to_connect. The same function can be called from any flow step or directly via conv.call_handoff() for dynamic routing.
5. Verify
- Start a session in your webchat widget and steer the conversation into the topic you wired the handoff to.
- Confirm a new chat contact appears in the Amazon Connect agent workspace (Contact Control Panel) for the queue the contact flow routes to.
- Reply from Connect and confirm the message is delivered back to the user inside the same widget.
- End the contact from Connect and confirm the widget shows the conversation as closed.
If you see ResourceNotFoundException, the region is almost certainly wrong – set aws_region on the integration. If you see assume-role errors, confirm the trust policy allows both sts:AssumeRole and sts:TagSession from the PolyAI worker account.

