Updated on 2023-10-12 GMT+08:00

Answering a Call

Application Scenario

After receiving the inbound call event reported by the OpenEye, the agent automatically invokes the call answering interface to answer the call.

Prerequisites

  • An agent has signed in to the CTI platform.
  • The onCallIncoming message is received.

Process Description

Invoke the acceptCall interface of OpenEyeCall to answer a call.
/**
* Inbound call event
 **/
function onCallIncoming(data) { 
    //Record the inbound call ID. This parameter will be used in the subsequent call answering interface.
    var tupCurrentCallId = data.param.call_id;

    //The following describes how to invoke the interface for answering a call. In actual development, invoke the  interface as required.
    acceptCall(tupCurrentCallId); 
} 
/** 
* Answer a call
 */ 
function acceptCall(tupCurrentCallId) { 
   if (tupCurrentCallStatus == OPENEYE_CALL_STATUS.ALERTING) {
        this.global_openEye_SDK.openEyeCall.acceptCall(tupCurrentCallId, tupCurrentCallType, { response: onAcceptCallReponse });
    } else {
        console.error("Phone status is invalid. Now it's " + tupCurrentCallStatus);
        alert("Phone status is invalid. Now it's " + tupCurrentCallStatus);
    }
} 
/** 
* Response of the answering interface
 */
function onAcceptCallReponse(data) { 
    if (data.result == 0) {
        console.error("AcceptCall success. ");
    } else {
        console.error("AcceptCall failed. The ErrorCode is " + data.result);
        console.info(data);
        alert("AcceptCall failed.  The ErrorCode is " + data.result);
    }
}