@nlxai/touchpoint-ui 1.2.6 → 1.2.7-alpha.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/build/App.d.ts +20 -0
- package/build/ProviderStack.d.ts +10 -0
- package/build/assets/index-B9Yzt2if.js +233 -0
- package/build/assets/index-BbXI3y3Q.css +1 -0
- package/build/bidirectional/analyzePageForms.d.ts +35 -0
- package/build/bidirectional/automaticContext.d.ts +12 -0
- package/build/bidirectional/commandHandler.d.ts +5 -0
- package/build/bidirectional/debug.d.ts +1 -0
- package/build/components/ErrorMessage.d.ts +4 -0
- package/build/components/FeedbackComment.d.ts +6 -0
- package/build/components/FullscreenError.d.ts +2 -0
- package/build/components/FullscreenVoice.d.ts +32 -0
- package/build/components/Header.d.ts +20 -0
- package/build/components/Input.d.ts +14 -0
- package/build/components/Layout.d.ts +23 -0
- package/build/components/Messages.d.ts +33 -0
- package/build/components/Notice.d.ts +4 -0
- package/build/components/Ripple.d.ts +9 -0
- package/build/components/RiveAnimation.d.ts +4 -0
- package/build/components/SafeMarkdown.d.ts +4 -0
- package/build/components/Settings.d.ts +10 -0
- package/build/components/Theme.d.ts +4 -0
- package/build/components/VoiceMini.d.ts +13 -0
- package/build/components/VoiceModalities.d.ts +11 -0
- package/build/components/defaultModalities/DefaultCard.d.ts +3 -0
- package/build/components/defaultModalities/DefaultCarousel.d.ts +6 -0
- package/build/components/defaultModalities/DefaultDateInput.d.ts +5 -0
- package/build/components/defaultModalities/shared.d.ts +20 -0
- package/build/components/ui/Carousel.d.ts +26 -0
- package/build/components/ui/CustomCard.d.ts +101 -0
- package/build/components/ui/DateInput.d.ts +30 -0
- package/build/components/ui/IconButton.d.ts +68 -0
- package/build/components/ui/Icons.d.ts +63 -0
- package/build/components/ui/LaunchButton.d.ts +13 -0
- package/build/components/ui/LightDarkToggle.d.ts +47 -0
- package/build/components/ui/Loader.d.ts +7 -0
- package/build/components/ui/MessageButton.d.ts +58 -0
- package/build/components/ui/PicturesContainer.d.ts +9 -0
- package/build/components/ui/Radio.d.ts +14 -0
- package/build/components/ui/TextButton.d.ts +46 -0
- package/build/components/ui/Typography.d.ts +29 -0
- package/build/components/ui/ViewMediaModal.d.ts +8 -0
- package/build/design-system.d.ts +1 -0
- package/build/favicon.ico +0 -0
- package/build/feedback.d.ts +38 -0
- package/build/index.d.ts +63 -0
- package/build/index.html +13 -0
- package/build/interface.d.ts +569 -0
- package/build/mocks/MockText.d.ts +10 -0
- package/build/mocks/MockVoice.d.ts +10 -0
- package/build/mocks/MockVoiceMini.d.ts +8 -0
- package/build/mocks/shared.d.ts +5 -0
- package/build/preview.d.ts +10 -0
- package/build/types.d.ts +5 -0
- package/build/utils/useAppRoot.d.ts +3 -0
- package/build/utils/useCopy.d.ts +4 -0
- package/build/utils/useTailwindMediaQuery.d.ts +1 -0
- package/build/voice.d.ts +70 -0
- package/index.html +43 -47
- package/lib/ProviderStack.d.ts +0 -21
- package/lib/components/FullscreenVoice.d.ts +4 -6
- package/lib/components/Layout.d.ts +23 -0
- package/lib/components/VoiceModalities.d.ts +11 -0
- package/lib/components/defaultModalities/index.d.ts +2 -0
- package/lib/components/ui/Radio.d.ts +14 -0
- package/lib/design-system/LightDarkToggle.d.ts +50 -0
- package/lib/design-system/index.d.ts +1 -0
- package/lib/index.js +11516 -11445
- package/lib/index.umd.js +82 -82
- package/lib/mocks/MockText.d.ts +10 -0
- package/lib/mocks/MockVoice.d.ts +10 -0
- package/lib/mocks/MockVoiceMini.d.ts +8 -0
- package/lib/mocks/shared.d.ts +5 -0
- package/package.json +3 -2
- package/vite.config.ts +61 -32
- package/lib/design-system.d.ts +0 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { Config, ApplicationMessage, ConversationHandler, Context } from '@nlxai/core';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { InteractiveElementInfo } from './bidirectional/analyzePageForms';
|
|
4
|
+
/**
|
|
5
|
+
* Window size configuration
|
|
6
|
+
* @inline @hidden
|
|
7
|
+
*/
|
|
8
|
+
export type WindowSize = "half" | "full";
|
|
9
|
+
/**
|
|
10
|
+
* Color mode configuration (light/dark modes)
|
|
11
|
+
* @inline @hidden
|
|
12
|
+
*/
|
|
13
|
+
export type ColorMode = "light" | "dark" | "light dark";
|
|
14
|
+
/**
|
|
15
|
+
* Choice message with metadata
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface ChoiceMessage {
|
|
19
|
+
/**
|
|
20
|
+
* Message contents
|
|
21
|
+
*/
|
|
22
|
+
message: ApplicationMessage;
|
|
23
|
+
/**
|
|
24
|
+
* Index in the response transcript history
|
|
25
|
+
*/
|
|
26
|
+
responseIndex: number;
|
|
27
|
+
/**
|
|
28
|
+
* Message index in the current response
|
|
29
|
+
*/
|
|
30
|
+
messageIndex: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Custom Modalities allow rendering of rich user interfaces directly inside a conversation.
|
|
34
|
+
* A custom modality component is a React component. It will receive the modality data as a
|
|
35
|
+
* `data` prop, along with the conversation handler instance to interact with the conversation as
|
|
36
|
+
* `conversationHandler` prop.
|
|
37
|
+
* @category Modality components
|
|
38
|
+
* @typeParam Data - The type of the modality being rendered by this component.
|
|
39
|
+
*/
|
|
40
|
+
export type CustomModalityComponent<Data> = ComponentType<{
|
|
41
|
+
/**
|
|
42
|
+
* The payload of the Custom Modality. The schema is defined in Dialog Studio settings.
|
|
43
|
+
*/
|
|
44
|
+
data: Data;
|
|
45
|
+
/**
|
|
46
|
+
* Conversation handler instance
|
|
47
|
+
*/
|
|
48
|
+
conversationHandler: ConversationHandler;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the component is enabled
|
|
51
|
+
* We should probably use context and handle disabling interactive components automatically for the user
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Class name to propagate to the container
|
|
57
|
+
*/
|
|
58
|
+
className?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Tells the component whether it is rendered as an overlay over other elements. In this case, the class `backdrop-blur-overlay` is required
|
|
61
|
+
* on transparent elements in order to make sure its contents remain visible.
|
|
62
|
+
*/
|
|
63
|
+
renderedAsOverlay?: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom conversation init method. Defaults to sending the welcome intent
|
|
67
|
+
* @param handler - the conversation handler.
|
|
68
|
+
* @param context - context set via TouchpointConfiguration.initialContext
|
|
69
|
+
* @inline @hidden
|
|
70
|
+
*/
|
|
71
|
+
export type InitializeConversation = (handler: ConversationHandler, context?: Context) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Fully custom launch icon
|
|
74
|
+
* @inline @hidden
|
|
75
|
+
*/
|
|
76
|
+
export type CustomLaunchButton = ComponentType<{
|
|
77
|
+
/**
|
|
78
|
+
* Class name injected into the component mainly to take care of positioning and z-index. Can be combined with more presentational and sizing-related class names.
|
|
79
|
+
*/
|
|
80
|
+
className?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Click handler that expands Touchpoint, without the caller having to implement this based on Touchpoint instance methods.
|
|
83
|
+
*/
|
|
84
|
+
onClick?: () => void;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Input type for the experience
|
|
88
|
+
* @inline @hidden
|
|
89
|
+
*/
|
|
90
|
+
export type Input = "text" | "voice" | "voiceMini" | "external";
|
|
91
|
+
/**
|
|
92
|
+
* Input field value
|
|
93
|
+
* @inline @hidden
|
|
94
|
+
*/
|
|
95
|
+
export interface InputField {
|
|
96
|
+
/**
|
|
97
|
+
* Field ID
|
|
98
|
+
*/
|
|
99
|
+
id: string;
|
|
100
|
+
/**
|
|
101
|
+
* Field value
|
|
102
|
+
*/
|
|
103
|
+
value: string | boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Internal state that the automatic context maintains.
|
|
107
|
+
* @category Bidirectional Voice+
|
|
108
|
+
*/
|
|
109
|
+
export interface PageState {
|
|
110
|
+
/** Mapping from form element IDs to their DOM elements */
|
|
111
|
+
formElements: Record<string, Element>;
|
|
112
|
+
/** Mapping from link element names to their URLs */
|
|
113
|
+
links: Record<string, string>;
|
|
114
|
+
/** Mapping from custom commands to their handlers */
|
|
115
|
+
customCommands: Map<string, (arg: any) => void>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Bidirectional context information that is sent to the LLM.
|
|
119
|
+
* @category Bidirectional Voice+
|
|
120
|
+
*/
|
|
121
|
+
export interface BidirectionalContext {
|
|
122
|
+
/** Identifier for which page you are currently on. This can be used to filter the relevant KB pages. */
|
|
123
|
+
uri?: string;
|
|
124
|
+
/** The active form fields that can be filled in. */
|
|
125
|
+
fields?: InteractiveElementInfo[];
|
|
126
|
+
/** Human readable location names that can be navigated to. */
|
|
127
|
+
destinations?: string[];
|
|
128
|
+
/**
|
|
129
|
+
* Custom actions that can be performed.
|
|
130
|
+
*/
|
|
131
|
+
actions?: Array<{
|
|
132
|
+
/** The name of the command, used to invoke it. */
|
|
133
|
+
action: string;
|
|
134
|
+
/** A short description of the command */
|
|
135
|
+
description?: string;
|
|
136
|
+
/** A schema for validating the command's input. Should follow the JSON Schema specification. */
|
|
137
|
+
schema?: any;
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Configuration for bidirectional mode of voice+.
|
|
142
|
+
* @category Bidirectional Voice+
|
|
143
|
+
*/
|
|
144
|
+
export type BidirectionalConfig = {
|
|
145
|
+
/**
|
|
146
|
+
* Attempt to gather and send page context automatically. This will work well on semantically coded pages without too many custom form controls.
|
|
147
|
+
* This enables a number of automatic features.
|
|
148
|
+
*
|
|
149
|
+
* Defaults to `true`.
|
|
150
|
+
*/
|
|
151
|
+
automaticContext?: true;
|
|
152
|
+
/**
|
|
153
|
+
* Navigation handler for bidirectional mode.
|
|
154
|
+
*
|
|
155
|
+
* The default implementation will navigate to those pages using standard `window.location` APIs.
|
|
156
|
+
* @param action - The navigation action to perform.
|
|
157
|
+
* @param destination - The name of the destination to navigate to if `action` is `"page_custom"`.
|
|
158
|
+
* @param destinations - A map of destination names to URLs for custom navigation.
|
|
159
|
+
*/
|
|
160
|
+
navigation?: (action: "page_next" | "page_previous" | "page_custom" | "page_unknown", destination: string | undefined, destinations: Record<string, string>) => void;
|
|
161
|
+
/**
|
|
162
|
+
* A callback for filling out form fields in bidirectional mode.
|
|
163
|
+
*
|
|
164
|
+
* The default implementation will fill out the form fields using standard DOM APIs.
|
|
165
|
+
* @param fields - An array of field objects with `id` and `value` properties.
|
|
166
|
+
* @param pageFields - A map of field IDs to DOM elements for custom form filling.
|
|
167
|
+
*/
|
|
168
|
+
input?: (fields: InputField[], pageFields: Record<string, Element>) => void;
|
|
169
|
+
/**
|
|
170
|
+
* A callback for custom actions in bidirectional mode.
|
|
171
|
+
* @param action - The custom name of your action.
|
|
172
|
+
* @param payload - The payload defined for the custom action.
|
|
173
|
+
* @deprecated Use {@link TouchpointInstance.setCustomBidirectionalCommands} instead.
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
custom?: (action: string, payload: unknown) => void;
|
|
177
|
+
/**
|
|
178
|
+
* A callback for customizing the automatic context gathering.
|
|
179
|
+
*
|
|
180
|
+
* This allows you to modify the context and state before they are sent to the LLM.
|
|
181
|
+
* @returns The modified context and state. If the state is identical to the previous state, the call to the server will be skipped.
|
|
182
|
+
*/
|
|
183
|
+
customizeAutomaticContext?: (arg: {
|
|
184
|
+
context: BidirectionalContext;
|
|
185
|
+
state: PageState;
|
|
186
|
+
}) => {
|
|
187
|
+
/**
|
|
188
|
+
* The current context being sent to the LLM
|
|
189
|
+
*/
|
|
190
|
+
context: BidirectionalContext;
|
|
191
|
+
/**
|
|
192
|
+
* The current state of the page - this is stuff not sent to the LLM, but needed to connect the results back to actions to take on the page.
|
|
193
|
+
*/
|
|
194
|
+
state: PageState;
|
|
195
|
+
};
|
|
196
|
+
} | {
|
|
197
|
+
/**
|
|
198
|
+
* Disable gathering page context automatically.
|
|
199
|
+
*/
|
|
200
|
+
automaticContext: false;
|
|
201
|
+
/**
|
|
202
|
+
* Navigation handler for bidirectional mode. Without automatic context there is no default implementation.
|
|
203
|
+
* @param action - The navigation action to perform.
|
|
204
|
+
* @param destination - The name of the destination to navigate to if `action` is `"page_custom"`.
|
|
205
|
+
*/
|
|
206
|
+
navigation?: (action: "page_next" | "page_previous" | "page_custom" | "page_unknown", destination?: string) => void;
|
|
207
|
+
/**
|
|
208
|
+
* A callback for filling out form fields in bidirectional mode. Without automatic context there is no default implementation.
|
|
209
|
+
* @param fields - An array of field objects with `id` and `value` properties.
|
|
210
|
+
*/
|
|
211
|
+
input?: (fields: InputField[]) => void;
|
|
212
|
+
/**
|
|
213
|
+
* A callback for custom actions in bidirectional mode.
|
|
214
|
+
* @param action - The custom name of your action.
|
|
215
|
+
* @param payload - The payload defined for the custom action.
|
|
216
|
+
*/
|
|
217
|
+
custom?: (action: string, payload: unknown) => void;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Main Touchpoint creation properties object
|
|
221
|
+
* @category Basics
|
|
222
|
+
*/
|
|
223
|
+
export interface TouchpointConfiguration {
|
|
224
|
+
/**
|
|
225
|
+
* Connection information for the \@nlxai/core conversation handler
|
|
226
|
+
*/
|
|
227
|
+
config: Config;
|
|
228
|
+
/**
|
|
229
|
+
* Optional window size for the chat window, defaults to `half`
|
|
230
|
+
*/
|
|
231
|
+
windowSize?: WindowSize;
|
|
232
|
+
/**
|
|
233
|
+
* Optional color mode for the chat window, defaults to `dark`. Setting `light dark` enables automatic switching based on system settings.
|
|
234
|
+
*/
|
|
235
|
+
colorMode?: ColorMode;
|
|
236
|
+
/**
|
|
237
|
+
* URL of icon used to display the brand in the chat header
|
|
238
|
+
*/
|
|
239
|
+
brandIcon?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Include border animation. Currently only supported in Voice Mini.
|
|
242
|
+
*/
|
|
243
|
+
animate?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* URL of icon used on the launch icon in the bottom right when the experience is collapsed.
|
|
246
|
+
*
|
|
247
|
+
* When set to `false`, no launch button is shown at all. When not set or set to `true`, the default launch icon is rendered.
|
|
248
|
+
*/
|
|
249
|
+
launchIcon?: string | boolean | CustomLaunchButton;
|
|
250
|
+
/**
|
|
251
|
+
* Specifies whether the user message has bubbles or not
|
|
252
|
+
*/
|
|
253
|
+
userMessageBubble?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Specifies whether the agent message has bubbles or not
|
|
256
|
+
*/
|
|
257
|
+
agentMessageBubble?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Enables chat mode, a classic chat experience with inline loaders and the chat history visible at all times.
|
|
260
|
+
*/
|
|
261
|
+
chatMode?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Optional theme object to override default theme values
|
|
264
|
+
*/
|
|
265
|
+
theme?: Partial<Theme>;
|
|
266
|
+
/**
|
|
267
|
+
* Optional {@link CustomModalityComponent | custom modality components} to render in Touchpoint
|
|
268
|
+
*/
|
|
269
|
+
modalityComponents?: Record<string, CustomModalityComponent<unknown>>;
|
|
270
|
+
/**
|
|
271
|
+
* Optional custom modality components to render in Touchpoint
|
|
272
|
+
* @deprecated use {@link TouchpointConfiguration.modalityComponents} instead.
|
|
273
|
+
* @hidden
|
|
274
|
+
*/
|
|
275
|
+
customModalities?: Record<string, CustomModalityComponent<unknown>>;
|
|
276
|
+
/**
|
|
277
|
+
* Custom conversation init method. Defaults to sending the welcome flow.
|
|
278
|
+
* @param handler - the conversation handler.
|
|
279
|
+
* @param context - the context object
|
|
280
|
+
*/
|
|
281
|
+
initializeConversation?: InitializeConversation;
|
|
282
|
+
/**
|
|
283
|
+
* Controls the ways in which the user can communicate with the application. Defaults to `"text"`
|
|
284
|
+
*/
|
|
285
|
+
input?: Input;
|
|
286
|
+
/**
|
|
287
|
+
* Sets whether the transcript is shown in `voice` and `voiceMini` inputs.
|
|
288
|
+
*/
|
|
289
|
+
showVoiceTranscript?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Context sent with the initial request.
|
|
292
|
+
*/
|
|
293
|
+
initialContext?: Context;
|
|
294
|
+
/**
|
|
295
|
+
* Enables bidirectional mode of voice+. Will automatically set the bidirectional flag in the config.
|
|
296
|
+
*
|
|
297
|
+
*/
|
|
298
|
+
bidirectional?: BidirectionalConfig;
|
|
299
|
+
/**
|
|
300
|
+
* Copy
|
|
301
|
+
*/
|
|
302
|
+
copy?: Partial<Copy>;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The full theme expressed as CSS custom properties.
|
|
306
|
+
* This means that for instance colors can be made to switch automatically based on the system color mode by using the `light-dark()` CSS function.
|
|
307
|
+
* Note also that not all colors need to be provided manually. For instance if only `primary` is provided, the rest of the primary colors will be computed automatically based on it.
|
|
308
|
+
* Therefore, for a fully custom but minimal theme, you only need to provide `accent`, `primary`, `secondary`, `background`, `overlay`, and potentially the warning and error colors.
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const theme : Partial<Theme> = {
|
|
312
|
+
* primary: "light-dark(rgb(0, 2, 9), rgb(255, 255, 255))",
|
|
313
|
+
* secondary: "light-dark(rgb(255, 255, 255), rgb(0, 2, 9))",
|
|
314
|
+
* accent: "light-dark(rgb(28, 99, 218), rgb(174, 202, 255))",
|
|
315
|
+
* background: "light-dark(rgba(220, 220, 220, 0.9), rgba(0, 2, 9, 0.9))",
|
|
316
|
+
* }
|
|
317
|
+
* ```
|
|
318
|
+
* @category Theming
|
|
319
|
+
*/
|
|
320
|
+
export interface Theme {
|
|
321
|
+
/**
|
|
322
|
+
* Font family
|
|
323
|
+
*/
|
|
324
|
+
fontFamily: string;
|
|
325
|
+
/**
|
|
326
|
+
* Primary color
|
|
327
|
+
*/
|
|
328
|
+
primary: string;
|
|
329
|
+
/**
|
|
330
|
+
* Primary color with 90% opacity
|
|
331
|
+
*/
|
|
332
|
+
primary90: string;
|
|
333
|
+
/**
|
|
334
|
+
* Primary color with 80% opacity
|
|
335
|
+
*/
|
|
336
|
+
primary80: string;
|
|
337
|
+
/**
|
|
338
|
+
* Primary color with 60% opacity
|
|
339
|
+
*/
|
|
340
|
+
primary60: string;
|
|
341
|
+
/**
|
|
342
|
+
* Primary color with 40% opacity
|
|
343
|
+
*/
|
|
344
|
+
primary40: string;
|
|
345
|
+
/**
|
|
346
|
+
* Primary color with 20% opacity
|
|
347
|
+
*/
|
|
348
|
+
primary20: string;
|
|
349
|
+
/**
|
|
350
|
+
* Primary color with 10% opacity
|
|
351
|
+
*/
|
|
352
|
+
primary10: string;
|
|
353
|
+
/**
|
|
354
|
+
* Primary color with 5% opacity
|
|
355
|
+
*/
|
|
356
|
+
primary5: string;
|
|
357
|
+
/**
|
|
358
|
+
* Primary color with 1% opacity
|
|
359
|
+
*/
|
|
360
|
+
primary1: string;
|
|
361
|
+
/**
|
|
362
|
+
* Secondary color
|
|
363
|
+
*/
|
|
364
|
+
secondary: string;
|
|
365
|
+
/**
|
|
366
|
+
* Secondary color with 90% opacity
|
|
367
|
+
*/
|
|
368
|
+
secondary90: string;
|
|
369
|
+
/**
|
|
370
|
+
* Secondary color with 80% opacity
|
|
371
|
+
*/
|
|
372
|
+
secondary80: string;
|
|
373
|
+
/**
|
|
374
|
+
* Secondary color with 60% opacity
|
|
375
|
+
*/
|
|
376
|
+
secondary60: string;
|
|
377
|
+
/**
|
|
378
|
+
* Secondary color with 40% opacity
|
|
379
|
+
*/
|
|
380
|
+
secondary40: string;
|
|
381
|
+
/**
|
|
382
|
+
* Secondary color with 20% opacity
|
|
383
|
+
*/
|
|
384
|
+
secondary20: string;
|
|
385
|
+
/**
|
|
386
|
+
* Secondary color with 10% opacity
|
|
387
|
+
*/
|
|
388
|
+
secondary10: string;
|
|
389
|
+
/**
|
|
390
|
+
* Secondary color with 5% opacity
|
|
391
|
+
*/
|
|
392
|
+
secondary5: string;
|
|
393
|
+
/**
|
|
394
|
+
* Secondary color with 1% opacity
|
|
395
|
+
*/
|
|
396
|
+
secondary1: string;
|
|
397
|
+
/**
|
|
398
|
+
* Accent color used e.g. for prominent buttons, the loader animation as well as selected card outlines
|
|
399
|
+
*/
|
|
400
|
+
accent: string;
|
|
401
|
+
/**
|
|
402
|
+
* Accent color with 20% opacity
|
|
403
|
+
*/
|
|
404
|
+
accent20: string;
|
|
405
|
+
/**
|
|
406
|
+
* The background color of the main Touchpoint interface
|
|
407
|
+
*/
|
|
408
|
+
background: string;
|
|
409
|
+
/**
|
|
410
|
+
* The color of the overlay covering the visible portion of the website when the Touchpoint interface does not cover the full screen
|
|
411
|
+
*/
|
|
412
|
+
overlay: string;
|
|
413
|
+
/**
|
|
414
|
+
* Primary warning color
|
|
415
|
+
*/
|
|
416
|
+
warningPrimary: string;
|
|
417
|
+
/**
|
|
418
|
+
* Secondary warning color
|
|
419
|
+
*/
|
|
420
|
+
warningSecondary: string;
|
|
421
|
+
/**
|
|
422
|
+
* Primary error color
|
|
423
|
+
*/
|
|
424
|
+
errorPrimary: string;
|
|
425
|
+
/**
|
|
426
|
+
* Secondary error color
|
|
427
|
+
*/
|
|
428
|
+
errorSecondary: string;
|
|
429
|
+
/**
|
|
430
|
+
* Inner border radius: used for most buttons
|
|
431
|
+
*/
|
|
432
|
+
innerBorderRadius: string;
|
|
433
|
+
/**
|
|
434
|
+
* Outer border radius: generally used for elements that contain buttons that have inner border radius. Also used by the launch button.
|
|
435
|
+
*/
|
|
436
|
+
outerBorderRadius: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* During a Voice+ bidirectional conversation, you can indicate to the application the availability of
|
|
440
|
+
* custom commands that the user can invoke.
|
|
441
|
+
* @category Bidirectional Voice+
|
|
442
|
+
*/
|
|
443
|
+
export interface BidirectionalCustomCommand {
|
|
444
|
+
/**
|
|
445
|
+
* The name of the command, used to invoke it. Should be unique and descriptive in the context of the LLM.
|
|
446
|
+
*/
|
|
447
|
+
action: string;
|
|
448
|
+
/**
|
|
449
|
+
* A short description of the command, used to help the LLM understand its purpose.
|
|
450
|
+
*
|
|
451
|
+
* If omitted, then the command will not be sent to the application and must be triggered
|
|
452
|
+
* from the application side.
|
|
453
|
+
*/
|
|
454
|
+
description?: string;
|
|
455
|
+
/**
|
|
456
|
+
* A JSON Schema that defines the structure of the command's input.
|
|
457
|
+
*
|
|
458
|
+
* Use descriptive names and `description` fields to give the underlying LLM plenty of context for
|
|
459
|
+
* it to generate reasonable parameters. Note that the LLM output will be validated (and transformed)
|
|
460
|
+
* with this schema, so you are guaranteed type safe inputs to your handler.
|
|
461
|
+
*
|
|
462
|
+
* Should follow the JSONSchema specification.
|
|
463
|
+
*/
|
|
464
|
+
schema?: any;
|
|
465
|
+
/**
|
|
466
|
+
* Any additional input data that the LLM should have.
|
|
467
|
+
*/
|
|
468
|
+
input?: any;
|
|
469
|
+
/**
|
|
470
|
+
* A handler that will be called with an argument matching the schema when the command is invoked.
|
|
471
|
+
*/
|
|
472
|
+
handler: (value: any) => void;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Instance of a Touchpoint UI component
|
|
476
|
+
* @category Basics
|
|
477
|
+
*/
|
|
478
|
+
export interface TouchpointInstance {
|
|
479
|
+
/**
|
|
480
|
+
* Controls whether the Touchpoint UI is expanded or collapsed
|
|
481
|
+
*/
|
|
482
|
+
expanded: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* The conversation handler instance for interacting with the application
|
|
485
|
+
*/
|
|
486
|
+
conversationHandler: ConversationHandler;
|
|
487
|
+
/**
|
|
488
|
+
* Method to remove the Touchpoint UI from the DOM
|
|
489
|
+
*/
|
|
490
|
+
teardown: () => void;
|
|
491
|
+
/**
|
|
492
|
+
* Sets currently available custom bidirectional commands.
|
|
493
|
+
* This allows you to define custom commands that can be used in the voice bot.
|
|
494
|
+
* The commands will be available in the voice bot and can be used to trigger actions.
|
|
495
|
+
*
|
|
496
|
+
* Example:
|
|
497
|
+
* ```javascript
|
|
498
|
+
* client.setCustomBidirectionalCommands([
|
|
499
|
+
* {
|
|
500
|
+
* action: "Meal",
|
|
501
|
+
* description: "add a meal to your flight",
|
|
502
|
+
* schema: {
|
|
503
|
+
* enum: ["standard", "vegetarian", "vegan", "gluten-free"],
|
|
504
|
+
* },
|
|
505
|
+
* handler: (value) => {
|
|
506
|
+
* console.log("Meal option:", value);
|
|
507
|
+
* },
|
|
508
|
+
* },
|
|
509
|
+
* ]);
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* This will allow the voice bot to use the command `Meal` with the value `standard`, `vegetarian`, `vegan`, or `gluten-free`.
|
|
513
|
+
*
|
|
514
|
+
* When using more complex arguments, a library such as [Zod](https://zod.dev) can be useful:
|
|
515
|
+
*
|
|
516
|
+
* ```javascript
|
|
517
|
+
* import * as z from "zod/v4";
|
|
518
|
+
*
|
|
519
|
+
* const schema = z.object({
|
|
520
|
+
* "name": z.string().describe("The customer's name, such as John Doe"),
|
|
521
|
+
* "email": z.string().email().describe("The customer's email address"),
|
|
522
|
+
* });
|
|
523
|
+
*
|
|
524
|
+
* client.setCustomBidirectionalCommands([
|
|
525
|
+
* {
|
|
526
|
+
* action: "Meal",
|
|
527
|
+
* description: "add a meal to your flight",
|
|
528
|
+
* schema: z.toJSONSchema(schema, {io: "input"}),
|
|
529
|
+
* handler: (value) => {
|
|
530
|
+
* const result = z.safeParse(schema, value);
|
|
531
|
+
* if (result.success) {
|
|
532
|
+
* // result.data is now type safe and TypeScript can reason about it
|
|
533
|
+
* console.log("Meal option:", result.data);
|
|
534
|
+
* } else {
|
|
535
|
+
* console.error("Failed to parse Meal option:", result.error);
|
|
536
|
+
* }
|
|
537
|
+
* },
|
|
538
|
+
* },
|
|
539
|
+
* ]);
|
|
540
|
+
* ```
|
|
541
|
+
* @param commands - A list containing the custom commands to set.
|
|
542
|
+
*/
|
|
543
|
+
setCustomBidirectionalCommands: (commands: BidirectionalCustomCommand[]) => void;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Copy configuration
|
|
547
|
+
*/
|
|
548
|
+
export interface Copy {
|
|
549
|
+
/**
|
|
550
|
+
* Escalation attempt notice
|
|
551
|
+
*/
|
|
552
|
+
escalationAttemptNotice: string;
|
|
553
|
+
/**
|
|
554
|
+
* Escalation notice
|
|
555
|
+
*/
|
|
556
|
+
escalationNotice: string;
|
|
557
|
+
/**
|
|
558
|
+
* Restart conversation button label
|
|
559
|
+
*/
|
|
560
|
+
restartConversationButtonLabel: string;
|
|
561
|
+
/**
|
|
562
|
+
* Restart conversation button label
|
|
563
|
+
*/
|
|
564
|
+
escalationButtonLabel: string;
|
|
565
|
+
/**
|
|
566
|
+
* Send message button label
|
|
567
|
+
*/
|
|
568
|
+
sendMessageButtonLabel: string;
|
|
569
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { WindowSize, ColorMode } from '../interface';
|
|
3
|
+
export declare const MockText: FC<{
|
|
4
|
+
embedded: boolean;
|
|
5
|
+
colorMode?: ColorMode;
|
|
6
|
+
isExpanded: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onExpand: () => void;
|
|
9
|
+
windowSize: WindowSize;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { WindowSize, ColorMode } from '../interface';
|
|
3
|
+
export declare const MockVoice: FC<{
|
|
4
|
+
embedded: boolean;
|
|
5
|
+
colorMode?: ColorMode;
|
|
6
|
+
isExpanded: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onExpand: () => void;
|
|
9
|
+
windowSize: WindowSize;
|
|
10
|
+
}>;
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Config } from '@nlxai/core';
|
|
2
|
+
import { TouchpointConfiguration } from './interface';
|
|
3
|
+
export type NormalizedTouchpointConfiguration = TouchpointConfiguration & Required<Pick<TouchpointConfiguration, "initializeConversation" | "input">> & {
|
|
4
|
+
config: Required<Pick<Config, "conversationId" | "userId" | "bidirectional">>;
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTailwindMediaQuery: (queryPrefix: "sm" | "md" | "lg") => boolean | undefined;
|