1.使用示例

  • 在引用js接入代码和添加好id为telephoneBar的标签前提下。
  • 在相关的事件中,拼接好调用函数的相应数据,再调用telephoneFunction函数即可。

示例:

<body>
  <div id="telephoneBar" data-width="800px" data-height="110px">
  </div>
  <button onclick="callout()">外呼</button>
  <script>
    function transfer() {
      let obj = {
        key: 'callOut',//操作标识
        data: {
          id: 'a0c6745bbde435aca2af60eabb1xxxxx', //对接ID,接入代码中的phoneId
          telephone: '131xxxxxxxx', //被叫号码
        }
      }
      telephoneFunction(obj);//调用对外函数
    }
  </script>
</body>

2.接口说明

2.1 登录

标识(key):login

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 接入代码中的phoneId(以下统称:对接ID)
2 agent String 账户,格式为:{座席号码}@{租户名称}
3 password String 密码
4 mode String 登录方式(1 手机登录 ,2 话机接听,4 插件登录,6咨询业务经理 7 SIM卡话机接听,8 SIP软电话接听)
5 type String 登录类型(’ready’为空闲,’busy’为忙碌)
示例代码:
//登录
function login() {
  let obj = {
    key: 'login', // 操作标识
    data: {
      id: phoneId, // 对接ID
      agent: 'xxx@xxx', // 登录账号,如'8004@1030test'
      password: 'xxx', // 密码
      mode: '4', // 登录方式,1:手机登录 ,2:话机接听,4:插件登录,以api文档为准
      type: 'ready', // 座席状态,ready:空闲,busy:忙碌,以api文档为准
    }
  }
  telephoneFunction(obj); // 调用对外函数
}
登录的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007", // 座席工号
        "agentstate": "ready", // 座席状态为空闲
        "calltimes": "",
        "phoneType": 4,
        "callstate": 0,
        "callscene": 0,
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab", // 租户id
        "type": "response",
        "retmsg": "succeed!",
        "command": "agentLogin", // 登录事件,command可区分不同事件
        "retcode": 200 // 200代表登录成功,非200登录失败
    }
}

2.2 登出

标识(key):logout

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//登出
function logout() {
  let obj = {
    key: 'logout',
    data: {
      id: phoneId, // 对接ID
    }
  }
  telephoneFunction(obj);
}
登出的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentLogout", // 登出事件
        "retmsg": "succed!",
        "retcode": 200 // 200代表登出成功,非200登出失败
    }
}

2.3 切换座席状态

应用场景:登录后

标识(key):changeAgentStatus

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 type String 类型(传’ready’为切换至空闲,’busy’切换至忙碌)
示例代码:
//切换座席状态
function changeAgentStatus () {
  let obj = {
    key: 'changeAgentStatus',
    data: {
      id: phoneId, // 对接ID
      type: 'ready', // ready’为切换至空闲,’busy’切换至忙碌
    }
  }
  telephoneFunction(obj);
}
切换座席状态的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentSetState", // 切换座席状态事件
        "retmsg": "succeed!",
        "retcode": 200 // 200代表切换成功,非200切换失败
    }
}
{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "reason": "agent setup",
        "stateto": "ready", // 当前的座席状态
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "event",
        "command": "agentstatus", // 座席状态结果事件
        "statefrom": "busy" // 上一次的座席状态
    }
}

2.4 外呼

应用场景:登录后

标识(key):callOut

传入参数(data):

非必填参数,调用接口时请传递参数名,参数值可为空

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 telephone String 被叫号码
3 remark Object 扩展字段
示例代码:
//外呼
function callOut(phoneNum) {
  let obj = {
    key: 'callOut',
    data: {
      id: phoneId, // 对接ID
      telephone: phoneNum, // 被叫号码
      remark: {‘a’:’b’,’c’:’d’}, // 扩展字段
    }
  }
  telephoneFunction(obj);
}
外呼的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentDialout", // 外呼事件
        "retmsg": "succed!",
        "retcode": 200
    }
}

