Integrating Amazon Connect with

Amazon Connect is a self-service, cloud-based contact center solution that makes it easy for any business to deliver better customer service at lower cost. Amazon Connect is based on the same contact center technology used by Amazon customer service associates around the world to power millions of customer conversations.

Integration Steps monitors and analyzes the performance of Amazon Connect real-time communications, enabling you to rapidly troubleshoot issues and deliver high-quality services to your customers.

Note: The and Amazon Connect integration is not currently available on the master branch of connect streams, as Amazon Connect does not currently expose PeerConnection. In order to integrate with Amazon Connect, you have to pull the branch with PeerConnection exposed. will make sure the branch is up-to-date with the master branch.

Step 1: Pull the Git Branch that Exposes rtc-session

Pull the branch and compile it as instructed in the Connect repository.  

Step 2: Include callstats.js and callstats-amazon-shim.js

Add the callstats.js and callstats-amazon-shim.js to the HEAD tag. Please refer to our API page for more information on the dependencies.

<script src="connect-rtc.js"></script>
<script src="amazon-connect.js"></script>

// Add the callstats.js and callstats-amazon-shim.js

<script src=""></script>
<script src=""></script>

You can find the AppID on the page, and AppSecret under the security tab for that App.

Step 3: Initialize Connect Contact Panel (CCP)

The parameters that must be configured before initializing CCP are explained in detail here. Please read this carefully before proceeding further.

//replace with the CCP URL for your Amazon Connect instance

 var ccpUrl = "ccpUrl";
   connect.core.initCCP(containerDiv, {        
ccpUrl: ccpUrl,
loginPopup: true,
softphone: {
allowFramedSoftphone: false

 connect.core.initSoftphoneManager({allowFramedSoftphone: true});

Step 4: Initialize callstats.js

var localUserId;      
var appId = "appID";
var appSecret = "appSecret";

function csInitCallback (err, msg){

 console.log("CallStats Initializing Status: err="+err+" msg="+msg);
   function subscribeToAgentEvents(agent) {      
localUserId = agent.getName();

var callstats = window.CallstatsAmazonShim.initialize(connect, appId, appSecret, localUserId, configParams, csInitCallback, csStatsCallback);


Step 5: Optional APIs

/* To make pre-call test */ 


//Callback Function

function preCallTestResultsCallback(status, results) {

//Check the status

if (status == callstats.callStatsAPIReturnStatus.success) {


var connectivity = results.mediaConnectivity;
var rtt = results.rtt;
var loss = results.fractionalLoss;
var throughput = results.throughput;


else {
console.log("Pre-call test could not be run");


/* To send agent feedback */


//Feedback has the following structure

 var feedback = {
 "userID": localUserId, 
 "overall": overallRating, 
 "comment": agentComment,

/* To send application error logs */


//log can be a string or object (name and message)

var log = {
 message: "[modules/xmpp/ChatRoom.js] chat how are you",
 error: "Error 1",
 stack: "slkdfsdhhsdlghshglshglhslghslfhglsfhlghsflhg",
 name: "error"


  • AppID: AppID is a String obtained from the dashboard.

  • AppSecret: AppSecret is a String obtained from the dashboard.

  • localUserId: localUserId is a String with a maximum length of 256 bytes that MUST NOT be null or empty. It is provided by the developer or fetched from the agent.getName() call of the Connect SDK.

  • configParams: configParams is OPTIONAL. It is the set of parameters used to enable ordisable certain features in the library. See the API section for “JSON for configParams”.

  • csInitCallback: csInitCallback is OPTIONAL. It provides a callback function that asynchronously reports failure or success. See the Callback and Error Handling section of the API page.

  • csStatsCallback: csStatsCallback is OPTIONAL. It provides a callback  that asynchronously reports conference statistics. See the Callback and Error Handling section of the API page.