Search code examples
amazon-connect

How to programmatically end a contact on Amazon Connect CCP


I am hosting an Amazon Connect CCP iframe in a webpage. How can I programmatically intercept an outbound call in the browser and terminate the contact if certain conditions on the webpage are not met?

We have tried hooking into various events documented in https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md to no avail.

thanks

.


Solution

  • You need to terminate the agent’s connection.

    First, grab the agent’s active contact:

    https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#agentgetcontacts

    Then, find the agent’s connection on that contact:

    https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#contactgetagentconnection

    Last, end the connection:

    https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#connectiondestroy

    Note that this will end the contact but not necessarily the call. If that’s a multi party call (multi contact call) and other agents are participating, the call will proceed with the other agents.