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.


Step 1: 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 2: 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});
//agent data is only available for paid plans

Step 3: 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();
const agentMonitor = new callstatsAgentMonitor();     
  agentMonitor.initialize(connect, ccpUrl, appId, appSecret, localUserId);
var callstats = window.CallstatsAmazonShim.initialize(connect, appId, appSecret,
localUserId, configParams, csInitCallback, csStatsCallback);

Step 4: Optional APIs

/* To make pre-call test */ 
//precall tests are only available for paid plans

//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 */
//agent feedback data is only available for paid plans

//Feedback has the following structure

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

/* To send application error logs */
//app error logs are only available for paid plans

//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.


Do you need help getting started?

Our team are ready to help you get started, fill in this form, and one of our experts will be in touch soon.