<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 numberfunction 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 numberphoneDesc: '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 recordsconst sessionId = res.data.sessionId}).catch((err) => {// Outbound call failed. Obtain the failure reason for promptconsole.error(err.errMsg)})}// Listen to the click event of the button and trigger the outbound call methoddocument.getElementById('call').addEventListsner('click', () => {// Replace it with a real outbound numbersdkCall('19999999999');})</script>
Was this page helpful?