tencent cloud

Feedback

Last updated: 2024-04-01 18:09:01

    Step 1: Initialize the SDK

    Please refer to Initializing SDK.
    Note
    The following steps should be performed after the 'tccc.events.ready' event is successful.

    Step 2: Implement Clicking Button to Trigger SDK Outbound Call

    Vue
    React
    Native JS
    <template>
    <button @click="sdkCall">One-click outbound call</button>
    </template>
    <script>
    export default {
    data() {
    phoneNumber: '19999999999' // Replace it with a real outbound number
    },
    methods: {
    sdkCall() {
    window.tccc.Call.startOutboundCall({
    phoneNumber: this.phoneNumber,
    }).then((res) => {
    this.sessionId = res.data.sessionId;
    }).catch((err) => {
    const error = err.errorMsg;
    })
    }
    }
    }
    </script>
    import { useState } from 'react';
    export function CallButton() {
    const [phoneNumber, setPhoneNumber] = useState('19999999999') // Replace it with a real outbound number
    
    function sdkCall(phoneNumber) {
    window.tccc.Call.startOutboundCall({
    phoneNumber,
    }).then((res) => {
    this.sessionId = res.data.sessionId;
    }).catch((err) => {
    const error = err.errorMsg;
    })
    }
    
    return (
    <button onClick={sdkCall}>One-click outbound call</button>
    )
    }
    <button id="call">One-click outbound call</button>
    <script>
    function sdkCall(phoneNumber) {
    window.tccc.Call.startOutboundCall({
    phoneNumber, // Outbound number
    phoneDesc: 'Tencent' // Remarks, which will replace the display of the number on the call bar
    }).then((res) => {
    // Outbound call succeeded. Obtain the outbound ID, which can be used to query related call recordings and service records
    const sessionId = res.data.sessionId
    }).catch((err) => {
    // Outbound call failed. Obtain the failure reason for prompt
    console.error(err.errMsg)
    })
    }
    // Listen to the click event of the button and trigger the outbound call method
    document.getElementById('call').addEventListsner('click', () => {
    // Replace it with a real outbound number
    sdkCall('19999999999');
    })
    </script>
    After the outbound call is successfully triggered, wait for the other party to answer and trigger related events in turn.

    Outbound Call Event Process

    
    
    
    
    
    
    
    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