Principles
Cloud Contact Center provides a JavaScript SDK for developers. Developers can import the SDK into the page using a script, which completes the initialization of the SDK. The integration interaction is as follows:
Notes
1. Could Contact Center's agent-side Web SDK primarily supports Google Chrome 56 and later and Microsoft Edge 80 and later. It is recommended to install the latest version of the browser to support more features.
2. Please use the HTTPS protocol to deploy the front-end page (localhost can be used during development), otherwise, normal calls will not be possible due to browser restrictions.
Integration Prerequisites
Key Concepts
SdkAppId: The application ID users create on the Cloud Contact Center console. You can create up to 20 Cloud Contact Center applications under one Tencent Cloud account, often starting with 140. UserID: The account configured by the agent or administrator in the Cloud Contact Center, usually in the format of an email address. After the application is created for the first time, the main account can go to Internal Message (sub-account requires a subscription to Cloud Contact Center product messages) to view the contact center administrator account and password. Under one SDKAppID, multiple UserIDs can be configured. If the configuration limit is exceeded, more agents need to be purchased in Agent Purchase. SecretId and SecretKey: A certificate needed by developers to call cloud APIs, created on the Tencent Cloud console. SDKURL: The JS URL needed to initialize the Web SDK, created via cloud APIs. The URL is valid for 10 minutes. Please ensure it is used only once and created when SDK needs to be initialized. No need to re-create it after successful SDK initialization.
SessionId: The unique ID for a user from the beginning to the end of a call. Developers can associate different recordings, service records, and event pushes via SessionId.
Step 1: Obtain Required Parameters
1. Obtain the SecretId
and SecretKey
of Tencent Cloud account. For details, refer to Access Key. Step 2: Obtain the SDK URL
Note: This step requires backend development by the accessing party.
1. Integrate tencentcloud-sdk
3. Return the obtained SdkURL to the frontend of the accessing party.
In the following, we will use the interface name /loginTCCC
to explain the interface developed in this step. The following code is an example in Node.js. For sample code in other languages, see CreateSDKLoginToken.
const tencentcloud = require('tencentcloud-sdk-nodejs');
const express = require('express');
const app = express();
const CccClient = tencentcloud.ccc.v20200210.Client;
app.use('/loginTCCC', (req, res) => {
const clientConfig = {
credential: {
secretId: 'SecretId',
secretKey: 'SecretKey'
},
region: '',
profile: {
httpProfile: {
endpoint: 'ccc.tencentcloudapi.com'
}
}
};
const client = new CccClient(clientConfig);
const params = {
SdkAppId: 1400000000,
SeatUserId: 'xxx@qq.com'
};
client.CreateSDKLoginToken(params).then(
(data) => {
res.send({
SdkURL: data.SdkURL
})
},
(err) => {
console.error('error', err);
res.status(500);
}
);
})
Step 3: Request to Obtain SDK URL and Complete Initialization from the Web Frontend
Note: This step requires frontend development by the accessing party.
1. Request the /loginTCCC
interface implemented in step 2 and obtain the SdkURL.
2. Insert the SdkURL into the page using the script method.
3. After the tccc.events.ready event has been successfully listened to, execute the business logic.
function injectTcccWebSDK(SdkURL) {
if (window.tccc) {
console.warn('The SDK has been initialized. Please confirm whether the initialization is being executed repeatedly');
return;
}
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.setAttribute('crossorigin', 'anonymous');
script.src = SdkURL;
document.body.appendChild(script);
script.addEventListener('load', () => {
window.tccc.on(window.tccc.events.ready, () => {
resolve('Initialization succeeded')
});
window.tccc.on(window.tccc.events.tokenExpired, ({message}) => {
console.error('Initialization failed', message)
reject(message)
})
})
})
}
fetch('/loginTCCC')
.then(res => res.json())
.then((res) => {
const SdkURL = res.SdkURL;
return injectTcccWebSdk(SdkURL);
})
.catch((error) => {
console.error(error);
})
Was this page helpful?