{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "c52bf3f5-xxxx-xxxx-xxxx-2ecaaf3a15d3", // 通话id
        "agentnum": "1007",
        "calldirection": "call out", // 呼叫方向,call out 呼出,call in 呼入
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372", // 外呼显示号码
        "sessionid": "2480aabb-xxxx-xxxx-xxxx-43c380efe62f", // 通话session-id
        "dnis": "131xxxxxxxx", // 被叫号码
        "type": "event",
        "ani": "02863208372", // 主叫号码
        "command": "callout_process" // 呼叫中事件
    }
}

{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "c52bf3f5-xxxx-xxxx-xxxx-2ecaaf3a15d3",
        "agentnum": "1007",
        "calldirection": "call out",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372",
        "sessionid": "2480aabb-xxxx-xxxx-xxxx-43c380efe62f",
        "dnis": "131xxxxxxxx",
        "type": "event",
        "ani": "02863208372",
        "command": "call_process" // 被叫响铃事件
    }
}
{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "c52bf3f5-xxxx-xxxx-xxxx-2ecaaf3a15d3",
        "agentnum": "1007",
        "calldirection": "call out",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372",
        "sessionid": "2480aabb-xxxx-xxxx-xxxx-43c380efe62f",
        "dnis": "131xxxxxxxx",
        "type": "event",
        "ani": "02863208372",
        "command": "call_talking" // 被叫接听了,双方通话中事件
    }
}
{
    "key": "MobilesCityApi", //根据号码查询归属地信息,外呼和来电都会有此回调
    "name": "电话归属信息",
    "data": {
        "areaCode": "610100",
        "code": "029",
        "131xxxxxxxx": {
            "code": "029",
            "province": "陕西",
            "city": "西安"
        }
    }
}

2.5 挂断

应用场景:通话中

标识(key):hangup

传入参数(data):

非必填参数,调用接口时请传递参数名,参数值可为空

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//挂断
function hangup() {
  let obj = {
    key: 'hangup',
    data: {
      id: phoneId, // 对接ID
    }
  }
  telephoneFunction(obj);
}
挂断的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentHangup", // 座席挂断事件
        "retmsg": "succed!",
        "retcode": 200
    }
}

{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "c52bf3f5-xxxx-xxxx-xxxx-2ecaaf3a15d3",
        "agentnum": "1007",
        "calldirection": "call out",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372",
        "sessionid": "2480aabb-xxxx-xxxx-xxxx-43c380efe62f",
        "dnis": "02863208372",
        "type": "event",
        "ani": "131xxxxxxxx",
        "command": "call_hangup" // 通话结束事件
    }
}

2.6 接听

应用场景:来电后

标识(key):answer

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID

注:手机及话机登录时,接听事件不生效。

示例代码:
//接听
function answer() {
  if (mode !== '4') {
    alert('此登录方式,无法使用接听')
    return;
  }
  let obj = {
    key: 'answer',
    data: {
      id: phoneId, // 对接ID
    }
  }
  telephoneFunction(obj);
}
接听的回调事件说明:
{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "ad981bdb-xxxx-xxxx-xxxx-39020240db6e",
        "agentnum": "1007",
        "queueid": "d85f1989xxxx-xxxx-xxxx24dbf5a6f2919",
        "calldirection": "call in",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372",
        "sessionid": "1c2cf6d6-xxxx-xxxx-xxxx-351a97506288",
        "dnis": "02863208372",
        "type": "event",
        "ani": "131xxxxxxxx",
        "command": "incoming" // 来电事件
    }
}

{
    "key": "CTIEvent",
    "name": "通话信令",
    "data": {
        "callid": "b87777ca-xxxx-xxxx-xxxx-46e85e2156b6",
        "agentnum": "1007",
        "queueid": "d85f19895xxxx-xxxx-xxxxe24dbf5a6f2919",
        "calldirection": "call in",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "memo": "02863208372",
        "sessionid": "a2f508de-xxxx-xxxx-xxxx-351a97506288",
        "dnis": "02863208372",
        "type": "event",
        "ani": "131xxxxxxxx",
        "command": "call_talking" // 接听后,双方通话中事件
    }
}

2.7 转接

应用场景:通话中

