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',
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,
agent: 'xxx@xxx',
password: 'xxx',
mode: '4',
type: 'ready',
}
}
telephoneFunction(obj);
}
登录的回调事件说明:
{
"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
}
}
2.2 登出
标识(key):logout
传入参数(data):
序号 |
名称 |
类型 |
是否必填 |
说明 |
1 |
id |
String |
是 |
对接ID |
示例代码:
function logout() {
let obj = {
key: 'logout',
data: {
id: phoneId,
}
}
telephoneFunction(obj);
}
登出的回调事件说明:
{
"key": "CTIResponse",
"name": "通话信令",
"data": {
"agentnum": "1007",
"tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
"type": "response",
"command": "agentLogout",
"retmsg": "succed!",
"retcode": 200
}
}
2.3 切换座席状态
应用场景:登录后
标识(key):changeAgentStatus
传入参数(data):
序号 |
名称 |
类型 |
是否必填 |
说明 |
1 |
id |
String |
是 |
对接ID |
2 |
type |
String |
是 |
类型(传’ready’为切换至空闲,’busy’切换至忙碌) |
示例代码:
function changeAgentStatus () {
let obj = {
key: 'changeAgentStatus',
data: {
id: phoneId,
type: 'ready',
}
}
telephoneFunction(obj);
}
切换座席状态的回调事件说明:
{
"key": "CTIResponse",
"name": "通话信令",
"data": {
"agentnum": "1007",
"tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
"type": "response",
"command": "agentSetState",
"retmsg": "succeed!",
"retcode": 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,
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",
"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": "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,
}
}
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,
}
}
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,
type: 'agent',
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,
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 |
示例代码:
function ivr() {
let obj = {
key: 'ivr',
data: {
id: phoneId,
ivrId: 'b27e72cd0115d448fb918f69a6fxxxxx',
}
}
telephoneFunction(obj);
}
转IVR流程的回调事件说明:
{
"key": "CTIResponse",
"name": "通话信令",
"data": {
"agentnum": "1007",
"tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
"type": "response",
"command": "agentToIVR",
"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,
ivrId: '16916e1e36b1fbfc93fcffc8208xxxxx',
node_id: 'b9771aba-xxxx-xxxx-xxxx-f3418daxxxxx',
}
}
telephoneFunction(obj);
}
满意度转接的回调事件说明:
{
"key": "CTIResponse",
"name": "通话信令",
"data": {
"agentnum": "1007",
"tenantid": "acf528a2-xxxx-xxxx-xxxx-74cb3995cfab",
"type": "response",
"command": "agentToIVR",
"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,
selectTags: { tags: [["834d3c228b740a0bf8f5e467cadxxxxx"], ["2b076e0665d749aa74dd27dd407xxxxx"]] },
}
}
telephoneFunction(obj);
}
无回调事件
2.12 提交随路数据
应用场景:通话中
标识(key):associate
传入参数(data):
序号 |
名称 |
类型 |
是否必填 |
说明 |
1 |
id |
String |
是 |
对接ID |
2 |
remark |
String |
是 |
随路信息 |
示例代码:
function associate() {
let obj = {
key: 'associate',
data: {
id: phoneId,
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,
}
}
telephoneFunction(obj);
}
2.14 设置电话条无边距样式
说明:默认有边距。
标识(key):barStyleNoPadding
传入参数(data):
序号 |
名称 |
类型 |
是否必填 |
说明 |
1 |
id |
String |
是 |
对接ID |
示例代码:
function barStyleNoPadding() {
let obj = {
key: 'barStyleNoPadding',
data: {
id: phoneId,
}
}
telephoneFunction(obj);
}
2.15 保持呼叫
应用场景:通话中
标识(key):holdOn
传入参数(data):
序号 |
名称 |
类型 |
是否必填 |
说明 |
1 |
id |
String |
是 |
对接ID |
示例代码:
function holdOn() {
let obj = {
key: 'holdOn',
data: {
id: phoneId,
}
}
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,
}
}
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,
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