-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
494 lines (466 loc) · 17.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>通话组件测试</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./css/callcenter-component.css">
<style type="text/css">
table {
border: 1px;
border-collapse: collapse;
border-spacing: 0;
}
table th {
border: 1px solid #ddd;
padding: 5px;
text-align: center;
}
table tbody td {
border: 1px solid #ddd;
text-align: center;
}
</style>
</head>
<body>
<table>
<caption>
历史弹屏
</caption>
<thead>
<tr>
<th>客户号码</th>
<th>通话类型</th>
<th>客服姓名</th>
<th>客服ID</th>
<th>来源队列</th>
<th>通话记录ID</th>
<th>归属地</th>
<th>振铃时间</th>
<th>Call ID</th>
<th>IVR变量</th>
<th>是否挂断</th>
</tr>
</thead>
<tbody id="screen-pop-history">
</tbody>
</table>
<p>
<button onclick="destroyCallComponent();">销毁通话组件</button>
<button onclick="createCallComponent();">创建通话组件</button>
</p>
<h3>修改客服状态</h3>
<div>
<button onclick="setWorkStatus('idle');">空闲</button>
<button onclick="setWorkStatus('busy');">忙碌</button>
<button onclick="setWorkStatus('resting');">小休</button>
<button onclick="setWorkStatus('offline');">离线</button>
</div>
<h3>修改客服在线方式</h3>
<div>
<button onclick="setWorkingWay('fixed_voip_online');">IP话机</button>
<button onclick="setWorkingWay('phone_online');">手机</button>
<button onclick="setWorkingWay('voip_online');">网页电话</button>
</div>
<h3>修改中继号</h3>
<div>
<p>获取中继号时,务必保持initdata接口初始化成功,未成功时只有一个id为null的默认项</p>
<input id="call_number_id" placeholder="中继号ID"/>
<button onclick="getCallNumbers();">获取中继号</button>
<button onclick="setupDefaultNumber();">修改中继号</button>
</div>
<h3>保持/取回 通话</h3>
<div>
<button onclick="holdCallSelect();">保持通话</button>
<button onclick="recoveryCallSelect();">取回通话</button>
</div>
<h3>测试外呼接口</h3>
<div>
<input placeholder="请输入号码" id="phone-number-input"/>
<input placeholder="请输入业务id" id="biz_id"/>
<button
onclick="makeCall(document.getElementById('phone-number-input').value, document.getElementById('biz_id').value);">
拨打
</button>
</div>
<h3>接听与挂断</h3>
<div>
<button onclick="callComp.answer();">接听</button>
<button onclick="callComp.hangup();">挂断</button>
</div>
<h3>高级通话</h3>
<input id="agent_id" placeholder="客服ID"/>
<div>
<button onclick="transfer();">转接</button>
<button onclick="startConsult();">咨询</button>
<button onclick="stopConsult();">结束咨询</button>
<button onclick="startThreeWayCalling();">三方</button>
<button onclick="transferAfterConsult();">咨询后转接</button>
<button onclick="threeWayCallingAfterConsult();">咨询后三方</button>
<button onclick="transferAfterThreeWayCalling();">三方后转接</button>
</div>
<h3>转接IVR</h3>
<input id="node_id" placeholder="节点id"/>
<select id="type">
<option value="agent_hold">转接后等待</option>
<option value="agent_hangup">转接后挂机</option>
</select>
<div>
<button onclick="startIvrCalling();">转接ivr</button>
</div>
<h3>测试自动外呼任务客户号码组存储</h3>
<div>
<button onclick="getAutomaticCallNumGroup();">测试</button>
</div>
<h3>监控-修改客服状态</h3>
<input id="monitor_workStatus_id" placeholder="客服ID"/>
<div>
<button onclick="setMonitorWorkStatus('idle');">空闲</button>
<button onclick="setMonitorWorkStatus('busy');">忙碌</button>
<button onclick="setMonitorWorkStatus('offline');">离线</button>
</div>
<div>
<p>如果在小休的的输入框中,输入了自定义小休的id那么切换到自定义小休的状态</p>
<input id="resting_id" placeholder="小休ID"/>
<button onclick="setMonitorWorkStatus('resting');">小休</button>
</div>
<h3>监控-切换客服在线方式</h3>
<input id="monitor_workingWay_id" placeholder="客服ID"/>
<div>
<button onclick="setMonitorAgentWorkWay('fixed_voip_online');">IP话机</button>
<button onclick="setMonitorAgentWorkWay('phone_online');">手机</button>
<button onclick="setMonitorAgentWorkWay('voip_online');">网页电话</button>
</div>
<h3>监控-高级通话</h3>
<input id="monitor_agent_id" placeholder="客服ID"/>
<div>
<button onclick="monitorAgentListening();">监听</button>
<button onclick="monitorAgentInterpose();">强插</button>
<button onclick="monitorAgentSubstitute();">拦截</button>
</div>
<script src="./js/callcenter-component.js"></script>
<script src="./js/call-api.js"></script>
<script>
var token = 'xxxxx';
var subDomain = 'xxxxxx';
var onTokenExpired = function(callback) {
setTimeout(function() {
callback('xxxx');
}, 1000);
};
window.callAPI.tokenInit(
token,
subDomain,
onTokenExpired
);
var tbody = document.getElementById('screen-pop-history');
function createCallComponent() {
if (window.callComp && !window.callComp.isDestroyed) {
return;
}
window.callComp = new UdeskCallcenterComponent({
container: document.body,
token: token, // 客服token
subDomain: subDomain, // 您在udesk注册的二级域名,例如您的udesk域名是sample.udesk.cn,则此处填写sample
showManualScreenPop: true,
movable: true,
onScreenPop: function(conversation) {
var tr = document.createElement('tr');
tr.innerHTML =
'<td><a href="javascript:;" onclick="makeCall(\'' + conversation.customer_phone_number + '\')">' +
conversation.customer_phone_number + '</a></td>' + //客户电话
'<td>' + conversation.call_type + '</td>' + //呼入、呼出
'<td>' + conversation.agent_name + '</td>' + //客服姓名
'<td>' + conversation.agent_id + '</td>' + //客服ID
'<td>' + (conversation.queue_name || '') + '</td>' + //队列,仅呼入有值,呼出值为null
'<td>' + conversation.conversation_id + '</td>' + //conversation_id
'<td>' + conversation.customer_phone_location + '</td>' + //客户手机号归属地
'<td>' + conversation.ring_time + '</td>' + //振铃时间
'<td>' + conversation.call_id + '</td>' + //call_id
'<td>' + conversation.ivr_variables + '</td>' + //ivr_variables
'<td id="' + conversation.conversation_id + '"></td>';
if (tbody.hasChildNodes()) {
tbody.insertBefore(tr, tbody.childNodes[0]);
} else {
tbody.append(tr);
}
},
onHangup: function(conversation) {
document.getElementById(conversation.conversation_id).innerText = '已挂断';
console.log('hangup', conversation);
},
onWorkStatusChange: function(status) {
console.log('客服当前状态:' + status);
},
onWorkWayChange: function(way) {
console.log('客服当前在线方式:' + way);
},
onDropCall: function(res) {
console.log('挂断结果:' + res.error_message);
},
onTransferResult: function(res) {
console.log('转接结果', JSON.stringify(res));
},
onConsultResult: function(res) {
console.log('咨询结果', JSON.stringify(res));
},
onThreeWayCallingResult: function(res) {
console.log('三方结果', JSON.stringify(res));
},
onTokenExpired: onTokenExpired,
onIvrCallResult: function(res) {
console.log('ivr转回结果', JSON.stringify(res));
},
onResumeAgentResult: function(res) {
console.log('ivr转回结果', JSON.stringify(res));
},
onTalking: function(conversation) {
console.log('talking', conversation);
},
onRinging: function(conversation) {
console.log('ringing', conversation);
},
onSoftPhoneRegistered: function() {
console.log('软电话已注册');
},
onSoftPhoneUnregistered: function() {
console.log('软电话已注销');
}
// onInitSuccess: function() {
// console.log('初始化成功');
// },
// onInitFailure: function() {
// console.log('初始化失败');
// }
});
}
function makeCall(phone_number, biz_id) {
callComp.makeCall(phone_number, {biz_id: biz_id}, function() {
console.log('外呼成功');
}, function() {
console.log('外呼失败');
});
}
function destroyCallComponent() {
window.callComp.destroy();
window.callComp = null;
}
function setWorkStatus(status) {
if (window.callComp) {
window.callComp.setWorkStatus(status, function() {
console.log('修改状态成功');
}, function() {
console.log('修改状态失败');
});
}
}
function holdCallSelect() {
var targetId = document.getElementById('agent_id').value;
if (window.callComp) {
window.callComp.holdCallSelect(function() {
console.log('正在保持通话...');
}, function(res) {
alert(JSON.stringify(res));
});
} else {
alert('请先创建通话组件');
}
}
function recoveryCallSelect() {
var targetId = document.getElementById('agent_id').value;
if (window.callComp) {
window.callComp.recoveryCallSelect(function() {
console.log('正在取回通话...');
}, function(res) {
alert(JSON.stringify(res));
});
} else {
alert('请先创建通话组件');
}
}
function transfer() {
var targetId = document.getElementById('agent_id').value;
if (window.callComp) {
window.callComp.transfer(targetId, function() {
console.log('正在尝试转接...');
}, function(res) {
alert(JSON.stringify(res));
});
} else {
alert('请先创建通话组件');
}
}
function startConsult() {
var targetId = document.getElementById('agent_id').value;
if (window.callComp) {
window.callComp.startConsult(targetId, function() {
console.log('正在尝试咨询...');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function stopConsult() {
if (window.callComp) {
window.callComp.stopConsult(function() {
console.log('正在结束咨询...');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function startThreeWayCalling() {
var targetId = document.getElementById('agent_id').value;
if (window.callComp) {
window.callComp.startThreeWayCalling(targetId, function() {
console.log('正在尝试发起三方通话...');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function startIvrCalling() {
var targetId = document.getElementById('node_id').value;
var type = document.getElementById('type').value;
var node = {
transfer_mode: type,
id: targetId
};
if (window.callComp) {
window.callComp.startIvrCalling(node, function() {
console.log('正在尝试转接ivr...');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function setWorkingWay(workingWay) {
if (callComp) {
callComp.setWorkingWay(workingWay, function() {
console.log('正在尝试修改客服在线方式');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function setupDefaultNumber() {
var callNumberId = document.getElementById('call_number_id').value;
if (callComp) {
callComp.setupDefaultNumber(callNumberId, function(res) {
console.log('正在尝试修改中继号');
alert(JSON.stringify(res));
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function getAutomaticCallNumGroup() {
if (callComp) {
var cc_ad_task = callComp.getAutomaticCallNumGroup();
if (cc_ad_task) {
alert(JSON.stringify(cc_ad_task));
} else {
alert('还没有储存自动外呼任务的客户号码组');
}
}
}
function getCallNumbers() {
if (callComp) {
var call_numbers = callComp.getCallNumbers();
alert(JSON.stringify(call_numbers));
}
}
function setMonitorWorkStatus(agent_work_state) {
if (callComp && callAPI) {
var resting_id = document.getElementById('resting_id').value;
var anget_id = document.getElementById('monitor_workStatus_id').value;
if (agent_work_state === 'resting' && resting_id.length !== 0) {
callAPI.setMonitorWorkRestingStatus(anget_id, resting_id, function() {
console.log('正在尝试修改其他客服状态');
}, function(res) {
alert(JSON.stringify(res));
});
} else {
callAPI.setMonitorWorkStatus(anget_id, agent_work_state, function() {
console.log('正在尝试修改其他客服状态');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
}
function setMonitorAgentWorkWay(agent_work_way) {
if (callComp && callAPI) {
var anget_id = document.getElementById('monitor_workingWay_id').value;
callAPI.setMonitorAgentWorkWay(anget_id, agent_work_way, function() {
console.log('正在尝试修改其他客服设备状态');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function monitorAgentListening() {
if (callComp && callAPI) {
var agent_id = document.getElementById('monitor_agent_id').value;
callAPI.monitorAgentListening(agent_id, function() {
console.log('正在尝试监听');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function monitorAgentInterpose() {
if (callComp && callAPI) {
var agent_id = document.getElementById('monitor_agent_id').value;
callAPI.monitorAgentInterpose(agent_id, function() {
console.log('正在尝试强插');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function monitorAgentSubstitute() {
if (callComp && callAPI) {
var agent_id = document.getElementById('monitor_agent_id').value;
callAPI.monitorAgentSubstitute(agent_id, function() {
console.log('正在尝试拦截');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function transferAfterConsult() {
if (callComp) {
var agent_id = document.getElementById('agent_id').value;
callComp.transferAfterConsult(agent_id, function() {
console.log('正在转接');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function threeWayCallingAfterConsult() {
if (callComp) {
var agent_id = document.getElementById('agent_id').value;
callComp.threeWayCallingAfterConsult(agent_id, function() {
console.log('正在转接');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
function transferAfterThreeWayCalling() {
if (callComp) {
var agent_id = document.getElementById('agent_id').value;
callComp.transferAfterThreeWayCalling(agent_id, function() {
console.log('正在转接');
}, function(res) {
alert(JSON.stringify(res));
});
}
}
</script>
</body>
</html>