标识(key):transfer

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 type String 转接类型(agent:转接到座席,phone:转接到号码)
3 value String 座席工号/被叫号码,type为agent时传座席工号,type为phone时传被叫号码
示例代码:
//转接
function transfer(num) {
  let obj = {
    key: 'transfer',
    data: {
      id: phoneId, // 对接ID
      type: 'agent', // agent:转接到座席,phone:转接到号码
      value: num, // 座席工号/被叫号码
    }
  }
  telephoneFunction(obj);
}
转接的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentTransfer", // 转接事件
        "retmsg": "succed!",
        "retcode": 200
    }
}

2.8 咨询

应用场景:通话中

标识(key):consult

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
3 value String 座席工号
示例代码:
//咨询
function consult(number) {
  let obj = {
    key: 'consult',
    data: {
      id: phoneId, // 对接ID
      value: number, // 座席工号
    }
  }
  telephoneFunction(obj);
}
咨询的回调事件说明:
{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "command": "agentConsult", //咨询事件
        "retmsg": "succed!",
        "retcode": 200
    }
}

2.9 转IVR流程

应用场景:通话中

标识(key):ivr

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 ivrId String ivr流程id
示例代码:
//转IVR流程
function ivr() {
  let obj = {
    key: 'ivr',
    data: {
      id: phoneId, // 对接ID
      ivrId: 'b27e72cd0115d448fb918f69a6fxxxxx', // ivr流程id
    }
  }
  telephoneFunction(obj);
}
转IVR流程的回调事件说明:
{
  "key": "CTIResponse",
  "name": "通话信令",
  "data": {
    "agentnum": "1007",
    "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
    "type": "response",
    "command": "agentToIVR", // 转IVR流程事件
    "retmsg": "succed!",
    "retcode": 200
  }
}

2.10 满意度转接(满意度转接属于转IVR的一种特殊场景)

应用场景:通话中

标识(key):satisfaction

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 ivrId String ivr流程id
3 node_id String ivr流程节点id(满意度列表获取)
示例代码:
//满意度转接
function satisfaction() {
  let obj = {
    key: 'satisfaction',
    data: {
      id: phoneId, // 对接ID
      ivrId: '16916e1e36b1fbfc93fcffc8208xxxxx', // ivr流程id
      node_id: 'b9771aba-xxxx-xxxx-xxxx-f3418daxxxxx', // ivr流程节点id(满意度列表获取)
    }
  }
  telephoneFunction(obj);
}
满意度转接的回调事件说明:
{
  "key": "CTIResponse",
  "name": "通话信令",
  "data": {
    "agentnum": "1007",
    "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
    "type": "response",
    "command": "agentToIVR", // 转IVR流程事件(满意度转接属于转IVR的一种特殊场景)
    "retmsg": "succed!",
    "retcode": 200
  }
}

2.11 添加通话标签

应用场景:全部

标识(key):tag

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 selectTags Object 标签ID数组(selectTags:{tags: [[“xxxx”], [“xxxx”]]})
示例代码:
//添加通话标签
function tag() {
  let obj = {
    key: 'tag',
    data: {
      id: phoneId, // 对接ID
      selectTags: { tags: [["834d3c228b740a0bf8f5e467cadxxxxx"], ["2b076e0665d749aa74dd27dd407xxxxx"]] }, // 标签ID
    }
  }
  telephoneFunction(obj);
}
无回调事件

2.12 提交随路数据

应用场景:通话中

标识(key):associate

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 remark String 随路信息
示例代码:
//提交随路数据
function associate() {
  let obj = {
    key: 'associate',
    data: {
      id: phoneId, // 对接ID
      remark: '电话条测试质控1112', // 随路信息
    }
  }
  telephoneFunction(obj);
}
提交随路数据的回调事件说明:
{
  "key": "CTIResponse",
  "name": "通话信令",
  "data": {
    "agentnum": "1007",
    "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
    "type": "response",
    "command": "agentSetAssociateData", //提交随路数据事件
    "retmsg": "succed!",
    "retcode": 200
  }
}

2.13 设置电话条无边框样式

说明:默认有边框。

标识(key):barStyleNoBorder

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//设置电话条无边框样式
function barStyleNoBorder() {
  let obj = {
    key: 'barStyleNoBorder',
    data: {
      id: phoneId,//对接ID
    }
  }
  telephoneFunction(obj);
}

2.14 设置电话条无边距样式

说明:默认有边距。

