@ujet/websdk-headless 4.22.0 → 5.2.1
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/dist/index.d.ts +707 -134
- package/dist/index.js +145 -131
- package/dist/index.mjs +27412 -19871
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,3 @@
|
|
|
1
|
-
interface RequestReturn {
|
|
2
|
-
headers: Record<string, string>;
|
|
3
|
-
data: any;
|
|
4
|
-
}
|
|
5
|
-
interface LogData {
|
|
6
|
-
loglevel: string;
|
|
7
|
-
timestamp: string;
|
|
8
|
-
application: string;
|
|
9
|
-
sdk_version: string;
|
|
10
|
-
device_uuid: string;
|
|
11
|
-
tenant: string;
|
|
12
|
-
company_id: string;
|
|
13
|
-
location_url: string;
|
|
14
|
-
channel: string;
|
|
15
|
-
message: string;
|
|
16
|
-
data: any;
|
|
17
|
-
tracker_id?: string;
|
|
18
|
-
}
|
|
19
|
-
interface LogHistoryData {
|
|
20
|
-
date: string;
|
|
21
|
-
channel: string;
|
|
22
|
-
level: string;
|
|
23
|
-
args: any[];
|
|
24
|
-
}
|
|
25
|
-
interface ClientEvent {
|
|
26
|
-
name: string;
|
|
27
|
-
payload: {
|
|
28
|
-
lang: string;
|
|
29
|
-
menu_id: number;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
interface MessageRequest {
|
|
34
|
-
type: string;
|
|
35
|
-
content?: string;
|
|
36
|
-
[key: string]: unknown;
|
|
37
|
-
}
|
|
38
|
-
interface ChatRequest {
|
|
39
|
-
lang?: string;
|
|
40
|
-
trigger_id?: string;
|
|
41
|
-
ticket_id?: string;
|
|
42
|
-
email?: string;
|
|
43
|
-
greeting?: string;
|
|
44
|
-
cobrowsable?: boolean;
|
|
45
|
-
custom_data?: {
|
|
46
|
-
signed?: string;
|
|
47
|
-
unsigned?: Record<string, any>;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
interface EscalateRequest {
|
|
51
|
-
force_escalate: boolean;
|
|
52
|
-
menu_id: number;
|
|
53
|
-
lang: string;
|
|
54
|
-
}
|
|
55
|
-
interface CobrowseRequest {
|
|
56
|
-
code: string;
|
|
57
|
-
from: string;
|
|
58
|
-
nonce: string;
|
|
59
|
-
}
|
|
60
|
-
interface RateRequest {
|
|
61
|
-
rating: number;
|
|
62
|
-
feedback: string;
|
|
63
|
-
}
|
|
64
|
-
interface SurveyAnswers {
|
|
65
|
-
[id: string]: number | string;
|
|
66
|
-
}
|
|
67
|
-
interface ChatEndUserEventRequest {
|
|
68
|
-
event: {
|
|
69
|
-
name: string;
|
|
70
|
-
payload: Record<string, string>;
|
|
71
|
-
};
|
|
72
|
-
end_user_name?: string;
|
|
73
|
-
}
|
|
74
|
-
interface CallRequest {
|
|
75
|
-
phone_number: string;
|
|
76
|
-
lang?: string;
|
|
77
|
-
scheduled_at?: string;
|
|
78
|
-
ticket_id?: string;
|
|
79
|
-
email?: string;
|
|
80
|
-
recording_permission?: 'recording_permission_not_asked' | 'recording_permission_granted' | 'recording_permission_denied';
|
|
81
|
-
custom_data?: {
|
|
82
|
-
signed?: string;
|
|
83
|
-
unsigned?: Record<string, any>;
|
|
84
|
-
};
|
|
85
|
-
reschedule_call_id?: number;
|
|
86
|
-
use_advanced_call_scheduling?: boolean;
|
|
87
|
-
}
|
|
88
|
-
interface EmailRequest {
|
|
89
|
-
name?: string;
|
|
90
|
-
email: string;
|
|
91
|
-
content: string;
|
|
92
|
-
lang?: string;
|
|
93
|
-
files?: File[];
|
|
94
|
-
recaptcha?: string;
|
|
95
|
-
}
|
|
96
|
-
interface FormData {
|
|
97
|
-
signature: string;
|
|
98
|
-
data: {
|
|
99
|
-
smart_action_id: number;
|
|
100
|
-
id: number;
|
|
101
|
-
uri: string;
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
interface ChatMessageRequest {
|
|
105
|
-
message: {
|
|
106
|
-
content: string;
|
|
107
|
-
timestamp: string;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
interface CheckInVisibilityStateRequest {
|
|
111
|
-
widget_minimized?: boolean;
|
|
112
|
-
tab_inactive?: boolean;
|
|
113
|
-
}
|
|
114
|
-
interface CheckInModalStateRequest {
|
|
115
|
-
modal_type: 'check_in';
|
|
116
|
-
}
|
|
117
|
-
interface GetTimeSlotsRequest {
|
|
118
|
-
lang?: string;
|
|
119
|
-
rescheduleCallId?: number;
|
|
120
|
-
useAdvancedCallScheduling?: boolean;
|
|
121
|
-
}
|
|
122
|
-
interface CustomFormPayload {
|
|
123
|
-
smart_action_id: number;
|
|
124
|
-
form_response: {
|
|
125
|
-
question_id: number;
|
|
126
|
-
value: string | string[] | boolean;
|
|
127
|
-
}[];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
1
|
declare enum PostSessionStatus {
|
|
131
2
|
WAITING = "waiting",
|
|
132
3
|
READY = "ready",
|
|
@@ -141,6 +12,21 @@ declare enum CheckInStatus {
|
|
|
141
12
|
SKIPPED = "skipped",
|
|
142
13
|
TIMED_OUT = "timed_out"
|
|
143
14
|
}
|
|
15
|
+
declare enum ProviderType {
|
|
16
|
+
UJET = "ujet_conversations",
|
|
17
|
+
TWILIO = "twilio_conversations",
|
|
18
|
+
NEXMO = "nexmo_conversations",
|
|
19
|
+
MOCK = "mock"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Stable identifiers for the channel.type values returned in MenuChannel.
|
|
24
|
+
* Use these constants rather than raw string literals so renames are safe.
|
|
25
|
+
*/
|
|
26
|
+
declare enum ChannelType {
|
|
27
|
+
INBOUND_CALL = "inbound_call",
|
|
28
|
+
VOICEMAIL = "voicemail"
|
|
29
|
+
}
|
|
144
30
|
|
|
145
31
|
interface LanguageOption {
|
|
146
32
|
lang: string;
|
|
@@ -166,6 +52,7 @@ interface MenuChannel {
|
|
|
166
52
|
type: string;
|
|
167
53
|
menu_id: number;
|
|
168
54
|
collect_email: boolean;
|
|
55
|
+
recording_option?: RecordingOption;
|
|
169
56
|
deflected?: boolean;
|
|
170
57
|
deflection_type?: string;
|
|
171
58
|
[key: string]: unknown;
|
|
@@ -191,6 +78,7 @@ interface MenuResponse {
|
|
|
191
78
|
direct: {
|
|
192
79
|
key: boolean;
|
|
193
80
|
user: boolean;
|
|
81
|
+
key_id: number | null;
|
|
194
82
|
};
|
|
195
83
|
}
|
|
196
84
|
interface WaitTimeResponse {
|
|
@@ -426,6 +314,202 @@ interface ServerAuthResponse {
|
|
|
426
314
|
interface FeatureFlagsResponse {
|
|
427
315
|
'advanced-call-scheduling': boolean;
|
|
428
316
|
'consumer-agent-pdf'?: boolean;
|
|
317
|
+
'web-sdk-instant-voice'?: boolean;
|
|
318
|
+
}
|
|
319
|
+
type RecordingPermission = 'recording_permission_not_asked' | 'recording_permission_granted' | 'recording_permission_denied';
|
|
320
|
+
type RecordingOption = 'record_never' | 'record_always' | 'record_ask_user';
|
|
321
|
+
type ServerVoiceCallStatus = 'scheduled' | 'queued' | 'assigned' | 'connecting' | 'connected' | 'va_assigned' | 'va_connected' | 'reconnecting' | 'switching' | 'voicemail' | 'finished' | 'failed' | 'recovered' | 'canceled' | 'timeout';
|
|
322
|
+
type VoiceCallStatus = 'idle' | 'queued' | 'connecting' | 'connected' | 'interrupted' | 'ended' | 'error';
|
|
323
|
+
/** The set of smart-action types the server can request. */
|
|
324
|
+
type SmartActionType = 'text' | 'verification' | 'photo' | 'screenshot' | 'video' | 'cobrowse';
|
|
325
|
+
/**
|
|
326
|
+
* Media smart-action subtypes — the three `SmartActionType` values that
|
|
327
|
+
* route through `client.voiceCall.uploadMediaForSmartAction` (versus text /
|
|
328
|
+
* verification / cobrowse). Exported so consumers passing the media type
|
|
329
|
+
* along — for example dialog components that branch on the smart action —
|
|
330
|
+
* can use the union without re-declaring it.
|
|
331
|
+
*/
|
|
332
|
+
type SmartActionMediaType = 'photo' | 'screenshot' | 'video';
|
|
333
|
+
interface SmartActionResponse {
|
|
334
|
+
id: number;
|
|
335
|
+
type: SmartActionType;
|
|
336
|
+
sub_type?: string;
|
|
337
|
+
status: string;
|
|
338
|
+
number_of_photos?: number | null;
|
|
339
|
+
}
|
|
340
|
+
interface VoiceCallResponse {
|
|
341
|
+
id: number;
|
|
342
|
+
status: ServerVoiceCallStatus;
|
|
343
|
+
type: 'WebInboundCall';
|
|
344
|
+
features: string[];
|
|
345
|
+
region?: string;
|
|
346
|
+
created_at: string;
|
|
347
|
+
fail_reason: string | null;
|
|
348
|
+
csat_settings: {
|
|
349
|
+
enabled: boolean;
|
|
350
|
+
post_in_crm: boolean;
|
|
351
|
+
feedback_enabled: boolean;
|
|
352
|
+
time_to_leave_feedback: number;
|
|
353
|
+
webhook_url: string | null;
|
|
354
|
+
};
|
|
355
|
+
recording_permitted: boolean;
|
|
356
|
+
survey_enabled: boolean;
|
|
357
|
+
agent: HumanAgent | null;
|
|
358
|
+
virtual_agent: VirtualAgent | null;
|
|
359
|
+
participants: HumanAgent[];
|
|
360
|
+
smart_actions?: SmartActionResponse[];
|
|
361
|
+
recording_permission?: RecordingPermission;
|
|
362
|
+
recording_option?: RecordingOption;
|
|
363
|
+
wait_estimation?: number;
|
|
364
|
+
lang: string;
|
|
365
|
+
menus: {
|
|
366
|
+
id: number;
|
|
367
|
+
name: string;
|
|
368
|
+
}[];
|
|
369
|
+
selected_menu: {
|
|
370
|
+
id: number;
|
|
371
|
+
name: string;
|
|
372
|
+
};
|
|
373
|
+
custom_data?: Record<string, unknown>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface RequestReturn {
|
|
377
|
+
headers: Record<string, string>;
|
|
378
|
+
data: any;
|
|
379
|
+
}
|
|
380
|
+
interface LogData {
|
|
381
|
+
loglevel: string;
|
|
382
|
+
timestamp: string;
|
|
383
|
+
application: string;
|
|
384
|
+
sdk_version: string;
|
|
385
|
+
device_uuid: string;
|
|
386
|
+
tenant: string;
|
|
387
|
+
company_id: string;
|
|
388
|
+
location_url: string;
|
|
389
|
+
channel: string;
|
|
390
|
+
message: string;
|
|
391
|
+
data: any;
|
|
392
|
+
tracker_id?: string;
|
|
393
|
+
}
|
|
394
|
+
interface LogHistoryData {
|
|
395
|
+
date: string;
|
|
396
|
+
channel: string;
|
|
397
|
+
level: string;
|
|
398
|
+
args: any[];
|
|
399
|
+
}
|
|
400
|
+
interface ClientEvent {
|
|
401
|
+
name: string;
|
|
402
|
+
payload: {
|
|
403
|
+
lang: string;
|
|
404
|
+
menu_id: number;
|
|
405
|
+
[key: string]: unknown;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
interface MessageRequest {
|
|
409
|
+
type: string;
|
|
410
|
+
content?: string;
|
|
411
|
+
[key: string]: unknown;
|
|
412
|
+
}
|
|
413
|
+
interface ChatRequest {
|
|
414
|
+
lang?: string;
|
|
415
|
+
trigger_id?: string;
|
|
416
|
+
ticket_id?: string;
|
|
417
|
+
email?: string;
|
|
418
|
+
greeting?: string;
|
|
419
|
+
cobrowsable?: boolean;
|
|
420
|
+
custom_data?: {
|
|
421
|
+
signed?: string;
|
|
422
|
+
unsigned?: Record<string, any>;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
interface EscalateRequest {
|
|
426
|
+
force_escalate: boolean;
|
|
427
|
+
menu_id: number;
|
|
428
|
+
lang: string;
|
|
429
|
+
}
|
|
430
|
+
interface CobrowseRequest {
|
|
431
|
+
code: string;
|
|
432
|
+
from: string;
|
|
433
|
+
nonce: string;
|
|
434
|
+
}
|
|
435
|
+
interface RateRequest {
|
|
436
|
+
rating: number;
|
|
437
|
+
feedback: string;
|
|
438
|
+
}
|
|
439
|
+
interface SurveyAnswers {
|
|
440
|
+
[id: string]: number | string;
|
|
441
|
+
}
|
|
442
|
+
interface ChatEndUserEventRequest {
|
|
443
|
+
event: {
|
|
444
|
+
name: string;
|
|
445
|
+
payload: Record<string, string>;
|
|
446
|
+
};
|
|
447
|
+
end_user_name?: string;
|
|
448
|
+
}
|
|
449
|
+
interface CallRequest {
|
|
450
|
+
phone_number: string;
|
|
451
|
+
lang?: string;
|
|
452
|
+
scheduled_at?: string;
|
|
453
|
+
ticket_id?: string;
|
|
454
|
+
email?: string;
|
|
455
|
+
recording_permission?: RecordingPermission;
|
|
456
|
+
custom_data?: {
|
|
457
|
+
signed?: string;
|
|
458
|
+
unsigned?: Record<string, any>;
|
|
459
|
+
};
|
|
460
|
+
reschedule_call_id?: number;
|
|
461
|
+
}
|
|
462
|
+
interface EmailRequest {
|
|
463
|
+
name?: string;
|
|
464
|
+
email: string;
|
|
465
|
+
content: string;
|
|
466
|
+
lang?: string;
|
|
467
|
+
files?: File[];
|
|
468
|
+
recaptcha?: string;
|
|
469
|
+
}
|
|
470
|
+
interface FormData {
|
|
471
|
+
signature: string;
|
|
472
|
+
data: {
|
|
473
|
+
smart_action_id: number;
|
|
474
|
+
id: number;
|
|
475
|
+
uri: string;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
interface ChatMessageRequest {
|
|
479
|
+
message: {
|
|
480
|
+
content: string;
|
|
481
|
+
timestamp: string;
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
interface CheckInVisibilityStateRequest {
|
|
485
|
+
widget_minimized?: boolean;
|
|
486
|
+
tab_inactive?: boolean;
|
|
487
|
+
}
|
|
488
|
+
interface CheckInModalStateRequest {
|
|
489
|
+
modal_type: 'check_in';
|
|
490
|
+
}
|
|
491
|
+
interface GetTimeSlotsRequest {
|
|
492
|
+
lang?: string;
|
|
493
|
+
rescheduleCallId?: number;
|
|
494
|
+
}
|
|
495
|
+
interface CustomFormPayload {
|
|
496
|
+
smart_action_id: number;
|
|
497
|
+
form_response: {
|
|
498
|
+
question_id: number;
|
|
499
|
+
value: string | string[] | boolean;
|
|
500
|
+
}[];
|
|
501
|
+
}
|
|
502
|
+
interface VoiceCallRequest {
|
|
503
|
+
lang?: string;
|
|
504
|
+
ticket_id?: string;
|
|
505
|
+
email?: string;
|
|
506
|
+
recording_permission?: RecordingPermission;
|
|
507
|
+
custom_data?: {
|
|
508
|
+
signed?: string;
|
|
509
|
+
unsigned?: Record<string, any>;
|
|
510
|
+
};
|
|
511
|
+
cobrowsable?: boolean;
|
|
512
|
+
voicemail_reason?: string;
|
|
429
513
|
}
|
|
430
514
|
|
|
431
515
|
type RequestMethod = (url: string, options: RequestInit | Record<string, any>) => Promise<RequestReturn>;
|
|
@@ -556,6 +640,10 @@ declare abstract class BaseProvider {
|
|
|
556
640
|
}
|
|
557
641
|
declare function addProviderType(Provider: typeof BaseProvider): void;
|
|
558
642
|
|
|
643
|
+
interface ChatHooks {
|
|
644
|
+
leaveChat?: () => Promise<void>;
|
|
645
|
+
leaveChatBeacon?: () => void;
|
|
646
|
+
}
|
|
559
647
|
declare class Chat {
|
|
560
648
|
private provider;
|
|
561
649
|
private store;
|
|
@@ -566,8 +654,10 @@ declare class Chat {
|
|
|
566
654
|
inEscalation: boolean;
|
|
567
655
|
private events;
|
|
568
656
|
private cachedFiles;
|
|
569
|
-
|
|
570
|
-
|
|
657
|
+
private hooks;
|
|
658
|
+
private leaveSent;
|
|
659
|
+
private beaconAttempted;
|
|
660
|
+
constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks);
|
|
571
661
|
get id(): number;
|
|
572
662
|
get menuId(): number;
|
|
573
663
|
get channelId(): string;
|
|
@@ -603,6 +693,9 @@ declare class Chat {
|
|
|
603
693
|
off(eventName: string, handler: EventHandler): void;
|
|
604
694
|
connect(): Promise<boolean>;
|
|
605
695
|
disconnect(): Promise<void>;
|
|
696
|
+
private sendLeave;
|
|
697
|
+
leaveBeacon(): void;
|
|
698
|
+
resetBeaconState(): void;
|
|
606
699
|
sendMessage(message: MessageRequest, file?: File): Promise<number>;
|
|
607
700
|
preview(text: string): Promise<void>;
|
|
608
701
|
fetchMessages(): Promise<MessageResponse[]>;
|
|
@@ -611,12 +704,20 @@ declare class Chat {
|
|
|
611
704
|
saveMedia(index: number, file: File): void;
|
|
612
705
|
destroy(): Promise<void>;
|
|
613
706
|
clearMediaStore(): Promise<void>;
|
|
614
|
-
_handleChatEndedEvent(message: MessageResponse): void;
|
|
615
707
|
private triggerEvent;
|
|
616
708
|
private registerProviderEvents;
|
|
617
709
|
private registerMessageEvents;
|
|
618
710
|
}
|
|
619
711
|
|
|
712
|
+
/** Thrown when a message send is attempted after the chat has already ended. */
|
|
713
|
+
declare class ChatEndedError extends Error {
|
|
714
|
+
static readonly CODE = "CHAT_ENDED";
|
|
715
|
+
readonly code = "CHAT_ENDED";
|
|
716
|
+
/** Chat status at the time of the rejected send (e.g. 'finished', 'timeout'). */
|
|
717
|
+
readonly status?: string;
|
|
718
|
+
constructor(status?: string);
|
|
719
|
+
}
|
|
720
|
+
|
|
620
721
|
declare global {
|
|
621
722
|
interface Window {
|
|
622
723
|
webkitIndexedDB: IDBFactory;
|
|
@@ -639,6 +740,270 @@ declare class MediaStore {
|
|
|
639
740
|
clear(): Promise<void>;
|
|
640
741
|
}
|
|
641
742
|
|
|
743
|
+
/** Return type of `VoiceCall.feedbackType` — which post-call UX (if any) to show. */
|
|
744
|
+
type VoiceFeedbackType = 'survey' | 'rate' | 'none';
|
|
745
|
+
/**
|
|
746
|
+
* Opaque server-side reference returned by {@link VoiceCall.prepareMediaUpload}
|
|
747
|
+
* and consumed by {@link VoiceCall.submitMediaRefsForSmartAction}. `kind`
|
|
748
|
+
* carries the originating media type so submit can reject cross-type misuse
|
|
749
|
+
* (e.g. submitting a video ref under a photo SmartAction).
|
|
750
|
+
*/
|
|
751
|
+
type MediaRef = {
|
|
752
|
+
readonly ref: string;
|
|
753
|
+
readonly kind: SmartActionMediaType;
|
|
754
|
+
};
|
|
755
|
+
declare class VoiceCall {
|
|
756
|
+
/** Backing field for the read-only `state` accessor; mutated by the SDK. */
|
|
757
|
+
protected _state: VoiceCallResponse;
|
|
758
|
+
private _publicState;
|
|
759
|
+
private setInternalState;
|
|
760
|
+
/**
|
|
761
|
+
* Server-side call state. Exposed as `Readonly` so consumers cannot mutate
|
|
762
|
+
* top-level fields. Raw `status` is omitted from this view — use
|
|
763
|
+
* `call.status` for the curated 7-state form, or `call.serverStatus()` to
|
|
764
|
+
* read the raw `ServerVoiceCallStatus` explicitly.
|
|
765
|
+
*/
|
|
766
|
+
get state(): Readonly<Omit<VoiceCallResponse, 'status'>>;
|
|
767
|
+
/**
|
|
768
|
+
* Raw server status escape hatch. Prefer `call.status` (curated). The raw
|
|
769
|
+
* value is intentionally exposed so consumers can test against the full
|
|
770
|
+
* `ServerVoiceCallStatus` union when curated `VoiceCallStatus` is too coarse.
|
|
771
|
+
*/
|
|
772
|
+
serverStatus(): ServerVoiceCallStatus;
|
|
773
|
+
private keepAlive;
|
|
774
|
+
private stateMachine;
|
|
775
|
+
private handledSmartActionIds;
|
|
776
|
+
private smartActionQueue;
|
|
777
|
+
private get currentSmartActionId();
|
|
778
|
+
private currentCobrowseSmartActionId;
|
|
779
|
+
private recordingPermissionAsked;
|
|
780
|
+
private speakerOn;
|
|
781
|
+
private cobrowseStarter;
|
|
782
|
+
private resolveStartedAtFromState;
|
|
783
|
+
private setStatus;
|
|
784
|
+
private teardownActiveResources;
|
|
785
|
+
/** Server-assigned voice call id. */
|
|
786
|
+
get id(): number;
|
|
787
|
+
/** Curated lifecycle status (mapped from raw server status). */
|
|
788
|
+
get status(): VoiceCallStatus;
|
|
789
|
+
/** Current peer (human or virtual). Human takes priority once escalated. */
|
|
790
|
+
get agent(): HumanAgent | VirtualAgent | null;
|
|
791
|
+
/** Seconds elapsed since the media leg connected (server-anchored). */
|
|
792
|
+
get duration(): number;
|
|
793
|
+
/**
|
|
794
|
+
* Post-call feedback type configured for this call.
|
|
795
|
+
*
|
|
796
|
+
* Precedence: `'survey'` > `'rate'` > `'none'`. If both `survey_enabled`
|
|
797
|
+
* and `csat_settings.enabled` are true on the call, survey wins (the
|
|
798
|
+
* customer-configured questionnaire is richer than a numeric rating).
|
|
799
|
+
* `'none'` means the consumer should skip any post-call UX and return
|
|
800
|
+
* straight to the launcher.
|
|
801
|
+
*/
|
|
802
|
+
get feedbackType(): VoiceFeedbackType;
|
|
803
|
+
/** Toggle mute on the local microphone. Idempotent. */
|
|
804
|
+
mute(on: boolean): void;
|
|
805
|
+
/** True when the local microphone is muted. */
|
|
806
|
+
isMuted(): boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Returns the remote audio MediaStream (human agent or virtual agent).
|
|
809
|
+
* Null after the call ends or before media is connected.
|
|
810
|
+
*/
|
|
811
|
+
getRemoteAudioStream(): MediaStream | null;
|
|
812
|
+
/**
|
|
813
|
+
* True when the runtime can programmatically switch the audio output (e.g.
|
|
814
|
+
* loudspeaker vs earpiece). iOS Safari returns false; consumers should hide
|
|
815
|
+
* the speaker toggle UI when this is false.
|
|
816
|
+
*/
|
|
817
|
+
isSpeakerSupported(): boolean;
|
|
818
|
+
/** True when the call audio is currently routed to a loudspeaker output. */
|
|
819
|
+
isSpeakerOn(): boolean;
|
|
820
|
+
/**
|
|
821
|
+
* Switch the audio output between loudspeaker (true) and the default
|
|
822
|
+
* earpiece/system output (false). On platforms where output-device selection
|
|
823
|
+
* is not supported, only the internal flag is updated (visual-only toggle).
|
|
824
|
+
*
|
|
825
|
+
* @throws {ProviderError} when `on=true` but no loudspeaker output device is
|
|
826
|
+
* available on a platform that supports output-device selection.
|
|
827
|
+
*/
|
|
828
|
+
setSpeakerOn(on: boolean): Promise<void>;
|
|
829
|
+
/** Confirm the recording-consent prompt (server records the call). */
|
|
830
|
+
grantRecording(): Promise<void>;
|
|
831
|
+
/** Decline the recording-consent prompt (server skips recording). */
|
|
832
|
+
denyRecording(): Promise<void>;
|
|
833
|
+
/**
|
|
834
|
+
* Generate a cobrowse code so an agent can join the user's screen for this
|
|
835
|
+
* voice call. Throws if cobrowse is not enabled on the Client (see the
|
|
836
|
+
* `cobrowse` option).
|
|
837
|
+
*/
|
|
838
|
+
startCobrowse(lang?: string, from?: string): Promise<string>;
|
|
839
|
+
/** Submit a text response to an agent-pushed text SmartAction. */
|
|
840
|
+
submitTextSmartAction(smartActionId: number, text: string): Promise<void>;
|
|
841
|
+
/** Confirm an agent-pushed verification SmartAction (user said yes). */
|
|
842
|
+
confirmVerificationSmartAction(smartActionId: number): Promise<void>;
|
|
843
|
+
/** Cancel any active SmartAction (user dismissed the dialog). */
|
|
844
|
+
cancelSmartAction(smartActionId: number): Promise<void>;
|
|
845
|
+
/** Upload media files (photo / screenshot / video) for a SmartAction. */
|
|
846
|
+
uploadMediaForSmartAction(smartActionId: number, files: File[], type: 'photo' | 'screenshot' | 'video'): Promise<void>;
|
|
847
|
+
/**
|
|
848
|
+
* Upload one media file in advance (used by the widget's mobile background-upload
|
|
849
|
+
* path). Returns an opaque server-side reference. Caller passes the references
|
|
850
|
+
* collected this way into {@link submitMediaRefsForSmartAction}. Pass an
|
|
851
|
+
* AbortSignal to cancel an in-flight upload (e.g. user closed the picker
|
|
852
|
+
* dialog mid-transfer).
|
|
853
|
+
*/
|
|
854
|
+
prepareMediaUpload(file: File, type: SmartActionMediaType, signal?: AbortSignal): Promise<MediaRef>;
|
|
855
|
+
/**
|
|
856
|
+
* Register pre-uploaded media refs (from {@link prepareMediaUpload}) against an
|
|
857
|
+
* active SmartAction. Used by the mobile background-upload path; desktop continues
|
|
858
|
+
* to use {@link uploadMediaForSmartAction}.
|
|
859
|
+
*
|
|
860
|
+
* Each {@link MediaRef} carries its `kind` so callers cannot accidentally
|
|
861
|
+
* submit a video ref under a photo SmartAction. The method throws
|
|
862
|
+
* {@link SmartActionError} if any ref's `kind` doesn't match `type`.
|
|
863
|
+
*/
|
|
864
|
+
submitMediaRefsForSmartAction(smartActionId: number, type: SmartActionMediaType, refs: readonly MediaRef[]): Promise<void>;
|
|
865
|
+
protected registerProviderEvents(): void;
|
|
866
|
+
protected fetchAndUpdateState(): Promise<void>;
|
|
867
|
+
private handleProviderMessage;
|
|
868
|
+
private handleSmartActionRequested;
|
|
869
|
+
private handleSmartActionResolved;
|
|
870
|
+
private handleStatusChanged;
|
|
871
|
+
private sendProviderMessage;
|
|
872
|
+
private markSmartActionHandled;
|
|
873
|
+
private resolveSmartAction;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
declare const VOICE_EVENTS: {
|
|
877
|
+
readonly STATUS_CHANGED: "voice.statusChanged";
|
|
878
|
+
readonly RECONNECTING: "voice.reconnecting";
|
|
879
|
+
readonly RECONNECTED: "voice.reconnected";
|
|
880
|
+
readonly ERROR: "voice.error";
|
|
881
|
+
readonly SMART_ACTION_REQUESTED: "voice.smartActionRequested";
|
|
882
|
+
readonly SMART_ACTION_RESOLVED: "voice.smartActionResolved";
|
|
883
|
+
readonly COBROWSE_REQUESTED: "voice.cobrowseRequested";
|
|
884
|
+
readonly COBROWSE_RESOLVED: "voice.cobrowseResolved";
|
|
885
|
+
readonly RECORDING_PERMISSION_REQUIRED: "voice.recordingPermissionRequired";
|
|
886
|
+
readonly MIC_PERMISSION_REQUIRED: "voice.micPermissionRequired";
|
|
887
|
+
readonly CONNECTION_QUALITY: "voice.connectionQuality";
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
/** Extract a human-readable message from an `unknown` caught value. */
|
|
891
|
+
declare const getErrorMessage: (err: unknown) => string;
|
|
892
|
+
/** Cross-realm-safe fallback for `err instanceof VoiceCallError` checks. */
|
|
893
|
+
declare const hasErrorCode: (err: unknown, code: VoiceErrorCode) => boolean;
|
|
894
|
+
/** Extract an HTTP-style numeric `status` from an `unknown` caught value. */
|
|
895
|
+
declare const getErrorStatus: (err: unknown) => number | undefined;
|
|
896
|
+
/** Base class for all voice-related errors. Carries a stable string `code`. */
|
|
897
|
+
declare class VoiceCallError extends Error {
|
|
898
|
+
readonly code: VoiceErrorCode;
|
|
899
|
+
constructor(message: string, code: VoiceErrorCode, cause?: unknown);
|
|
900
|
+
}
|
|
901
|
+
/** End user already has a call in progress on this device. */
|
|
902
|
+
declare class CallInProgressError extends VoiceCallError {
|
|
903
|
+
static readonly CODE = "CALL_IN_PROGRESS";
|
|
904
|
+
constructor(message?: string);
|
|
905
|
+
}
|
|
906
|
+
/** Inbound voice channel is disabled for this menu. */
|
|
907
|
+
declare class InboundDisabledError extends VoiceCallError {
|
|
908
|
+
static readonly CODE = "INBOUND_DISABLED";
|
|
909
|
+
constructor(message?: string);
|
|
910
|
+
}
|
|
911
|
+
/** Tenant is currently outside its configured operation hours. */
|
|
912
|
+
declare class OperationHoursError extends VoiceCallError {
|
|
913
|
+
static readonly CODE = "OPERATION_HOURS";
|
|
914
|
+
constructor(message?: string);
|
|
915
|
+
}
|
|
916
|
+
/** Inbound voice feature flag is off for this tenant. */
|
|
917
|
+
declare class FeatureNotEnabledError extends VoiceCallError {
|
|
918
|
+
static readonly CODE = "FEATURE_NOT_ENABLED";
|
|
919
|
+
constructor(message?: string);
|
|
920
|
+
}
|
|
921
|
+
/** Mic unavailable at call start — wraps any getUserMedia rejection; inspect `cause` to distinguish. */
|
|
922
|
+
declare class MicPermissionDeniedError extends VoiceCallError {
|
|
923
|
+
static readonly CODE = "MIC_PERMISSION_DENIED";
|
|
924
|
+
constructor(message?: string, cause?: unknown);
|
|
925
|
+
}
|
|
926
|
+
/** Caller invoked a method that requires an active voice call but none exists. */
|
|
927
|
+
declare class NoActiveVoiceCallError extends VoiceCallError {
|
|
928
|
+
static readonly CODE = "NO_ACTIVE_VOICE_CALL";
|
|
929
|
+
constructor(message?: string);
|
|
930
|
+
}
|
|
931
|
+
/** Another tab already holds the voice tab lock. */
|
|
932
|
+
declare class AnotherTabVoiceCallError extends VoiceCallError {
|
|
933
|
+
static readonly CODE = "ANOTHER_TAB_VOICE_CALL";
|
|
934
|
+
constructor(message?: string);
|
|
935
|
+
}
|
|
936
|
+
/** Underlying voice provider (e.g., Twilio Device/Call) failed. */
|
|
937
|
+
declare class ProviderError extends VoiceCallError {
|
|
938
|
+
static readonly CODE = "PROVIDER_ERROR";
|
|
939
|
+
constructor(message: string, cause?: unknown);
|
|
940
|
+
}
|
|
941
|
+
/** Smart action submit / cancel / update / upload failed (server error or missing client method). */
|
|
942
|
+
declare class SmartActionError extends VoiceCallError {
|
|
943
|
+
static readonly CODE = "SMART_ACTION_ERROR";
|
|
944
|
+
/** Server message when the agent ends a smart action before the user responds. */
|
|
945
|
+
static readonly ENDED_MESSAGE = "smart action is already ended";
|
|
946
|
+
constructor(message: string, cause?: unknown);
|
|
947
|
+
/** True when the underlying failure was the agent-ended-already case. */
|
|
948
|
+
get isAlreadyEnded(): boolean;
|
|
949
|
+
}
|
|
950
|
+
/** Unrecognized voice subsystem failure (network timeout, transient server error). */
|
|
951
|
+
declare class UnknownVoiceError extends VoiceCallError {
|
|
952
|
+
static readonly CODE = "UNKNOWN_VOICE_ERROR";
|
|
953
|
+
constructor(message: string, cause?: unknown);
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* True when the error indicates the call cannot start now due to tenant /
|
|
957
|
+
* menu / company / concurrency constraints — outside operation hours,
|
|
958
|
+
* inbound disabled, feature flag off, or another call in progress.
|
|
959
|
+
* MenuFoot uses this to show an after-hours message instead of an error UI.
|
|
960
|
+
*/
|
|
961
|
+
declare const isAfterHoursError: (err: unknown) => boolean;
|
|
962
|
+
/** Union of all stable error codes thrown by the voice subsystem. */
|
|
963
|
+
type VoiceErrorCode = typeof CallInProgressError.CODE | typeof InboundDisabledError.CODE | typeof OperationHoursError.CODE | typeof FeatureNotEnabledError.CODE | typeof MicPermissionDeniedError.CODE | typeof NoActiveVoiceCallError.CODE | typeof AnotherTabVoiceCallError.CODE | typeof ProviderError.CODE | typeof SmartActionError.CODE | typeof UnknownVoiceError.CODE;
|
|
964
|
+
|
|
965
|
+
interface VoiceStatusChangedEvent {
|
|
966
|
+
id: number;
|
|
967
|
+
status: VoiceCallStatus;
|
|
968
|
+
prevStatus?: VoiceCallStatus;
|
|
969
|
+
}
|
|
970
|
+
interface VoiceErrorEvent {
|
|
971
|
+
id: number;
|
|
972
|
+
error: VoiceCallError;
|
|
973
|
+
}
|
|
974
|
+
/** Emitted on a non-cobrowse smart action request. `smartAction.type` is never 'cobrowse'. */
|
|
975
|
+
interface VoiceSmartActionRequestedEvent {
|
|
976
|
+
smartAction: Readonly<SmartActionResponse & {
|
|
977
|
+
type: Exclude<SmartActionType, 'cobrowse'>;
|
|
978
|
+
}>;
|
|
979
|
+
}
|
|
980
|
+
interface VoiceSmartActionResolvedEvent {
|
|
981
|
+
smartActionId: number;
|
|
982
|
+
}
|
|
983
|
+
/** Emitted on a cobrowse smart action request. `smartAction.type` is always 'cobrowse'. */
|
|
984
|
+
interface VoiceCobrowseRequestedEvent {
|
|
985
|
+
smartAction: Readonly<SmartActionResponse & {
|
|
986
|
+
type: Extract<SmartActionType, 'cobrowse'>;
|
|
987
|
+
}>;
|
|
988
|
+
}
|
|
989
|
+
interface VoiceCobrowseResolvedEvent {
|
|
990
|
+
smartActionId: number;
|
|
991
|
+
}
|
|
992
|
+
interface VoiceRecordingPermissionRequiredEvent {
|
|
993
|
+
id: number;
|
|
994
|
+
}
|
|
995
|
+
/** Result of `client.checkMicPermission()`. `'unknown'` when the Permissions
|
|
996
|
+
* API or the `microphone` descriptor is unsupported (e.g. iOS Safari). */
|
|
997
|
+
type MicPermissionState = 'granted' | 'denied' | 'prompt' | 'unknown';
|
|
998
|
+
type ConnectionQualityLevel = 'good' | 'degraded';
|
|
999
|
+
/** Normalized, provider-agnostic quality issues. Twilio warning names are
|
|
1000
|
+
* mapped to these inside TwilioVoiceProvider — raw Twilio names never leak. */
|
|
1001
|
+
type ConnectionQualityWarning = 'high-latency' | 'jitter' | 'packet-loss' | 'low-quality';
|
|
1002
|
+
interface VoiceConnectionQualityEvent {
|
|
1003
|
+
level: ConnectionQualityLevel;
|
|
1004
|
+
warnings: ConnectionQualityWarning[];
|
|
1005
|
+
}
|
|
1006
|
+
|
|
642
1007
|
declare class Client {
|
|
643
1008
|
VERSION: string;
|
|
644
1009
|
options: ClientOption;
|
|
@@ -648,21 +1013,64 @@ declare class Client {
|
|
|
648
1013
|
request: RequestMethod;
|
|
649
1014
|
chat: Chat;
|
|
650
1015
|
private _cobrowse;
|
|
1016
|
+
private _voiceCall;
|
|
1017
|
+
private _voiceTabLock;
|
|
1018
|
+
private redactionSendQueue;
|
|
1019
|
+
private fileSendQueue;
|
|
1020
|
+
private _rehydratePromise;
|
|
1021
|
+
private onPageHide?;
|
|
1022
|
+
private onPageShow?;
|
|
651
1023
|
constructor(options: ClientOption);
|
|
1024
|
+
private registerUnloadHandlers;
|
|
1025
|
+
private unregisterUnloadHandlers;
|
|
652
1026
|
get deviceId(): string;
|
|
653
1027
|
get user(): UserProfile;
|
|
654
1028
|
get lang(): string;
|
|
655
1029
|
set lang(lang: string);
|
|
656
1030
|
get cobrowse(): any;
|
|
1031
|
+
get cobrowseEnabled(): boolean;
|
|
657
1032
|
destroy(): void;
|
|
1033
|
+
private releaseVoiceTabLock;
|
|
1034
|
+
/** Voice event payload signatures — overloads for `client.on`/`off`. */
|
|
1035
|
+
on(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void;
|
|
1036
|
+
on(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void;
|
|
1037
|
+
on(event: typeof VOICE_EVENTS.RECONNECTED, handler: () => void): void;
|
|
1038
|
+
on(event: typeof VOICE_EVENTS.ERROR, handler: (payload: VoiceErrorEvent) => void): void;
|
|
1039
|
+
on(event: typeof VOICE_EVENTS.SMART_ACTION_REQUESTED, handler: (payload: VoiceSmartActionRequestedEvent) => void): void;
|
|
1040
|
+
on(event: typeof VOICE_EVENTS.SMART_ACTION_RESOLVED, handler: (payload: VoiceSmartActionResolvedEvent) => void): void;
|
|
1041
|
+
on(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
1042
|
+
on(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
1043
|
+
on(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1044
|
+
on(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1045
|
+
on(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
658
1046
|
on(eventName: string, handler: EventHandler): void;
|
|
1047
|
+
off(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void;
|
|
1048
|
+
off(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void;
|
|
1049
|
+
off(event: typeof VOICE_EVENTS.RECONNECTED, handler: () => void): void;
|
|
1050
|
+
off(event: typeof VOICE_EVENTS.ERROR, handler: (payload: VoiceErrorEvent) => void): void;
|
|
1051
|
+
off(event: typeof VOICE_EVENTS.SMART_ACTION_REQUESTED, handler: (payload: VoiceSmartActionRequestedEvent) => void): void;
|
|
1052
|
+
off(event: typeof VOICE_EVENTS.SMART_ACTION_RESOLVED, handler: (payload: VoiceSmartActionResolvedEvent) => void): void;
|
|
1053
|
+
off(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
1054
|
+
off(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
1055
|
+
off(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1056
|
+
off(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1057
|
+
off(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
659
1058
|
off(eventName: string, handler: EventHandler): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Non-prompting read of the microphone permission state. Never calls
|
|
1061
|
+
* getUserMedia, so it does NOT trigger the browser permission dialog.
|
|
1062
|
+
* Returns 'unknown' when the Permissions API / 'microphone' descriptor is
|
|
1063
|
+
* unsupported (iOS Safari, older browsers) — callers should then rely on the
|
|
1064
|
+
* `voice.micPermissionRequired` event / the thrown MicPermissionDeniedError.
|
|
1065
|
+
*/
|
|
1066
|
+
checkMicPermission(): Promise<MicPermissionState>;
|
|
660
1067
|
getCompany(): Promise<CompanyResponse>;
|
|
661
1068
|
getFeatureFlags(): Promise<FeatureFlagsResponse>;
|
|
662
1069
|
runTrigger(cb: (trigger: TriggerItem) => void): Promise<void>;
|
|
663
1070
|
trackClientEvents(events: ClientEvent[]): Promise<void>;
|
|
664
1071
|
getProhibitedFileTypes(): Promise<FileTypeItem[]>;
|
|
665
1072
|
getMenus(key?: string, lang?: string): Promise<MenuResponse>;
|
|
1073
|
+
cancelMenuPolling(): void;
|
|
666
1074
|
getCustomFormData(formId: string): Promise<RequestReturn>;
|
|
667
1075
|
submitCustomForm(payload: CustomFormPayload): Promise<RequestReturn>;
|
|
668
1076
|
getAfterHourMessage(lang?: string): Promise<string>;
|
|
@@ -682,10 +1090,64 @@ declare class Client {
|
|
|
682
1090
|
loadChat(chatId: number | string): Promise<Chat>;
|
|
683
1091
|
resumeChat(chatId: number | string): Promise<Chat>;
|
|
684
1092
|
loadOngoingChat(): Promise<Chat | null>;
|
|
1093
|
+
private _doLoadOngoingChat;
|
|
685
1094
|
restoreCobrowseSession(): Promise<void>;
|
|
686
1095
|
finishChat(): Promise<void>;
|
|
687
1096
|
updatePostSession(postSessionStatus: PostSessionStatus, optInSelection?: boolean): Promise<void>;
|
|
688
1097
|
destroyChat(): Promise<void>;
|
|
1098
|
+
/** Active voice call instance, or null when no call is in progress. */
|
|
1099
|
+
get voiceCall(): VoiceCall | null;
|
|
1100
|
+
/**
|
|
1101
|
+
* Returns true when localStorage holds a pending refresh-restore entry.
|
|
1102
|
+
* Not cached — invocation is a sync I/O check.
|
|
1103
|
+
*/
|
|
1104
|
+
hasStoredVoiceCall(): boolean;
|
|
1105
|
+
/**
|
|
1106
|
+
* Start a new inbound voice call for the given menu.
|
|
1107
|
+
*
|
|
1108
|
+
* @throws CallInProgressError if another voice call is already active in
|
|
1109
|
+
* this session.
|
|
1110
|
+
* @throws MicPermissionDeniedError if the browser denies microphone access.
|
|
1111
|
+
* @throws AnotherTabVoiceCallError if another tab already holds the voice
|
|
1112
|
+
* tab lock.
|
|
1113
|
+
* @throws InboundDisabledError if inbound voice is disabled for the menu.
|
|
1114
|
+
* @throws OperationHoursError if the menu is outside its operation hours.
|
|
1115
|
+
* @throws FeatureNotEnabledError if the company doesn't have the voice
|
|
1116
|
+
* feature enabled.
|
|
1117
|
+
* @throws VoiceCallError (code 'UNKNOWN_VOICE_ERROR') as a generic
|
|
1118
|
+
* fallback for unrecognized server / transient failures.
|
|
1119
|
+
*/
|
|
1120
|
+
startVoiceCall(menuId: number | string, options?: VoiceCallRequest): Promise<VoiceCall>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Restore a voice call after a page refresh. Resolves to the call instance
|
|
1123
|
+
* when an active call exists on the server, or null when no recoverable call
|
|
1124
|
+
* is found (no stored entry, or the call has already terminated).
|
|
1125
|
+
*
|
|
1126
|
+
* @throws AnotherTabVoiceCallError if another tab already holds the voice
|
|
1127
|
+
* tab lock.
|
|
1128
|
+
* @throws Network/server errors are propagated; HTTP 404 is treated as
|
|
1129
|
+
* "no recoverable call" and resolves to null.
|
|
1130
|
+
*/
|
|
1131
|
+
loadVoiceCall(callId?: number | string): Promise<VoiceCall | null>;
|
|
1132
|
+
/**
|
|
1133
|
+
* End the active call but keep the VoiceCall instance + tab lock alive
|
|
1134
|
+
* so the widget can show post-call UI (rate/survey). For full teardown
|
|
1135
|
+
* including storage cleanup, call destroyVoiceCall().
|
|
1136
|
+
*/
|
|
1137
|
+
endVoiceCall(): Promise<void>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Escalate the active VA voice call to a human-agent queue. Server validates
|
|
1140
|
+
* the transition (only valid during a VA-routed call); SDK does not gate.
|
|
1141
|
+
*
|
|
1142
|
+
* @throws NoActiveVoiceCallError if no voice call is active.
|
|
1143
|
+
*/
|
|
1144
|
+
escalateVoiceCall(): Promise<void>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Release all resources for the active voice call. Hangs up the call first
|
|
1147
|
+
* if it's still ongoing, then tears down provider, timers, and event
|
|
1148
|
+
* listeners, and clears the localStorage entry.
|
|
1149
|
+
*/
|
|
1150
|
+
destroyVoiceCall(): Promise<void>;
|
|
689
1151
|
getChatDeflection(): Promise<ChatDeflectionResponse | null>;
|
|
690
1152
|
sendChatTranscripts(emails: string[]): Promise<void>;
|
|
691
1153
|
downloadChatTranscript(): Promise<GenerateTranscriptResponse>;
|
|
@@ -693,6 +1155,24 @@ declare class Client {
|
|
|
693
1155
|
getChatSurvey(): Promise<ChatSurveyResponse | null>;
|
|
694
1156
|
sendChatSurvey(answers: SurveyAnswers): Promise<void>;
|
|
695
1157
|
sendChatRate(data: RateRequest): Promise<void>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Submit a CSAT rating for the active voice call (feedbackType === 'rate').
|
|
1160
|
+
*
|
|
1161
|
+
* @throws NoActiveVoiceCallError if no voice call is active.
|
|
1162
|
+
*/
|
|
1163
|
+
rateVoiceCall(data: RateRequest): Promise<void>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Fetch the post-call survey definition (feedbackType === 'survey').
|
|
1166
|
+
*
|
|
1167
|
+
* @throws NoActiveVoiceCallError if no voice call is active.
|
|
1168
|
+
*/
|
|
1169
|
+
getVoiceCallSurvey(): Promise<ChatSurveyResponse | null>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Submit answers to the post-call survey (feedbackType === 'survey').
|
|
1172
|
+
*
|
|
1173
|
+
* @throws NoActiveVoiceCallError if no voice call is active.
|
|
1174
|
+
*/
|
|
1175
|
+
submitVoiceCallSurvey(answers: SurveyAnswers): Promise<void>;
|
|
696
1176
|
escalateChat(data?: EscalateRequest): Promise<void>;
|
|
697
1177
|
trackChatEscalation(escalationId: number, channel: string): Promise<void>;
|
|
698
1178
|
trackChatEndUserEvent(data: ChatEndUserEventRequest): Promise<void>;
|
|
@@ -718,7 +1198,6 @@ declare class Client {
|
|
|
718
1198
|
private updateCheckIn;
|
|
719
1199
|
private initializeCobrowse;
|
|
720
1200
|
private registerOngoingChat;
|
|
721
|
-
_triggerEvent(eventName: string, data?: any): void;
|
|
722
1201
|
}
|
|
723
1202
|
|
|
724
1203
|
declare class CircularBuffer<T> {
|
|
@@ -747,6 +1226,8 @@ declare class Logger {
|
|
|
747
1226
|
private log;
|
|
748
1227
|
}
|
|
749
1228
|
|
|
1229
|
+
declare const isMobilePlatform: () => boolean;
|
|
1230
|
+
|
|
750
1231
|
declare const ENVIRONMENT: string;
|
|
751
1232
|
declare const VERSION: string;
|
|
752
1233
|
declare const OPTIONS: {
|
|
@@ -758,4 +1239,96 @@ declare const OPTIONS: {
|
|
|
758
1239
|
version: string;
|
|
759
1240
|
};
|
|
760
1241
|
|
|
761
|
-
|
|
1242
|
+
type VoiceProviderMessageType = 'smart_action_requested' | 'smart_action_resolved' | 'recording_permission_required' | 'status_changed' | 'smart_action_notified' | 'smart_action_response' | 'recording_permission';
|
|
1243
|
+
|
|
1244
|
+
type IssueVoiceTokenMethod = () => Promise<{
|
|
1245
|
+
token: string;
|
|
1246
|
+
identity: string;
|
|
1247
|
+
}>;
|
|
1248
|
+
interface VoiceProviderMessage {
|
|
1249
|
+
type: VoiceProviderMessageType;
|
|
1250
|
+
data?: Record<string, unknown>;
|
|
1251
|
+
}
|
|
1252
|
+
declare abstract class BaseVoiceProvider {
|
|
1253
|
+
static type: string;
|
|
1254
|
+
protected events: EventManager;
|
|
1255
|
+
protected state: VoiceCallResponse;
|
|
1256
|
+
protected issueVoiceToken: IssueVoiceTokenMethod;
|
|
1257
|
+
constructor(events: EventManager, state: VoiceCallResponse, issueVoiceToken: IssueVoiceTokenMethod);
|
|
1258
|
+
/**
|
|
1259
|
+
* Dial the carrier and prepare the media leg.
|
|
1260
|
+
*
|
|
1261
|
+
* Contract:
|
|
1262
|
+
* - Resolve only after the transport reaches a state where it can emit
|
|
1263
|
+
* `INTERNAL_VOICE_EVENTS.CONNECTED` (`'voice:internal:connected'`) on its
|
|
1264
|
+
* own. The CONNECTED event is what drives `VoiceCall.status` from
|
|
1265
|
+
* `connecting` to `connected` / `va_connected`; without it, the call
|
|
1266
|
+
* stays in pre-connect state forever.
|
|
1267
|
+
* - Emit CONNECTED no later than the carrier's handshake completes (Twilio
|
|
1268
|
+
* does this on `Device.connect`'s `accept` event). If your transport
|
|
1269
|
+
* takes longer than a few seconds to reach the bridge, surface progress
|
|
1270
|
+
* via your own status messages — don't delay CONNECTED past actual
|
|
1271
|
+
* media-leg readiness.
|
|
1272
|
+
* - On failure, throw a `ProviderError` (or subclass) so the SDK can route
|
|
1273
|
+
* it through `VOICE_EVENTS.ERROR` with a typed shape.
|
|
1274
|
+
*/
|
|
1275
|
+
abstract create(): Promise<void>;
|
|
1276
|
+
/**
|
|
1277
|
+
* Fully tear down provider resources (device, listeners, audio context).
|
|
1278
|
+
* Called once per provider instance; subsequent calls are no-ops.
|
|
1279
|
+
* After destroy(), the provider MUST NOT emit further events.
|
|
1280
|
+
*/
|
|
1281
|
+
abstract destroy(): Promise<void>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Toggle the local microphone mute state.
|
|
1284
|
+
*
|
|
1285
|
+
* Contract:
|
|
1286
|
+
* - Idempotent — repeated calls with the same boolean MUST be no-ops. The
|
|
1287
|
+
* SDK and consumers may call `mute(true)` multiple times (focus
|
|
1288
|
+
* restoration, refresh re-apply); do not assume each call flips state.
|
|
1289
|
+
* - Synchronous. The state change MUST be observable via `isMuted()` on
|
|
1290
|
+
* the next event-loop tick.
|
|
1291
|
+
*/
|
|
1292
|
+
abstract mute(on: boolean): void;
|
|
1293
|
+
abstract isMuted(): boolean;
|
|
1294
|
+
abstract isOutputSelectionSupported(): boolean;
|
|
1295
|
+
abstract getAvailableOutputDevices(): MediaDeviceInfo[];
|
|
1296
|
+
abstract setOutputDevice(deviceId: string): Promise<void>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Disconnect the active call leg.
|
|
1299
|
+
* MUST emit the internal disconnected event (`'voice:internal:disconnected'`)
|
|
1300
|
+
* before resolving. Idempotent: calling on a non-active provider still emits it.
|
|
1301
|
+
*
|
|
1302
|
+
* @remarks The wire-format string `'voice:internal:disconnected'` IS the
|
|
1303
|
+
* stable contract — provider authors should emit this literal via
|
|
1304
|
+
* `this.events.triggerEvent(...)`. We do not export a named constant for
|
|
1305
|
+
* the SDK-provider boundary; the literal is intentionally the public
|
|
1306
|
+
* contract surface so providers don't take an import dependency on the
|
|
1307
|
+
* SDK's internal event-name module.
|
|
1308
|
+
*/
|
|
1309
|
+
abstract hangup(): Promise<void>;
|
|
1310
|
+
getRemoteStream(): MediaStream | null;
|
|
1311
|
+
sendMessage(message: VoiceProviderMessage): string | null;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Concrete (newable) constructor signature for provider implementations.
|
|
1315
|
+
* BaseVoiceProvider is abstract so `typeof BaseVoiceProvider` cannot be `new`-ed directly.
|
|
1316
|
+
*
|
|
1317
|
+
* `type` MUST be a non-empty string — it's the registry key used by
|
|
1318
|
+
* `addVoiceProviderType()` / `getVoiceProviderType()` to dispatch incoming
|
|
1319
|
+
* `voip_provider` values from the server to the right provider class.
|
|
1320
|
+
*/
|
|
1321
|
+
type VoiceProviderConstructor = (new (events: EventManager, state: VoiceCallResponse, issueVoiceToken: IssueVoiceTokenMethod) => BaseVoiceProvider) & {
|
|
1322
|
+
type: string;
|
|
1323
|
+
};
|
|
1324
|
+
declare const addVoiceProviderType: (Provider: VoiceProviderConstructor) => void;
|
|
1325
|
+
declare const getVoiceProviderType: (type: string) => VoiceProviderConstructor | undefined;
|
|
1326
|
+
|
|
1327
|
+
declare const COBROWSE_EVENTS: {
|
|
1328
|
+
readonly LOADED: "cobrowse.loaded";
|
|
1329
|
+
readonly UPDATED: "cobrowse.updated";
|
|
1330
|
+
readonly ENDED: "cobrowse.ended";
|
|
1331
|
+
};
|
|
1332
|
+
type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
|
|
1333
|
+
|
|
1334
|
+
export { AnotherTabVoiceCallError, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MessageRequest, type MessageResponse, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, ProviderError, ProviderType, type QuestionItem, type RateRequest, type RecordingOption, type RecordingPermission, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, UnknownVoiceError, type UserProfile, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform };
|