@trillet-ai/web-sdk 1.10.0 → 1.12.0
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/widget/index.d.ts +140 -4
- package/dist/widget/index.js +544 -89
- package/dist/widget/index.js.map +1 -1
- package/dist/widget.umd.js +41 -13
- package/dist/widget.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/widget/index.d.ts
CHANGED
|
@@ -2,6 +2,76 @@ import * as React from 'react';
|
|
|
2
2
|
import { TrilletRoomDetails } from '../server.js';
|
|
3
3
|
import { T as Transcript } from '../TranscriptManager-Bh-JJm_m.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Built-in widget copy per language.
|
|
7
|
+
*
|
|
8
|
+
* Every visitor-facing string the widget renders on its own lives here, so a site in
|
|
9
|
+
* German, French or Italian gets a fully localised widget without setting a dozen
|
|
10
|
+
* text attributes. Explicit text attributes and the saved dashboard design still win
|
|
11
|
+
* over these defaults (see configFromElement).
|
|
12
|
+
*/
|
|
13
|
+
declare const WIDGET_LANGUAGES: readonly ["en", "de", "fr", "it"];
|
|
14
|
+
type WidgetLanguage = (typeof WIDGET_LANGUAGES)[number];
|
|
15
|
+
interface WidgetCopy {
|
|
16
|
+
startCallText: string;
|
|
17
|
+
startChatText: string;
|
|
18
|
+
endCallText: string;
|
|
19
|
+
endChatText: string;
|
|
20
|
+
endConversationText: string;
|
|
21
|
+
messageText: string;
|
|
22
|
+
callLabel: string;
|
|
23
|
+
chatLabel: string;
|
|
24
|
+
switchToTextText: string;
|
|
25
|
+
switchToVoiceText: string;
|
|
26
|
+
listeningText: string;
|
|
27
|
+
speakingText: string;
|
|
28
|
+
expandText: string;
|
|
29
|
+
collapseText: string;
|
|
30
|
+
recaptchaText: string;
|
|
31
|
+
inputPlaceholder: string;
|
|
32
|
+
askAnything: string;
|
|
33
|
+
/** `{name}` is replaced with the agent or brand name. */
|
|
34
|
+
askNamed: string;
|
|
35
|
+
chooseModePrompt: string;
|
|
36
|
+
talkToUs: string;
|
|
37
|
+
connecting: string;
|
|
38
|
+
online: string;
|
|
39
|
+
callEnded: string;
|
|
40
|
+
chatEnded: string;
|
|
41
|
+
startNewChat: string;
|
|
42
|
+
/** Always-reachable reset action, live or ended — distinct from "end call". */
|
|
43
|
+
startOver: string;
|
|
44
|
+
backToChat: string;
|
|
45
|
+
/** `{name}` is replaced with the agent or brand name. */
|
|
46
|
+
chatWithNamed: string;
|
|
47
|
+
chat: string;
|
|
48
|
+
send: string;
|
|
49
|
+
close: string;
|
|
50
|
+
typing: string;
|
|
51
|
+
muteMic: string;
|
|
52
|
+
unmuteMic: string;
|
|
53
|
+
terms: string;
|
|
54
|
+
termsTitle: string;
|
|
55
|
+
termsAccept: string;
|
|
56
|
+
termsDecline: string;
|
|
57
|
+
feedbackQuestion: string;
|
|
58
|
+
feedbackThanks: string;
|
|
59
|
+
errorNotEnabled: string;
|
|
60
|
+
errorUnavailable: string;
|
|
61
|
+
errorTooMany: string;
|
|
62
|
+
errorGeneric: string;
|
|
63
|
+
feedbackGood: string;
|
|
64
|
+
feedbackBad: string;
|
|
65
|
+
openChat: string;
|
|
66
|
+
minimize: string;
|
|
67
|
+
typeInstead: string;
|
|
68
|
+
showConversation: string;
|
|
69
|
+
talkInstead: string;
|
|
70
|
+
/** Pre-call dynamic-variables form. */
|
|
71
|
+
continueText: string;
|
|
72
|
+
fieldRequired: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
5
75
|
type WidgetVariant = 'compact' | 'expanded';
|
|
6
76
|
type WidgetVariantInput = WidgetVariant | 'tiny' | 'full';
|
|
7
77
|
type WidgetMode = 'voice' | 'text' | 'both';
|
|
@@ -38,6 +108,25 @@ interface RemoteWidgetConfig {
|
|
|
38
108
|
startCallText?: string | null;
|
|
39
109
|
messageText?: string | null;
|
|
40
110
|
suggestedPrompts?: string[];
|
|
111
|
+
/** Widget UI language (en | de | fr | it). Absent: the host page's <html lang>. */
|
|
112
|
+
language?: string | null;
|
|
113
|
+
/**
|
|
114
|
+
* Variables collected before a call starts, as the dashboard saves them: 'preset'
|
|
115
|
+
* entries carry a fixed value, 'prompt' entries are asked of the visitor. This is
|
|
116
|
+
* what GET /web-call/public/widget-config serves inside `widget`; the widget splits
|
|
117
|
+
* it locally (see splitDynamicVariableDefs).
|
|
118
|
+
*
|
|
119
|
+
* Note these are public: the config endpoint is unauthenticated, so a preset value
|
|
120
|
+
* is readable by anyone and must never hold a secret.
|
|
121
|
+
*/
|
|
122
|
+
dynamicVariables?: DynamicVariableDef[];
|
|
123
|
+
}
|
|
124
|
+
/** A visitor-facing "ask user" dynamic variable, collected before a call starts. */
|
|
125
|
+
interface DynamicVariablePrompt {
|
|
126
|
+
key: string;
|
|
127
|
+
label?: string;
|
|
128
|
+
placeholder?: string;
|
|
129
|
+
required?: boolean;
|
|
41
130
|
}
|
|
42
131
|
interface WidgetBrand {
|
|
43
132
|
logo?: string;
|
|
@@ -71,6 +160,9 @@ interface WidgetConfig {
|
|
|
71
160
|
variant: WidgetVariant;
|
|
72
161
|
placement: WidgetPlacement;
|
|
73
162
|
dismissible: boolean;
|
|
163
|
+
/** Resolved UI language and its built-in copy (see ./i18n). */
|
|
164
|
+
language: WidgetLanguage;
|
|
165
|
+
copy: WidgetCopy;
|
|
74
166
|
actionText?: string;
|
|
75
167
|
startCallText: string;
|
|
76
168
|
endCallText: string;
|
|
@@ -101,6 +193,13 @@ interface WidgetConfig {
|
|
|
101
193
|
feedback: 'none' | 'end';
|
|
102
194
|
mode: WidgetMode;
|
|
103
195
|
variables?: Record<string, unknown>;
|
|
196
|
+
/**
|
|
197
|
+
* Fixed values for "preset" dynamic variables, sent with every conversation. Not a
|
|
198
|
+
* place for secrets: they reach the browser and are readable by the visitor.
|
|
199
|
+
*/
|
|
200
|
+
dynamicVariablePresets: Record<string, string>;
|
|
201
|
+
/** "Ask user" dynamic variables; the widget renders a form for these before a call starts. */
|
|
202
|
+
dynamicVariablePrompts: DynamicVariablePrompt[];
|
|
104
203
|
maxCallDuration?: number;
|
|
105
204
|
/**
|
|
106
205
|
* Optional Google reCAPTCHA v2 site key. When set, the widget renders a checkbox the
|
|
@@ -115,6 +214,19 @@ interface WidgetConfig {
|
|
|
115
214
|
disableBanner: boolean;
|
|
116
215
|
brand: WidgetBrand;
|
|
117
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* A single dynamic-variable definition — the same preset/ask-user shape the Widget
|
|
219
|
+
* Studio and the demo-link editor both save (see trillet-backend's widgetConfig.js).
|
|
220
|
+
* Arrives either on the `dynamic-variable-defs` attribute or inside the saved design.
|
|
221
|
+
*/
|
|
222
|
+
interface DynamicVariableDef {
|
|
223
|
+
key: string;
|
|
224
|
+
mode: 'preset' | 'prompt';
|
|
225
|
+
value?: string;
|
|
226
|
+
label?: string;
|
|
227
|
+
placeholder?: string;
|
|
228
|
+
required?: boolean;
|
|
229
|
+
}
|
|
118
230
|
|
|
119
231
|
interface TrilletWidgetProps {
|
|
120
232
|
agentId: string;
|
|
@@ -152,6 +264,10 @@ interface TrilletWidgetProps {
|
|
|
152
264
|
actionText?: string;
|
|
153
265
|
startCallText?: string;
|
|
154
266
|
endCallText?: string;
|
|
267
|
+
/** Label for ending a text chat (default from `language`, e.g. "End chat" / "Chat beenden"). */
|
|
268
|
+
endChatText?: string;
|
|
269
|
+
/** UI language for the built-in labels: en | de | fr | it. Default: the page's <html lang>. */
|
|
270
|
+
language?: string;
|
|
155
271
|
/** Label for the text/chat entry point in mode="both" (default "Message"). */
|
|
156
272
|
messageText?: string;
|
|
157
273
|
switchToTextText?: string;
|
|
@@ -255,6 +371,15 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
255
371
|
startConversation(modality?: ActiveMode): Promise<void>;
|
|
256
372
|
/** Imperatively end the active conversation. Primary headless API. */
|
|
257
373
|
endConversation(): void;
|
|
374
|
+
/**
|
|
375
|
+
* Fully reset: tear down any live session (without dispatching its end-of-call
|
|
376
|
+
* events — this isn't "the conversation ended", it's "forget it happened"), wipe the
|
|
377
|
+
* transcript, and start a brand new one. Reachable at any time, live or already
|
|
378
|
+
* ended — unlike {@link endConversation}, which keeps the transcript visible, this
|
|
379
|
+
* always lands back in a fresh pre-call state so quick-question suggestions and the
|
|
380
|
+
* dynamic-variables form (if configured) reappear.
|
|
381
|
+
*/
|
|
382
|
+
startOver(modality?: ActiveMode): void;
|
|
258
383
|
/** @deprecated Use {@link startConversation}. Kept as a thin alias for back-compat. */
|
|
259
384
|
startCall(): Promise<void>;
|
|
260
385
|
/** @deprecated Use {@link endConversation}. Kept as a thin alias for back-compat. */
|
|
@@ -282,6 +407,7 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
282
407
|
private flushPending;
|
|
283
408
|
private notice;
|
|
284
409
|
private switchingSide;
|
|
410
|
+
private callGeneration;
|
|
285
411
|
private beginCall;
|
|
286
412
|
private wireAgentEvents;
|
|
287
413
|
private endLocalCall;
|
|
@@ -325,6 +451,9 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
325
451
|
private termsAccepted;
|
|
326
452
|
private termsAcceptedThisPage;
|
|
327
453
|
private renderTerms;
|
|
454
|
+
private showVariablesForm;
|
|
455
|
+
private dynamicVariableValues;
|
|
456
|
+
private renderVariablesForm;
|
|
328
457
|
/** "How was this conversation?" thumbs, once, after a conversation ends. */
|
|
329
458
|
private renderFeedback;
|
|
330
459
|
/**
|
|
@@ -341,9 +470,11 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
341
470
|
/** Suggested questions just above the ask bar while it has focus. */
|
|
342
471
|
private renderAskSuggestions;
|
|
343
472
|
/**
|
|
344
|
-
* Open the panel. A text-only widget
|
|
345
|
-
* welcome is already there when the panel opens, like
|
|
346
|
-
* waits for the visitor to pick call or message.
|
|
473
|
+
* Open the panel. A text-only widget with no prior conversation starts the chat
|
|
474
|
+
* straight away, so the agent's welcome is already there when the panel opens, like
|
|
475
|
+
* any website chat. `both` waits for the visitor to pick call or message. Reopening
|
|
476
|
+
* never clears anything on its own — an ended conversation's transcript stays put
|
|
477
|
+
* until the visitor explicitly starts over (see {@link startOver}).
|
|
347
478
|
*/
|
|
348
479
|
private openPanel;
|
|
349
480
|
private renderPanel;
|
|
@@ -358,7 +489,12 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
358
489
|
private renderHeader;
|
|
359
490
|
/** Start, call and gate screens centre a large avatar in the body. */
|
|
360
491
|
private bodyShowsLargeAvatar;
|
|
361
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* True when a `both` widget is idle/ended with no modality chosen and nothing to
|
|
494
|
+
* show. A finished conversation keeps its thread on screen instead, so ending a call
|
|
495
|
+
* never hides what was said; the choose-how-to-talk entry comes back only once the
|
|
496
|
+
* visitor starts over.
|
|
497
|
+
*/
|
|
362
498
|
private isBothPreCall;
|
|
363
499
|
/** True when a site key is configured and this session has not solved it yet. */
|
|
364
500
|
private needsRecaptcha;
|