标识(key):barStyleNoPadding

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//设置电话条无边距样式
function barStyleNoPadding() {
  let obj = {
    key: 'barStyleNoPadding',
    data: {
      id: phoneId,//对接ID
    }
  }
  telephoneFunction(obj);
}

2.15 保持呼叫

应用场景:通话中

标识(key):holdOn

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//电话条保持呼叫
function holdOn() {
      let obj = {
        key: 'holdOn',
        data: {
           id: phoneId, // 对接ID
        }
      }
      telephoneFunction(obj);
    }
保持呼叫回调事件说明:
{
    "agentnum": "8014",
    "tenantid": "",
    "type": "response",
    "retmsg": "succed!",
    "command": "agentHold",
    "retcode": 200
}

2.16 取消保持呼叫

应用场景:通话中

标识(key):resume

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
示例代码:
//电话条取消保持呼叫
function resume() {
      let obj = {
        key: 'resume',
        data: {
           id: phoneId, // 对接ID
        }
      }
      telephoneFunction(obj);
    }
取消保持回调事件说明:
{
    "agentnum": "8014",
    "tenantid": "",
    "type": "response",
    "retmsg": "succed!",
    "command": "agentUnhold",
    "retcode": 200
}

2.17 切换登录方式

应用场景:登录后

标识(key):changeMode

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 mode String 接听方式(1 手机登录 ,2 话机接听,4 插件登录)
示例代码:
//切换登录方式
function changeMode() {
      let obj = {
        key: 'changeMode,
        data: {
           id: phoneId, // 对接ID
           mode: '2',  //1 手机登录 ,2 话机接听,4 插件登录
        }
      }
      telephoneFunction(obj);
    }
切换登录方式回调事件说明:
{
    "agentnum": "8014",
    "tenantid": "",
    "type": "response",
    "retmsg": "succed!",
    "command": "setAgentType",
    "status": "online",
    "retcode": 200
}

2.18 隐藏通话控制所有按钮

应用场景:登录后

标识(key):hideCallControlAllBtns

传入参数(data):

序号 名称 类型 是否必填 说明
1 id String 对接ID
2 isHide Boolean true:隐藏所有通话控制按钮,false:显示所有通话控制按钮。
示例代码:
//隐藏通话控制的所有按钮
var isHide = false;
function hideCallControlAllBtns() {
  isHide = !isHide
  let obj = {
    key: 'hideCallControlAllBtns',
    data: {
      id: phoneId,//对接ID,
      isHide: isHide,
    }
  }
  telephoneFunction(obj);
}
无回调事件

3.接口回调事件及数据

几乎所有接口都有回调事件,回调数据都有固定的形式(返回对象中含有key、name、data三对键值,参考如下返回值示例),点击相应按钮(或调用相应的接口)会返回对应的回调数据。开发者可根据回调数据处理自己的业务逻辑,可用以下方式监听到回调事件(console可查看)。

监听代码

// 监听消息事件
window.addEventListener('message', function (e) {
  let json = JSON.parse(e.data);
  console.log('%c%s', 'color: white; background: blue', '---listener message:', json)
});

返回值示例

{
    "key": "CTIResponse",
    "name": "通话信令",
    "data": {
        "agentnum": "1007",
        "agentstate": "ready",
        "calltimes": "",
        "phoneType": 4,
        "callstate": 0,
        "callscene": 0,
        "tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
        "type": "response",
        "retmsg": "succeed!",
        "command": "agentLogin",
        "retcode": 200
    }
}

回调事件中key的释义

序号 名称 说明
1 MobilesCityApi 电话归属信息
2 GetTagDataApi 通话标签信息
3 GetTransferApi 转接和咨询所需列表
4 TransferSuccess 转接成功
5 GetIvrApi IVR流程信息
6 GetlistSatisfactionNodesApi 满意度列表
7 AccountIsLogouted 账号在别处登录
8 CTIEvent 通话信令
9 CTIResponse 通话信令
10 CTIMessage 通话信令
11 PluginConnectState 插件连接状态(仅限插件方式登录)
12 ModeChangeState 切换登录方式状态
13 AssociateClicked 点击随路数据按钮
文档更新时间: 2024-03-25 15:24   作者:admin