@zhaokun/cti 1.3.4 → 1.4.5

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