tencent cloud

Feedback

Last updated: 2024-04-01 18:02:33

    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

    1. You have created a Cloud Contact Center application.
    2. You have purchased and added an agent account.

    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.
    2. Obtain the sdkAppId of the Cloud Contact Center application, and log in to the Cloud Contact Center console to view:
    
    
    

    Step 2: Obtain the SDK URL

    Note: This step requires backend development by the accessing party.
    1. Integrate tencentcloud-sdk
    2. Call the CreateSDKLoginToken interface.
    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.
    // Version of tencentcloud-sdk-nodejs required to be 4.0.3 or later
    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 = {
    // Address to obtain secretId and secretKey: https://console.tencentcloud.com/cam/capi
    credential: {
    secretId: 'SecretId',
    secretKey: 'SecretKey'
    },
    region: '',
    profile: {
    httpProfile: {
    endpoint: 'ccc.tencentcloudapi.com'
    }
    }
    };
    const client = new CccClient(clientConfig);
    const params = {
    SdkAppId: 1400000000, // Replace it with your own SdkAppId
    SeatUserId: 'xxx@qq.com' // Replace it with the agent account
    };
    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');
    // The DomId needs to be rendered into it. If it is filled in, there is no floating window, and the workspace is directly rendered into the specified dom element (XML)
    // To ensure the integrity of the workspace UI, the rendered Dom should have a minimum height of 480px and a minimum width of 760px
    // script.dataset.renderDomId = "renderDom";
    script.src = SdkURL;
    document.body.appendChild(script);
    script.addEventListener('load', () => {
    // JS SDK file loaded successfully. At this point, you can use the global variable "tccc"
    window.tccc.on(window.tccc.events.ready, () => {
    /**
    * TCCC SDK initialization succeeded. At this point, you can call out, listen to inbound events, and use other features.
    * Note ⚠️: Please ensure that the SDK is only initialized once
    * */
    resolve('Initialization succeeded')
    });
    window.tccc.on(window.tccc.events.tokenExpired, ({message}) => {
    console.error('Initialization failed', message)
    reject(message)
    })
    })
    })
    }
    
    // Request the interface implemented in step 2 /loginTCCC
    // Note ⚠️: The following is just a code example, it is not recommended to run directly
    fetch('/loginTCCC')
    .then(res => res.json())
    .then((res) => {
    const SdkURL = res.SdkURL; // Ensure that the SdkURL is returned by the request, otherwise, unpredictable errors may occur!
    return injectTcccWebSdk(SdkURL);
    })
    .catch((error) => {
    // Initialization failed
    console.error(error);
    })
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support