
# 接听呼叫
#### 应用场景
座席侧收到OpenEye上报的呼入事件后，自动调用接听呼叫接口，实现来话的接听。
#### 前提条件
- 座席已经签入CTI平台。
- 收到[onCallIncoming](https://support.huaweicloud.com/devg-openeye-cec/cec_05_1534.html)。
 
#### 流程说明
调用OpenEyeCall的[acceptCall](https://support.huaweicloud.com/devg-openeye-cec/cec_05_1532.html)接口进行接听呼叫。
```
/**
 * 来电事件
 **/
function onCallIncoming(data) { 
    //记录一下来电的callid，后续接听接口需要用到该参数
    var tupCurrentCallId = data.param.call_id;
    //此处调用仅是演示如何调用接听呼叫接口，实际开发中请根据需要在合适地方调用该接口
    acceptCall(tupCurrentCallId); 
} 
/** 
 * 接听呼叫 
 */ 
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);
    }
} 
/** 
 * 接听接口的响应 
 */
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);
    }
}
```
