@zhaokun/cti 1.3.3 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +371 -0
- package/index.d.ts +36 -0
- package/latest/denoiser.wasm +0 -0
- package/latest/index.html +24 -6
- package/latest/zhaokun.cti.min.js +6 -6
- package/package.json +8 -6
- package/latest/docs.pdf +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# 呼叫中心 ZHAOKUN-CTI-SDK
|
|
2
|
+
|
|
3
|
+
### 安装
|
|
4
|
+
|
|
5
|
+
#### Script 标签引入
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
<script src="./zhaokun.cti.min.js"></script>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
#### NPM 安装
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm i @zhaokun/cti
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 使用
|
|
18
|
+
|
|
19
|
+
#### 初始化(签入)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
var content = null
|
|
23
|
+
function init() {
|
|
24
|
+
// 实例化成功后会自动签入 调用
|
|
25
|
+
content = new zhaokunCTI({
|
|
26
|
+
webrtc: true, // 必填 是否是webrtc
|
|
27
|
+
token: "", // 必填 接口获取的token
|
|
28
|
+
agent: "", // 必填 坐席工号
|
|
29
|
+
account: "", // 必填 分机号
|
|
30
|
+
socket: "", // 必填 socket连接地址
|
|
31
|
+
env: "", // debug 打印日志
|
|
32
|
+
aiDenoise: false, // ai 降噪开关
|
|
33
|
+
aiDenoisePath: "https://www.example.com/denoiser.wasm", // 可访问的文件地址,文件在https://www.npmjs.com/package/@zhaokun/cti?activeTab=code latest文件夹里面的denoiser.wasm
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
content.onmessage(function (obj) {
|
|
37
|
+
console.log("收到数据", obj)
|
|
38
|
+
// 具体返回类型参考下方【onmessage 事件响应格式】
|
|
39
|
+
const type = obj.type // 消息类型
|
|
40
|
+
const data = obj.data // 消息数据
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// socket 连接成功
|
|
44
|
+
content.onopen(function () {
|
|
45
|
+
console.log("onopen")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// 获取在线时间
|
|
49
|
+
content.onlinetime(function (time) {
|
|
50
|
+
console.log("onlinetime", time)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// 实时权限检测
|
|
54
|
+
content.onpermission(function (permission) {
|
|
55
|
+
// console.log("onpermission", permission)
|
|
56
|
+
{
|
|
57
|
+
"microphone": true // 麦克风是否开启 true false
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// socket 连接错误
|
|
62
|
+
content.onerror(function (e) {
|
|
63
|
+
console.log("onerror", e)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// socket 连接断开
|
|
67
|
+
content.onclose(function () {
|
|
68
|
+
console.log("onclose")
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// 错误事件
|
|
72
|
+
content.error(function (e) {
|
|
73
|
+
console.log("error", e)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// 初始化(自动签入)
|
|
77
|
+
content.agent.start()
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
init()
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
[onmessage 事件响应格式](#onmessage-事件响应格式)
|
|
85
|
+
|
|
86
|
+
#### 签出
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
content.agent.logout()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### 呼叫
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
content.agent.call({
|
|
96
|
+
customer: "", // 手机号或分机号
|
|
97
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
98
|
+
custom: "", // 业务编号(长度限制32位字母数字组成)
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 挂机
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
content.agent.hangup()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### 呼入接听
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
content.agent.answer()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### 保持
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
content.agent.hold()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### 取消保持
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
content.agent.unhold()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### 开启手机接听
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
content.agent.mobileAnswer({
|
|
130
|
+
status: 1,
|
|
131
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### 取消手机接听
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
content.agent.mobileAnswer({
|
|
139
|
+
status: 0,
|
|
140
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### 转接
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
content.agent.transfer({
|
|
148
|
+
customer: "", // 手机号或分机号
|
|
149
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### 转到队列(技能组)
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
content.agent.transferQueue("")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### 询问开始
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
content.agent.threeWayStart({
|
|
163
|
+
customer: "", // 手机号或分机号
|
|
164
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### 询问取消
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
content.agent.consultCancel()
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### 询问确定
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
content.agent.consultTransfer()
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### DTMF
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
content.agent.keyup("1") // 按键值(0-9*#)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### 三方开始
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
content.agent.threeWayStart({
|
|
190
|
+
customer: "", // 手机号或分机号
|
|
191
|
+
relayNumber: "", // 主叫号码(中继号码)
|
|
192
|
+
})
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 取消三方
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
content.agent.threeWayCancel()
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### 评价
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
content.agent.grade()
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### 主叫号码(中继号)列表
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
content.agent.relayList()
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### 队列(技能组)列表
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
content.agent.queueList()
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### 获取系统信息
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
content.tool.getSystemInfo()
|
|
223
|
+
// 返回格式
|
|
224
|
+
{
|
|
225
|
+
"type": "SystemInfo",
|
|
226
|
+
"code": 200,
|
|
227
|
+
"data": {
|
|
228
|
+
"browser": {
|
|
229
|
+
"name": "Chrome", // 浏览器名称
|
|
230
|
+
"version": "133.0" // 版本
|
|
231
|
+
},
|
|
232
|
+
"support": {
|
|
233
|
+
"webrtc": true, // true false 浏览器是否支持webrtc
|
|
234
|
+
"websocket": true // true false 浏览器是否支持websocket
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### 检测麦克风
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
content.tool.checkMicrophoneStatus()
|
|
244
|
+
// 返回数据
|
|
245
|
+
{
|
|
246
|
+
"type": "CheckMicrophoneStatus",
|
|
247
|
+
"code": 200, // 200 成功 其他失败
|
|
248
|
+
"message": "麦克风已开启"
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### 获取默认媒体设备
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
content.tool.getDefaultMedia()
|
|
256
|
+
{
|
|
257
|
+
"type": "DefaultMedia",
|
|
258
|
+
"code": 200,
|
|
259
|
+
"data": {
|
|
260
|
+
// 默认麦克风设备
|
|
261
|
+
"input": {
|
|
262
|
+
"deviceId": "default",
|
|
263
|
+
"kind": "audioinput",
|
|
264
|
+
"label": "默认 - 外置麦克风 (Built-in)", // 设备名称
|
|
265
|
+
"groupId": "775636b3e17f56abe21a8c2ed7f4dbfca3dbb2882ce75034541d45226e43c335"
|
|
266
|
+
},
|
|
267
|
+
// 默认扬声器
|
|
268
|
+
"output": {
|
|
269
|
+
"deviceId": "default",
|
|
270
|
+
"kind": "audiooutput",
|
|
271
|
+
"label": "默认 - 外置耳机 (Built-in)",// 设备名称
|
|
272
|
+
"groupId": "775636b3e17f56abe21a8c2ed7f4dbfca3dbb2882ce75034541d45226e43c335"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
####
|
|
279
|
+
|
|
280
|
+
### onmessage-事件响应格式
|
|
281
|
+
|
|
282
|
+
#### 中继号码消息(响应)
|
|
283
|
+
|
|
284
|
+
| 参数名称 | 类型 | 描述 |
|
|
285
|
+
| ------------- | ------ | --------- |
|
|
286
|
+
| type | string | RelayList |
|
|
287
|
+
| data | object | |
|
|
288
|
+
| └ relay400 | string | 400号码 |
|
|
289
|
+
| └ relayName | string | 中继名称 |
|
|
290
|
+
| └ relayNumber | string | 中继号码 |
|
|
291
|
+
|
|
292
|
+
#### 队列列表消息(响应)
|
|
293
|
+
|
|
294
|
+
| 参数名称 | 类型 | 描述 |
|
|
295
|
+
| -------- | ------ | --------- |
|
|
296
|
+
| type | string | QueueList |
|
|
297
|
+
| data | object | |
|
|
298
|
+
| └ id | string | 队列ID |
|
|
299
|
+
| └ title | string | 队列名称 |
|
|
300
|
+
|
|
301
|
+
#### 号码属地消息(响应)
|
|
302
|
+
|
|
303
|
+
| 参数名称 | 类型 | 描述 |
|
|
304
|
+
| ---------- | ------ | ------------ |
|
|
305
|
+
| type | string | RegionInfo |
|
|
306
|
+
| data | object | |
|
|
307
|
+
| └ channel | string | 运营商 |
|
|
308
|
+
| └ zone | string | 区号 |
|
|
309
|
+
| └ code | string | 行政区域代码 |
|
|
310
|
+
| └ province | string | 省 |
|
|
311
|
+
| └ city | string | 市 |
|
|
312
|
+
|
|
313
|
+
#### 账号签出(响应)
|
|
314
|
+
|
|
315
|
+
| 参数名称 | 类型 | 描述 |
|
|
316
|
+
| -------- | ------ | ------ |
|
|
317
|
+
| type | string | Logout |
|
|
318
|
+
| data | object | |
|
|
319
|
+
|
|
320
|
+
#### 坐席状态消息(响应)
|
|
321
|
+
|
|
322
|
+
| 参数名称 | 类型 | 描述 |
|
|
323
|
+
| --------- | ------- | ------------------------------------------- |
|
|
324
|
+
| type | string | Status |
|
|
325
|
+
| data | object | |
|
|
326
|
+
| └ uid | integer | 账号ID |
|
|
327
|
+
| └ account | string | 话机账号 |
|
|
328
|
+
| └ status | integer | 状态(1空闲2忙碌3小休4振铃5通话6保持7后处理) |
|
|
329
|
+
| └ time | integer | 状态时间(10位时间戳) |
|
|
330
|
+
|
|
331
|
+
#### 电话振铃(响应)
|
|
332
|
+
|
|
333
|
+
| 参数名称 | 类型 | 描述 |
|
|
334
|
+
| -------------- | ------- | -------------------- |
|
|
335
|
+
| type | string | Ring |
|
|
336
|
+
| data | object | |
|
|
337
|
+
| └ id | string | 电话UUID |
|
|
338
|
+
| └ uid | integer | 账号ID |
|
|
339
|
+
| └ type | integer | 电话类型(1呼出0呼入) |
|
|
340
|
+
| └ customer | string | 客户号码 |
|
|
341
|
+
| └ relay400 | string | relay400 |
|
|
342
|
+
| └ transferType | string | 转接类型 |
|
|
343
|
+
| └ transferFrom | string | 转接来源 |
|
|
344
|
+
| └ custom | string | 业务编号 |
|
|
345
|
+
|
|
346
|
+
#### 三方/询问(响应)
|
|
347
|
+
|
|
348
|
+
| 参数名称 | 类型 | 描述 |
|
|
349
|
+
| -------- | ------ | ------------------------------------------------- |
|
|
350
|
+
| type | string | TransferResult |
|
|
351
|
+
| data | object | |
|
|
352
|
+
| └ type | string | 类型(threeway三方consult询问) |
|
|
353
|
+
| └ result | string | 结果(start开始 cancel取消 transfer转接answer应答) |
|
|
354
|
+
|
|
355
|
+
#### 状态恢复(响应)
|
|
356
|
+
|
|
357
|
+
| 参数名称 | 类型 | 描述 |
|
|
358
|
+
| ---------- | ------- | -------------------- |
|
|
359
|
+
| type | string | Resume |
|
|
360
|
+
| data | object | |
|
|
361
|
+
| └ id | string | 电话UUID |
|
|
362
|
+
| └ uid | integer | 账号ID |
|
|
363
|
+
| └ type | integer | 电话类型(1呼出0呼入) |
|
|
364
|
+
| └ customer | string | 客户号码 |
|
|
365
|
+
|
|
366
|
+
#### 通用错误消息(响应)
|
|
367
|
+
|
|
368
|
+
| 参数名称 | 类型 | 描述 |
|
|
369
|
+
| -------- | ------ | -------- |
|
|
370
|
+
| type | string | Error |
|
|
371
|
+
| data | string | 错误消息 |
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface CTIConfig {
|
|
2
|
+
webrtc: boolean;
|
|
3
|
+
token: string;
|
|
4
|
+
agent: string;
|
|
5
|
+
account: string;
|
|
6
|
+
socket: string;
|
|
7
|
+
env?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CTIMessage {
|
|
11
|
+
type: string;
|
|
12
|
+
data: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Agent {
|
|
16
|
+
start(): void;
|
|
17
|
+
call(params: { phone: string; relayNumber?: string }): void;
|
|
18
|
+
answer(): void;
|
|
19
|
+
hangup(): void;
|
|
20
|
+
hold(): void;
|
|
21
|
+
unhold(): void;
|
|
22
|
+
transfer(params: { phone: string }): void;
|
|
23
|
+
mobileAnswer(params: { status: number; relayNumber?: string }): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default class zhaokunCTI {
|
|
27
|
+
constructor(config: CTIConfig);
|
|
28
|
+
agent: Agent;
|
|
29
|
+
onmessage(callback: (message: CTIMessage) => void): void;
|
|
30
|
+
onopen(callback: (event: any) => void): void;
|
|
31
|
+
onerror(callback: (error: any) => void): void;
|
|
32
|
+
onclose(callback: (event: any) => void): void;
|
|
33
|
+
onlinetime(callback: (time: string) => void): void;
|
|
34
|
+
onpermission(callback: (permission: any) => void): void;
|
|
35
|
+
error(callback: (error: any) => void): void;
|
|
36
|
+
}
|
|
Binary file
|
package/latest/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
@@ -134,6 +134,11 @@
|
|
|
134
134
|
<div class="item">
|
|
135
135
|
<button id="customHandle">自定义发送</button>
|
|
136
136
|
</div>
|
|
137
|
+
|
|
138
|
+
<div class="item">
|
|
139
|
+
<button id="aiDenoiseOpen">ai降噪开启</button>
|
|
140
|
+
<button id="aiDenoiseClose">ai降噪关闭</button>
|
|
141
|
+
</div>
|
|
137
142
|
</div>
|
|
138
143
|
|
|
139
144
|
<div style="color: #f56c6c">
|
|
@@ -157,11 +162,13 @@
|
|
|
157
162
|
// 实例化成功后会自动签入 调用
|
|
158
163
|
content = new zhaokunCTI({
|
|
159
164
|
webrtc: true, // 必填 是否是webrtc
|
|
160
|
-
token: "
|
|
161
|
-
agent: "
|
|
162
|
-
account: "
|
|
163
|
-
socket: "
|
|
164
|
-
|
|
165
|
+
token: "", // 必填 接口获取的token
|
|
166
|
+
agent: "", // 必填 坐席工号
|
|
167
|
+
account: "", // 必填 分机号
|
|
168
|
+
socket: "", // 必填 socket连接地址
|
|
169
|
+
aiDenoise: false, // ai 降噪开关
|
|
170
|
+
aiDenoisePath: "", // ai 降噪的文件
|
|
171
|
+
env: "", // debug 打印日志
|
|
165
172
|
})
|
|
166
173
|
|
|
167
174
|
// content.onmessage(function (obj) {
|
|
@@ -196,6 +203,10 @@
|
|
|
196
203
|
// console.log("onlinetime", time)
|
|
197
204
|
$("#onlinetime").html(time)
|
|
198
205
|
})
|
|
206
|
+
content.onaidenoise(function (status) {
|
|
207
|
+
// 设置成功以后会在下次通话生效
|
|
208
|
+
console.log("降噪状态:", status) // true / false
|
|
209
|
+
})
|
|
199
210
|
// content.onlinetime(function (time) {
|
|
200
211
|
// console.log("onlinetime2", time)
|
|
201
212
|
// })
|
|
@@ -270,6 +281,13 @@
|
|
|
270
281
|
})
|
|
271
282
|
}
|
|
272
283
|
|
|
284
|
+
$("#aiDenoiseOpen").click(() => {
|
|
285
|
+
content.tool.setAiDenoise(true)
|
|
286
|
+
})
|
|
287
|
+
$("#aiDenoiseClose").click(() => {
|
|
288
|
+
content.tool.setAiDenoise(false)
|
|
289
|
+
})
|
|
290
|
+
|
|
273
291
|
$("#hold").click(() => {
|
|
274
292
|
// 保持
|
|
275
293
|
content.agent.hold()
|