@nlxai/touchpoint-ui 1.2.3-alpha.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1371 -7
- package/index.html +29 -167
- package/lib/bidirectional/analyzePageForms.d.ts +5 -1
- package/lib/components/FullscreenVoice.d.ts +1 -0
- package/lib/components/Ripple.d.ts +4 -0
- package/lib/components/ui/Carousel.d.ts +18 -0
- package/lib/components/ui/CustomCard.d.ts +47 -0
- package/lib/components/ui/DateInput.d.ts +15 -1
- package/lib/components/ui/IconButton.d.ts +20 -0
- package/lib/components/ui/TextButton.d.ts +17 -0
- package/lib/components/ui/Typography.d.ts +19 -0
- package/lib/index.d.ts +26 -2
- package/lib/index.js +1347 -1344
- package/lib/index.umd.js +33 -33
- package/lib/interface.d.ts +153 -127
- package/package.json +11 -6
- package/typedoc.cjs +19 -6
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Touchpoint UI provides a customizable chat interface that you can embed in your web applications. Touchpoint UI allows users to interact with your application and provides a seamless conversational experience.
|
|
4
4
|
|
|
5
|
+
```bash
|
|
6
|
+
npm i --save @nlxai/touchpoint-ui
|
|
7
|
+
```
|
|
8
|
+
|
|
5
9
|
```js
|
|
6
10
|
import { create } from "@nlxai/touchpoint-ui";
|
|
7
11
|
|
|
@@ -20,15 +24,1375 @@ const touchpoint = await create({
|
|
|
20
24
|
});
|
|
21
25
|
```
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
<!-- include docs/README.md -->
|
|
28
|
+
## Basics
|
|
29
|
+
|
|
30
|
+
### create()
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
function create(props): Promise<TouchpointInstance>;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Creates a new Touchpoint UI instance and appends it to the document body
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
##### props
|
|
41
|
+
|
|
42
|
+
[`TouchpointConfiguration`](#touchpointconfiguration)
|
|
43
|
+
|
|
44
|
+
Configuration props for Touchpoint
|
|
45
|
+
|
|
46
|
+
#### Returns
|
|
47
|
+
|
|
48
|
+
`Promise`\<[`TouchpointInstance`](#touchpointinstance)\>
|
|
49
|
+
|
|
50
|
+
A promise that resolves to a TouchpointInstance
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### TouchpointConfiguration
|
|
55
|
+
|
|
56
|
+
Main Touchpoint creation properties object
|
|
57
|
+
|
|
58
|
+
#### Properties
|
|
59
|
+
|
|
60
|
+
##### config
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
config: Config;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Connection information for the @nlxai/core conversation handler
|
|
67
|
+
|
|
68
|
+
##### windowSize?
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
optional windowSize: "full" | "half";
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Optional window size for the chat window, defaults to `half`
|
|
75
|
+
|
|
76
|
+
##### colorMode?
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
optional colorMode: "dark" | "light" | "light dark";
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Optional color mode for the chat window, defaults to `dark`. Setting `light dark` enables automatic switching based on system settings.
|
|
83
|
+
|
|
84
|
+
##### brandIcon?
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
optional brandIcon: string;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
URL of icon used to display the brand in the chat header
|
|
91
|
+
|
|
92
|
+
##### animate?
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
optional animate: boolean;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Include border animation. Currently only supported in Voice Mini.
|
|
99
|
+
|
|
100
|
+
##### launchIcon?
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
optional launchIcon:
|
|
104
|
+
| string
|
|
105
|
+
| boolean
|
|
106
|
+
|
|
|
107
|
+
| ComponentClass<{
|
|
108
|
+
className?: string;
|
|
109
|
+
onClick?: () => void;
|
|
110
|
+
}, any>
|
|
111
|
+
| FunctionComponent<{
|
|
112
|
+
className?: string;
|
|
113
|
+
onClick?: () => void;
|
|
114
|
+
}>;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
URL of icon used on the launch icon in the bottom right when the experience is collapsed.
|
|
118
|
+
|
|
119
|
+
When set to `false`, no launch button is shown at all. When not set or set to `true`, the default launch icon is rendered.
|
|
120
|
+
|
|
121
|
+
##### userMessageBubble?
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
optional userMessageBubble: boolean;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Specifies whether the user message has bubbles or not
|
|
128
|
+
|
|
129
|
+
##### agentMessageBubble?
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
optional agentMessageBubble: boolean;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Specifies whether the agent message has bubbles or not
|
|
136
|
+
|
|
137
|
+
##### chatMode?
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
optional chatMode: boolean;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Enables chat mode, a classic chat experience with inline loaders and the chat history visible at all times.
|
|
144
|
+
|
|
145
|
+
##### theme?
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
optional theme: Partial<Theme>;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Optional theme object to override default theme values
|
|
152
|
+
|
|
153
|
+
##### modalityComponents?
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
optional modalityComponents: Record<string, CustomModalityComponent<unknown>>;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Optional [custom modality components](#custommodalitycomponent) to render in Touchpoint
|
|
160
|
+
|
|
161
|
+
##### initializeConversation()?
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
optional initializeConversation: (handler, context?) => void;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Custom conversation init method. Defaults to sending the welcome flow.
|
|
168
|
+
|
|
169
|
+
###### Parameters
|
|
170
|
+
|
|
171
|
+
###### handler
|
|
172
|
+
|
|
173
|
+
`ConversationHandler`
|
|
174
|
+
|
|
175
|
+
the conversation handler.
|
|
176
|
+
|
|
177
|
+
###### context?
|
|
178
|
+
|
|
179
|
+
`Context`
|
|
180
|
+
|
|
181
|
+
the context object
|
|
182
|
+
|
|
183
|
+
###### Returns
|
|
184
|
+
|
|
185
|
+
`void`
|
|
186
|
+
|
|
187
|
+
##### input?
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
optional input: "text" | "voice" | "voiceMini";
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Controls the ways in which the user can communicate with the application. Defaults to `"text"`
|
|
194
|
+
|
|
195
|
+
##### initialContext?
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
optional initialContext: Context;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Context sent with the initial request.
|
|
202
|
+
|
|
203
|
+
##### bidirectional?
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
optional bidirectional: BidirectionalConfig;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Enables bidirectional mode of voice+. Will automatically set the bidirectional flag in the config.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### TouchpointInstance
|
|
214
|
+
|
|
215
|
+
Instance of a Touchpoint UI component
|
|
216
|
+
|
|
217
|
+
#### Properties
|
|
218
|
+
|
|
219
|
+
##### expanded
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
expanded: boolean;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Controls whether the Touchpoint UI is expanded or collapsed
|
|
226
|
+
|
|
227
|
+
##### conversationHandler
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
conversationHandler: ConversationHandler;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The conversation handler instance for interacting with the application
|
|
234
|
+
|
|
235
|
+
##### teardown()
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
teardown: () => void;
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Method to remove the Touchpoint UI from the DOM
|
|
242
|
+
|
|
243
|
+
###### Returns
|
|
244
|
+
|
|
245
|
+
`void`
|
|
246
|
+
|
|
247
|
+
##### setCustomBidirectionalCommands()
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
setCustomBidirectionalCommands: (commands) => void;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Sets currently available custom bidirectional commands.
|
|
254
|
+
This allows you to define custom commands that can be used in the voice bot.
|
|
255
|
+
The commands will be available in the voice bot and can be used to trigger actions.
|
|
256
|
+
|
|
257
|
+
Example:
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
client.setCustomBidirectionalCommands([
|
|
261
|
+
{
|
|
262
|
+
action: "Meal",
|
|
263
|
+
description: "add a meal to your flight",
|
|
264
|
+
schema: {
|
|
265
|
+
enum: ["standard", "vegetarian", "vegan", "gluten-free"],
|
|
266
|
+
},
|
|
267
|
+
handler: (value) => {
|
|
268
|
+
console.log("Meal option:", value);
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
]);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
This will allow the voice bot to use the command `Meal` with the value `standard`, `vegetarian`, `vegan`, or `gluten-free`.
|
|
275
|
+
|
|
276
|
+
When using more complex arguments, a library such as [Zod](https://zod.dev) can be useful:
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
import * as z from "zod/v4";
|
|
280
|
+
|
|
281
|
+
const schema = z.object({
|
|
282
|
+
name: z.string().describe("The customer's name, such as John Doe"),
|
|
283
|
+
email: z.string().email().describe("The customer's email address"),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
client.setCustomBidirectionalCommands([
|
|
287
|
+
{
|
|
288
|
+
action: "Meal",
|
|
289
|
+
description: "add a meal to your flight",
|
|
290
|
+
schema: z.toJSONSchema(schema, { io: "input" }),
|
|
291
|
+
handler: (value) => {
|
|
292
|
+
const result = z.safeParse(schema, value);
|
|
293
|
+
if (result.success) {
|
|
294
|
+
// result.data is now type safe and TypeScript can reason about it
|
|
295
|
+
console.log("Meal option:", result.data);
|
|
296
|
+
} else {
|
|
297
|
+
console.error("Failed to parse Meal option:", result.error);
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
]);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
###### Parameters
|
|
305
|
+
|
|
306
|
+
###### commands
|
|
307
|
+
|
|
308
|
+
[`BidirectionalCustomCommand`](#bidirectionalcustomcommand)[]
|
|
309
|
+
|
|
310
|
+
A list containing the custom commands to set.
|
|
311
|
+
|
|
312
|
+
###### Returns
|
|
313
|
+
|
|
314
|
+
`void`
|
|
315
|
+
|
|
316
|
+
## Theming
|
|
317
|
+
|
|
318
|
+
### Theme
|
|
319
|
+
|
|
320
|
+
The full theme expressed as CSS custom properties.
|
|
321
|
+
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.
|
|
322
|
+
Note also that not all colors need to be provided manually. For instance if only `primary80` is provided, the rest of the primary colors will be computed automatically based on it.
|
|
323
|
+
Therefore, for a fully custom but minimal theme, you only need to provide `accent`, `primary80`, `secondary80`, `background`, `overlay`, and potentially the warning and error colors.
|
|
324
|
+
|
|
325
|
+
#### Example
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
const theme: Partial<Theme> = {
|
|
329
|
+
primary80: "light-dark(rgba(0, 2, 9, 0.8), rgba(255, 255, 255, 0.8))",
|
|
330
|
+
secondary80: "light-dark(rgba(255, 255, 255, 0.8), rgba(0, 2, 9, 0.8))",
|
|
331
|
+
accent: "light-dark(rgb(28, 99, 218), rgb(174, 202, 255))",
|
|
332
|
+
background: "light-dark(rgba(220, 220, 220, 0.9), rgba(0, 2, 9, 0.9))",
|
|
333
|
+
};
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
#### Properties
|
|
337
|
+
|
|
338
|
+
##### fontFamily
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
fontFamily: string;
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Font family
|
|
345
|
+
|
|
346
|
+
##### primary80
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
primary80: string;
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Primary color with 80% opacity
|
|
353
|
+
|
|
354
|
+
##### primary60
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
primary60: string;
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Primary color with 60% opacity
|
|
361
|
+
|
|
362
|
+
##### primary40
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
primary40: string;
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Primary color with 40% opacity
|
|
369
|
+
|
|
370
|
+
##### primary20
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
primary20: string;
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Primary color with 20% opacity
|
|
377
|
+
|
|
378
|
+
##### primary10
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
primary10: string;
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Primary color with 10% opacity
|
|
385
|
+
|
|
386
|
+
##### primary5
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
primary5: string;
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Primary color with 5% opacity
|
|
393
|
+
|
|
394
|
+
##### primary1
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
primary1: string;
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Primary color with 1% opacity
|
|
401
|
+
|
|
402
|
+
##### secondary80
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
secondary80: string;
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Secondary color with 80% opacity
|
|
409
|
+
|
|
410
|
+
##### secondary60
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
secondary60: string;
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Secondary color with 60% opacity
|
|
417
|
+
|
|
418
|
+
##### secondary40
|
|
419
|
+
|
|
420
|
+
```ts
|
|
421
|
+
secondary40: string;
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Secondary color with 40% opacity
|
|
425
|
+
|
|
426
|
+
##### secondary20
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
secondary20: string;
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
Secondary color with 20% opacity
|
|
433
|
+
|
|
434
|
+
##### secondary10
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
secondary10: string;
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Secondary color with 10% opacity
|
|
441
|
+
|
|
442
|
+
##### secondary5
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
secondary5: string;
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Secondary color with 5% opacity
|
|
449
|
+
|
|
450
|
+
##### secondary1
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
secondary1: string;
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Secondary color with 1% opacity
|
|
457
|
+
|
|
458
|
+
##### accent
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
accent: string;
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Accent color used e.g. for prominent buttons, the loader animation as well as selected card outlines
|
|
465
|
+
|
|
466
|
+
##### accent20
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
accent20: string;
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Accent color with 20% opacity
|
|
473
|
+
|
|
474
|
+
##### background
|
|
475
|
+
|
|
476
|
+
```ts
|
|
477
|
+
background: string;
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
The background color of the main Touchpoint interface
|
|
481
|
+
|
|
482
|
+
##### overlay
|
|
483
|
+
|
|
484
|
+
```ts
|
|
485
|
+
overlay: string;
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
The color of the overlay covering the visible portion of the website when the Touchpoint interface does not cover the full screen
|
|
489
|
+
|
|
490
|
+
##### warningPrimary
|
|
491
|
+
|
|
492
|
+
```ts
|
|
493
|
+
warningPrimary: string;
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Primary warning color
|
|
497
|
+
|
|
498
|
+
##### warningSecondary
|
|
499
|
+
|
|
500
|
+
```ts
|
|
501
|
+
warningSecondary: string;
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
Secondary warning color
|
|
505
|
+
|
|
506
|
+
##### errorPrimary
|
|
507
|
+
|
|
508
|
+
```ts
|
|
509
|
+
errorPrimary: string;
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Primary error color
|
|
513
|
+
|
|
514
|
+
##### errorSecondary
|
|
515
|
+
|
|
516
|
+
```ts
|
|
517
|
+
errorSecondary: string;
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
Secondary error color
|
|
521
|
+
|
|
522
|
+
##### innerBorderRadius
|
|
523
|
+
|
|
524
|
+
```ts
|
|
525
|
+
innerBorderRadius: string;
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Inner border radius: used for most buttons
|
|
529
|
+
|
|
530
|
+
##### outerBorderRadius
|
|
531
|
+
|
|
532
|
+
```ts
|
|
533
|
+
outerBorderRadius: string;
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Outer border radius: generally used for elements that contain buttons that have inner border radius. Also used by the launch button.
|
|
537
|
+
|
|
538
|
+
## Modality components
|
|
539
|
+
|
|
540
|
+
### Ripple
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
const Ripple: FC<{
|
|
544
|
+
className?: string;
|
|
545
|
+
style?: CSSProperties;
|
|
546
|
+
}>;
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
A ripple effect composed of expanding circles.
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
### Carousel
|
|
554
|
+
|
|
555
|
+
```ts
|
|
556
|
+
const Carousel: FC<{
|
|
557
|
+
className?: string;
|
|
558
|
+
children?: ReactNode;
|
|
559
|
+
}>;
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
Renders a carousel of cards.
|
|
563
|
+
|
|
564
|
+
#### Example
|
|
565
|
+
|
|
566
|
+
```tsx
|
|
567
|
+
import {
|
|
568
|
+
Carousel,
|
|
569
|
+
CustomCard,
|
|
570
|
+
CustomCardImageRow,
|
|
571
|
+
React,
|
|
572
|
+
} from "@nlx/touchpoint-ui";
|
|
573
|
+
|
|
574
|
+
const MyCarousel = ({ data }) => (
|
|
575
|
+
<Carousel>
|
|
576
|
+
{data.map((item) => (
|
|
577
|
+
<CustomCard key={item.id}>
|
|
578
|
+
<CustomCardImageRow src={item.image} alt={item.description} />
|
|
579
|
+
</CustomCard>
|
|
580
|
+
))}
|
|
581
|
+
</Carousel>
|
|
582
|
+
);
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
---
|
|
24
586
|
|
|
25
|
-
|
|
587
|
+
### CustomCard
|
|
26
588
|
|
|
27
|
-
|
|
28
|
-
|
|
589
|
+
```ts
|
|
590
|
+
const CustomCard: FC<{
|
|
591
|
+
className?: string;
|
|
592
|
+
children: ReactNode;
|
|
593
|
+
selected?: boolean;
|
|
594
|
+
onClick?: () => void;
|
|
595
|
+
href?: string;
|
|
596
|
+
newTab?: boolean;
|
|
597
|
+
}>;
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
A customizable card component that can function as a button or link.
|
|
29
601
|
|
|
30
|
-
|
|
602
|
+
#### Example
|
|
31
603
|
|
|
32
|
-
|
|
604
|
+
```tsx
|
|
605
|
+
import {
|
|
606
|
+
CustomCard,
|
|
607
|
+
CustomCardImageRow,
|
|
608
|
+
CustomCardRow,
|
|
609
|
+
React,
|
|
610
|
+
} from "@nlx/touchpoint-ui";
|
|
611
|
+
|
|
612
|
+
const MyCard = ({ data }) => (
|
|
613
|
+
<CustomCard selected={data.active} onClick={() => alert("Card clicked!")}>
|
|
614
|
+
<CustomCardImageRow
|
|
615
|
+
src="https://example.com/image.jpg"
|
|
616
|
+
alt="Example Image"
|
|
617
|
+
/>
|
|
618
|
+
<CustomCardRow
|
|
619
|
+
left={<div>Left Content</div>}
|
|
620
|
+
right={<div>Right Content</div>}
|
|
621
|
+
icon={MyIcon}
|
|
622
|
+
/>
|
|
623
|
+
</CustomCard>
|
|
624
|
+
);
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
### CustomCardImageRow
|
|
630
|
+
|
|
631
|
+
```ts
|
|
632
|
+
const CustomCardImageRow: FC<{
|
|
633
|
+
src: string;
|
|
634
|
+
alt?: string;
|
|
635
|
+
}>;
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
A row within a CustomCard that displays an image.
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
### CustomCardRow
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
const CustomCardRow: FC<{
|
|
646
|
+
left: ReactNode;
|
|
647
|
+
right: ReactNode;
|
|
648
|
+
icon?: Icon;
|
|
649
|
+
}>;
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
A row within a CustomCard that displays left and right content, with an optional centered icon.
|
|
653
|
+
|
|
654
|
+
#### Example
|
|
655
|
+
|
|
656
|
+
```tsx
|
|
657
|
+
import { CustomCardRow, Icons, BaseText, React } from "@nlx/touchpoint-ui";
|
|
658
|
+
|
|
659
|
+
const MyCardRow = () => (
|
|
660
|
+
<CustomCardRow
|
|
661
|
+
left={<BaseText>Left Content</BaseText>}
|
|
662
|
+
right={<BaseText>Right Content</BaseText>}
|
|
663
|
+
icon={Icons.ArrowRight}
|
|
664
|
+
/>
|
|
665
|
+
);
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
---
|
|
669
|
+
|
|
670
|
+
### DateInput
|
|
671
|
+
|
|
672
|
+
```ts
|
|
673
|
+
const DateInput: FC<{
|
|
674
|
+
onSubmit?: (date) => void;
|
|
675
|
+
className?: string;
|
|
676
|
+
}>;
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
A date input
|
|
680
|
+
|
|
681
|
+
#### Example
|
|
682
|
+
|
|
683
|
+
```tsx
|
|
684
|
+
import { DateInput, React } from "@nlx/touchpoint-ui";
|
|
685
|
+
|
|
686
|
+
const MyDateInput = ({ conversationHandler }) => (
|
|
687
|
+
<DateInput
|
|
688
|
+
onSubmit={(date) => conversationHandler.sendContext({ myDate: date })}
|
|
689
|
+
/>
|
|
690
|
+
);
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
### IconButtonType
|
|
696
|
+
|
|
697
|
+
```ts
|
|
698
|
+
type IconButtonType =
|
|
699
|
+
| "main"
|
|
700
|
+
| "ghost"
|
|
701
|
+
| "activated"
|
|
702
|
+
| "coverup"
|
|
703
|
+
| "error"
|
|
704
|
+
| "overlay";
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
Represents the different types of icon buttons available in the application.
|
|
708
|
+
|
|
709
|
+
- `main`: The primary icon button.
|
|
710
|
+
- `ghost`: A transparent or less prominent icon button.
|
|
711
|
+
- `activated`: An icon button that indicates an active state.
|
|
712
|
+
- `coverup`: An icon button used to cover up or mask something.
|
|
713
|
+
- `overlay`: An icon button that appears over other content.
|
|
714
|
+
|
|
715
|
+
---
|
|
716
|
+
|
|
717
|
+
### IconButton
|
|
718
|
+
|
|
719
|
+
```ts
|
|
720
|
+
const IconButton: FC<{
|
|
721
|
+
onClick?: () => void;
|
|
722
|
+
label: string;
|
|
723
|
+
className?: string;
|
|
724
|
+
type: IconButtonType;
|
|
725
|
+
Icon: FC<IconProps>;
|
|
726
|
+
}>;
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
A button showing only an icon (textual label is provided for accessibility)
|
|
730
|
+
|
|
731
|
+
#### Example
|
|
732
|
+
|
|
733
|
+
```tsx
|
|
734
|
+
import { IconButton, Icons, React } from "@nlx/touchpoint-ui";
|
|
735
|
+
|
|
736
|
+
const MyIconButton = () => (
|
|
737
|
+
<IconButton
|
|
738
|
+
label="Send message"
|
|
739
|
+
onClick={() => alert("Icon button clicked!")}
|
|
740
|
+
type="main"
|
|
741
|
+
Icon={Icons.ArrowForward}
|
|
742
|
+
/>
|
|
743
|
+
);
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
### TextButton
|
|
749
|
+
|
|
750
|
+
```ts
|
|
751
|
+
const TextButton: FC<{
|
|
752
|
+
onClick?: () => void;
|
|
753
|
+
label: string;
|
|
754
|
+
className?: string;
|
|
755
|
+
type?: "main" | "ghost";
|
|
756
|
+
Icon: FC<IconProps>;
|
|
757
|
+
}>;
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
A button with a visible textual label
|
|
761
|
+
|
|
762
|
+
#### Example
|
|
763
|
+
|
|
764
|
+
```tsx
|
|
765
|
+
import { TextButton, ArrowForward, React } from "@nlx/touchpoint-ui";
|
|
766
|
+
|
|
767
|
+
const MyTextButton = ({ onClickHandler }) => (
|
|
768
|
+
<TextButton onClick={onClickHandler} label="Continue" />
|
|
769
|
+
);
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
---
|
|
773
|
+
|
|
774
|
+
### BaseText
|
|
775
|
+
|
|
776
|
+
```ts
|
|
777
|
+
const BaseText: FC<{
|
|
778
|
+
children: ReactNode;
|
|
779
|
+
faded?: boolean;
|
|
780
|
+
className?: string;
|
|
781
|
+
}>;
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
Standard text component with base typography styles applied.
|
|
785
|
+
|
|
786
|
+
#### Example
|
|
787
|
+
|
|
788
|
+
```tsx
|
|
789
|
+
import { BaseText, React } from "@nlx/touchpoint-ui";
|
|
790
|
+
|
|
791
|
+
const MyText = () => <BaseText faded>This is some standard text.</BaseText>;
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
---
|
|
795
|
+
|
|
796
|
+
### SmallText
|
|
797
|
+
|
|
798
|
+
```ts
|
|
799
|
+
const SmallText: FC<{
|
|
800
|
+
children: ReactNode;
|
|
801
|
+
className?: string;
|
|
802
|
+
}>;
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
Small text component with smaller typography styles applied.
|
|
806
|
+
|
|
807
|
+
---
|
|
808
|
+
|
|
809
|
+
### html()
|
|
810
|
+
|
|
811
|
+
```ts
|
|
812
|
+
const html: (strings, ...values) => unknown;
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
A tagged literal for creating reactive elements for custom modalities.
|
|
816
|
+
It already knows about all Touchpoint UI components, so you can use them directly without the need to import them.
|
|
817
|
+
Also very useful when using Touchpoint directly from CDN or in projects without a build step.
|
|
818
|
+
|
|
819
|
+
#### Parameters
|
|
820
|
+
|
|
821
|
+
##### strings
|
|
822
|
+
|
|
823
|
+
`TemplateStringsArray`
|
|
824
|
+
|
|
825
|
+
##### values
|
|
826
|
+
|
|
827
|
+
...`any`[]
|
|
828
|
+
|
|
829
|
+
#### Returns
|
|
830
|
+
|
|
831
|
+
`unknown`
|
|
832
|
+
|
|
833
|
+
#### Example
|
|
834
|
+
|
|
835
|
+
```ts
|
|
836
|
+
import { html, Icons } from "@nlx/touchpoint-ui";
|
|
837
|
+
|
|
838
|
+
const MyCustomModality = ({ data, conversationHandler }) =>
|
|
839
|
+
html`<div style="display: flex; gap: 8px;">
|
|
840
|
+
<IconButton
|
|
841
|
+
label="Cancel"
|
|
842
|
+
Icon=${Icons.Close}
|
|
843
|
+
type="ghost"
|
|
844
|
+
onClick=${cancel()}
|
|
845
|
+
/>
|
|
846
|
+
<TextButton
|
|
847
|
+
label="Submit"
|
|
848
|
+
Icon=${Icons.ArrowForward}
|
|
849
|
+
type="main"
|
|
850
|
+
onClick=${() => conversationHandler.sendText("Button clicked!")}
|
|
851
|
+
/>
|
|
852
|
+
</div>`;
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
---
|
|
856
|
+
|
|
857
|
+
### CustomModalityComponent
|
|
858
|
+
|
|
859
|
+
```ts
|
|
860
|
+
type CustomModalityComponent<Data> = ComponentType<{
|
|
861
|
+
data: Data;
|
|
862
|
+
conversationHandler: ConversationHandler;
|
|
863
|
+
className?: string;
|
|
864
|
+
}>;
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
Custom Modalities allow rendering of rich user interfaces directly inside a conversation.
|
|
868
|
+
A custom modality component is a React component. It will receive the modality data as a
|
|
869
|
+
`data` prop, along with the conversation handler instance to interact with the conversation as
|
|
870
|
+
`conversationHandler` prop.
|
|
871
|
+
|
|
872
|
+
#### Type Parameters
|
|
873
|
+
|
|
874
|
+
##### Data
|
|
875
|
+
|
|
876
|
+
`Data`
|
|
877
|
+
|
|
878
|
+
The type of the modality being rendered by this component.
|
|
879
|
+
|
|
880
|
+
## Bidirectional Voice+
|
|
881
|
+
|
|
882
|
+
### InteractiveElementInfo
|
|
883
|
+
|
|
884
|
+
Accessibility information with ID
|
|
885
|
+
|
|
886
|
+
#### Indexable
|
|
887
|
+
|
|
888
|
+
```ts
|
|
889
|
+
[key: string]: any
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
#### Properties
|
|
893
|
+
|
|
894
|
+
##### id
|
|
895
|
+
|
|
896
|
+
```ts
|
|
897
|
+
id: string;
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
Form element ID (assigned by the analysis logic, not necessarily equal to the DOM ID)
|
|
901
|
+
|
|
902
|
+
---
|
|
903
|
+
|
|
904
|
+
### PageForms
|
|
905
|
+
|
|
906
|
+
Page forms with elements
|
|
907
|
+
|
|
908
|
+
#### Properties
|
|
909
|
+
|
|
910
|
+
##### context
|
|
911
|
+
|
|
912
|
+
```ts
|
|
913
|
+
context: InteractiveElementInfo[];
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
Page context
|
|
917
|
+
|
|
918
|
+
##### formElements
|
|
919
|
+
|
|
920
|
+
```ts
|
|
921
|
+
formElements: Record<string, Element>;
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
Form element references
|
|
925
|
+
|
|
926
|
+
---
|
|
927
|
+
|
|
928
|
+
### analyzePageForms()
|
|
929
|
+
|
|
930
|
+
```ts
|
|
931
|
+
function analyzePageForms(): PageForms;
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
Analyze page forms
|
|
935
|
+
|
|
936
|
+
#### Returns
|
|
937
|
+
|
|
938
|
+
[`PageForms`](#pageforms)
|
|
939
|
+
|
|
940
|
+
Context and state about all the form elements detected on the page using accessibility APIs.
|
|
941
|
+
|
|
942
|
+
---
|
|
943
|
+
|
|
944
|
+
### PageState
|
|
945
|
+
|
|
946
|
+
Internal state that the automatic context maintains.
|
|
947
|
+
|
|
948
|
+
#### Properties
|
|
949
|
+
|
|
950
|
+
##### formElements
|
|
951
|
+
|
|
952
|
+
```ts
|
|
953
|
+
formElements: Record<string, Element>;
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
Mapping from form element IDs to their DOM elements
|
|
957
|
+
|
|
958
|
+
##### links
|
|
959
|
+
|
|
960
|
+
```ts
|
|
961
|
+
links: Record<string, string>;
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
Mapping from link element names to their URLs
|
|
965
|
+
|
|
966
|
+
##### customCommands
|
|
967
|
+
|
|
968
|
+
```ts
|
|
969
|
+
customCommands: Map<string, (arg) => void>;
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
Mapping from custom commands to their handlers
|
|
973
|
+
|
|
974
|
+
---
|
|
975
|
+
|
|
976
|
+
### BidirectionalContext
|
|
977
|
+
|
|
978
|
+
Bidirectional context information that is sent to the LLM.
|
|
979
|
+
|
|
980
|
+
#### Properties
|
|
981
|
+
|
|
982
|
+
##### uri?
|
|
983
|
+
|
|
984
|
+
```ts
|
|
985
|
+
optional uri: string;
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
Identifier for which page you are currently on. This can be used to filter the relevant KB pages.
|
|
989
|
+
|
|
990
|
+
##### fields?
|
|
991
|
+
|
|
992
|
+
```ts
|
|
993
|
+
optional fields: InteractiveElementInfo[];
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
The active form fields that can be filled in.
|
|
997
|
+
|
|
998
|
+
##### destinations?
|
|
999
|
+
|
|
1000
|
+
```ts
|
|
1001
|
+
optional destinations: string[];
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
Human readable location names that can be navigated to.
|
|
1005
|
+
|
|
1006
|
+
##### actions?
|
|
1007
|
+
|
|
1008
|
+
```ts
|
|
1009
|
+
optional actions: object[];
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
Custom actions that can be performed.
|
|
1013
|
+
|
|
1014
|
+
###### action
|
|
1015
|
+
|
|
1016
|
+
```ts
|
|
1017
|
+
action: string;
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
The name of the command, used to invoke it.
|
|
1021
|
+
|
|
1022
|
+
###### description?
|
|
1023
|
+
|
|
1024
|
+
```ts
|
|
1025
|
+
optional description: string;
|
|
1026
|
+
```
|
|
1027
|
+
|
|
1028
|
+
A short description of the command
|
|
1029
|
+
|
|
1030
|
+
###### schema?
|
|
1031
|
+
|
|
1032
|
+
```ts
|
|
1033
|
+
optional schema: any;
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
A schema for validating the command's input. Should follow the JSON Schema specification.
|
|
1037
|
+
|
|
1038
|
+
---
|
|
1039
|
+
|
|
1040
|
+
### BidirectionalConfig
|
|
1041
|
+
|
|
1042
|
+
```ts
|
|
1043
|
+
type BidirectionalConfig =
|
|
1044
|
+
| {
|
|
1045
|
+
automaticContext?: true;
|
|
1046
|
+
navigation?: (action, destination, destinations) => void;
|
|
1047
|
+
input?: (fields, pageFields) => void;
|
|
1048
|
+
custom?: (action, payload) => void;
|
|
1049
|
+
customizeAutomaticContext?: (arg) => object;
|
|
1050
|
+
}
|
|
1051
|
+
| {
|
|
1052
|
+
automaticContext: false;
|
|
1053
|
+
navigation?: (action, destination?) => void;
|
|
1054
|
+
input?: (fields) => void;
|
|
1055
|
+
custom?: (action, payload) => void;
|
|
1056
|
+
};
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
Configuration for bidirectional mode of voice+.
|
|
1060
|
+
|
|
1061
|
+
#### Type Declaration
|
|
1062
|
+
|
|
1063
|
+
```ts
|
|
1064
|
+
{
|
|
1065
|
+
automaticContext?: true;
|
|
1066
|
+
navigation?: (action, destination, destinations) => void;
|
|
1067
|
+
input?: (fields, pageFields) => void;
|
|
1068
|
+
custom?: (action, payload) => void;
|
|
1069
|
+
customizeAutomaticContext?: (arg) => object;
|
|
1070
|
+
}
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
##### automaticContext?
|
|
1074
|
+
|
|
1075
|
+
```ts
|
|
1076
|
+
optional automaticContext: true;
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
Attempt to gather and send page context automatically. This will work well on semantically coded pages without too many custom form controls.
|
|
1080
|
+
This enables a number of automatic features.
|
|
1081
|
+
|
|
1082
|
+
Defaults to `true`.
|
|
1083
|
+
|
|
1084
|
+
##### navigation()?
|
|
1085
|
+
|
|
1086
|
+
```ts
|
|
1087
|
+
optional navigation: (action, destination, destinations) => void;
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
Navigation handler for bidirectional mode.
|
|
1091
|
+
|
|
1092
|
+
The default implementation will navigate to those pages using standard `window.location` APIs.
|
|
1093
|
+
|
|
1094
|
+
###### Parameters
|
|
1095
|
+
|
|
1096
|
+
###### action
|
|
1097
|
+
|
|
1098
|
+
The navigation action to perform.
|
|
1099
|
+
|
|
1100
|
+
`"page_next"` | `"page_previous"` | `"page_custom"` | `"page_unknown"`
|
|
1101
|
+
|
|
1102
|
+
###### destination
|
|
1103
|
+
|
|
1104
|
+
The name of the destination to navigate to if `action` is `"page_custom"`.
|
|
1105
|
+
|
|
1106
|
+
`string` | `undefined`
|
|
1107
|
+
|
|
1108
|
+
###### destinations
|
|
1109
|
+
|
|
1110
|
+
`Record`\<`string`, `string`\>
|
|
1111
|
+
|
|
1112
|
+
A map of destination names to URLs for custom navigation.
|
|
1113
|
+
|
|
1114
|
+
###### Returns
|
|
1115
|
+
|
|
1116
|
+
`void`
|
|
1117
|
+
|
|
1118
|
+
##### input()?
|
|
1119
|
+
|
|
1120
|
+
```ts
|
|
1121
|
+
optional input: (fields, pageFields) => void;
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
A callback for filling out form fields in bidirectional mode.
|
|
1125
|
+
|
|
1126
|
+
The default implementation will fill out the form fields using standard DOM APIs.
|
|
1127
|
+
|
|
1128
|
+
###### Parameters
|
|
1129
|
+
|
|
1130
|
+
###### fields
|
|
1131
|
+
|
|
1132
|
+
`object`[]
|
|
1133
|
+
|
|
1134
|
+
An array of field objects with `id` and `value` properties.
|
|
1135
|
+
|
|
1136
|
+
###### pageFields
|
|
1137
|
+
|
|
1138
|
+
`Record`\<`string`, `Element`\>
|
|
1139
|
+
|
|
1140
|
+
A map of field IDs to DOM elements for custom form filling.
|
|
1141
|
+
|
|
1142
|
+
###### Returns
|
|
1143
|
+
|
|
1144
|
+
`void`
|
|
1145
|
+
|
|
1146
|
+
##### ~~custom()?~~
|
|
1147
|
+
|
|
1148
|
+
```ts
|
|
1149
|
+
optional custom: (action, payload) => void;
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
A callback for custom actions in bidirectional mode.
|
|
1153
|
+
|
|
1154
|
+
###### Parameters
|
|
1155
|
+
|
|
1156
|
+
###### action
|
|
1157
|
+
|
|
1158
|
+
`string`
|
|
1159
|
+
|
|
1160
|
+
The custom name of your action.
|
|
1161
|
+
|
|
1162
|
+
###### payload
|
|
1163
|
+
|
|
1164
|
+
`unknown`
|
|
1165
|
+
|
|
1166
|
+
The payload defined for the custom action.
|
|
1167
|
+
|
|
1168
|
+
###### Returns
|
|
1169
|
+
|
|
1170
|
+
`void`
|
|
1171
|
+
|
|
1172
|
+
###### Deprecated
|
|
1173
|
+
|
|
1174
|
+
Use [TouchpointInstance.setCustomBidirectionalCommands](#setcustombidirectionalcommands) instead.
|
|
1175
|
+
|
|
1176
|
+
##### customizeAutomaticContext()?
|
|
1177
|
+
|
|
1178
|
+
```ts
|
|
1179
|
+
optional customizeAutomaticContext: (arg) => object;
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
A callback for customizing the automatic context gathering.
|
|
1183
|
+
|
|
1184
|
+
This allows you to modify the context and state before they are sent to the LLM.
|
|
1185
|
+
|
|
1186
|
+
###### Parameters
|
|
1187
|
+
|
|
1188
|
+
###### arg
|
|
1189
|
+
|
|
1190
|
+
###### context
|
|
1191
|
+
|
|
1192
|
+
[`BidirectionalContext`](#bidirectionalcontext)
|
|
1193
|
+
|
|
1194
|
+
###### state
|
|
1195
|
+
|
|
1196
|
+
[`PageState`](#pagestate)
|
|
1197
|
+
|
|
1198
|
+
###### Returns
|
|
1199
|
+
|
|
1200
|
+
The modified context and state. If the state is identical to the previous state, the call to the server will be skipped.
|
|
1201
|
+
|
|
1202
|
+
###### context
|
|
1203
|
+
|
|
1204
|
+
```ts
|
|
1205
|
+
context: BidirectionalContext;
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
The current context being sent to the LLM
|
|
1209
|
+
|
|
1210
|
+
###### state
|
|
1211
|
+
|
|
1212
|
+
```ts
|
|
1213
|
+
state: PageState;
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
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.
|
|
1217
|
+
|
|
1218
|
+
```ts
|
|
1219
|
+
{
|
|
1220
|
+
automaticContext: false;
|
|
1221
|
+
navigation?: (action, destination?) => void;
|
|
1222
|
+
input?: (fields) => void;
|
|
1223
|
+
custom?: (action, payload) => void;
|
|
1224
|
+
}
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
##### automaticContext
|
|
1228
|
+
|
|
1229
|
+
```ts
|
|
1230
|
+
automaticContext: false;
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
Disable gathering page context automatically.
|
|
1234
|
+
|
|
1235
|
+
##### navigation()?
|
|
1236
|
+
|
|
1237
|
+
```ts
|
|
1238
|
+
optional navigation: (action, destination?) => void;
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
Navigation handler for bidirectional mode. Without automatic context there is no default implementation.
|
|
1242
|
+
|
|
1243
|
+
###### Parameters
|
|
1244
|
+
|
|
1245
|
+
###### action
|
|
1246
|
+
|
|
1247
|
+
The navigation action to perform.
|
|
1248
|
+
|
|
1249
|
+
`"page_next"` | `"page_previous"` | `"page_custom"` | `"page_unknown"`
|
|
1250
|
+
|
|
1251
|
+
###### destination?
|
|
1252
|
+
|
|
1253
|
+
`string`
|
|
1254
|
+
|
|
1255
|
+
The name of the destination to navigate to if `action` is `"page_custom"`.
|
|
1256
|
+
|
|
1257
|
+
###### Returns
|
|
1258
|
+
|
|
1259
|
+
`void`
|
|
1260
|
+
|
|
1261
|
+
##### input()?
|
|
1262
|
+
|
|
1263
|
+
```ts
|
|
1264
|
+
optional input: (fields) => void;
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
A callback for filling out form fields in bidirectional mode. Without automatic context there is no default implementation.
|
|
1268
|
+
|
|
1269
|
+
###### Parameters
|
|
1270
|
+
|
|
1271
|
+
###### fields
|
|
1272
|
+
|
|
1273
|
+
`object`[]
|
|
1274
|
+
|
|
1275
|
+
An array of field objects with `id` and `value` properties.
|
|
1276
|
+
|
|
1277
|
+
###### Returns
|
|
1278
|
+
|
|
1279
|
+
`void`
|
|
1280
|
+
|
|
1281
|
+
##### custom()?
|
|
1282
|
+
|
|
1283
|
+
```ts
|
|
1284
|
+
optional custom: (action, payload) => void;
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
A callback for custom actions in bidirectional mode.
|
|
1288
|
+
|
|
1289
|
+
###### Parameters
|
|
1290
|
+
|
|
1291
|
+
###### action
|
|
1292
|
+
|
|
1293
|
+
`string`
|
|
1294
|
+
|
|
1295
|
+
The custom name of your action.
|
|
1296
|
+
|
|
1297
|
+
###### payload
|
|
1298
|
+
|
|
1299
|
+
`unknown`
|
|
1300
|
+
|
|
1301
|
+
The payload defined for the custom action.
|
|
1302
|
+
|
|
1303
|
+
###### Returns
|
|
1304
|
+
|
|
1305
|
+
`void`
|
|
1306
|
+
|
|
1307
|
+
---
|
|
1308
|
+
|
|
1309
|
+
### BidirectionalCustomCommand
|
|
1310
|
+
|
|
1311
|
+
During a Voice+ bidirectional conversation, you can indicate to the application the availability of
|
|
1312
|
+
custom commands that the user can invoke.
|
|
1313
|
+
|
|
1314
|
+
#### Properties
|
|
1315
|
+
|
|
1316
|
+
##### action
|
|
1317
|
+
|
|
1318
|
+
```ts
|
|
1319
|
+
action: string;
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
The name of the command, used to invoke it. Should be unique and descriptive in the context of the LLM.
|
|
1323
|
+
|
|
1324
|
+
##### description?
|
|
1325
|
+
|
|
1326
|
+
```ts
|
|
1327
|
+
optional description: string;
|
|
1328
|
+
```
|
|
1329
|
+
|
|
1330
|
+
A short description of the command, used to help the LLM understand its purpose.
|
|
1331
|
+
|
|
1332
|
+
If omitted, then the command will not be sent to the application and must be triggered
|
|
1333
|
+
from the application side.
|
|
1334
|
+
|
|
1335
|
+
##### schema?
|
|
1336
|
+
|
|
1337
|
+
```ts
|
|
1338
|
+
optional schema: any;
|
|
1339
|
+
```
|
|
1340
|
+
|
|
1341
|
+
A JSON Schema that defines the structure of the command's input.
|
|
1342
|
+
|
|
1343
|
+
Use descriptive names and `description` fields to give the underlying LLM plenty of context for
|
|
1344
|
+
it to generate reasonable parameters. Note that the LLM output will be validated (and transformed)
|
|
1345
|
+
with this schema, so you are guaranteed type safe inputs to your handler.
|
|
1346
|
+
|
|
1347
|
+
Should follow the JSONSchema specification.
|
|
1348
|
+
|
|
1349
|
+
##### handler()
|
|
1350
|
+
|
|
1351
|
+
```ts
|
|
1352
|
+
handler: (value) => void;
|
|
1353
|
+
```
|
|
1354
|
+
|
|
1355
|
+
A handler that will be called with an argument matching the schema when the command is invoked.
|
|
1356
|
+
|
|
1357
|
+
###### Parameters
|
|
1358
|
+
|
|
1359
|
+
###### value
|
|
1360
|
+
|
|
1361
|
+
`any`
|
|
1362
|
+
|
|
1363
|
+
###### Returns
|
|
1364
|
+
|
|
1365
|
+
`void`
|
|
1366
|
+
|
|
1367
|
+
## Other
|
|
1368
|
+
|
|
1369
|
+
- [Icons](@nlxai/namespaces/Icons.md)
|
|
1370
|
+
|
|
1371
|
+
## Utilities
|
|
1372
|
+
|
|
1373
|
+
### version
|
|
1374
|
+
|
|
1375
|
+
```ts
|
|
1376
|
+
const version: string = packageJson.version;
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1379
|
+
Package version
|
|
1380
|
+
|
|
1381
|
+
<!-- /include -->
|
|
1382
|
+
|
|
1383
|
+
## Embedded mode
|
|
1384
|
+
|
|
1385
|
+
Touchpoint UI also registers a custom element called `<nlx-touchpoint>`, which you can include in your UI. This element has a writeable property `touchpointConfiguration` that accepts the same input as [`create`](#create).
|
|
1386
|
+
|
|
1387
|
+
This start touchpoint in embedded mode, in which there is no open button and touchpoint will follow whatever layout you give it, making it easier to integrate into various awkward situations.
|
|
1388
|
+
|
|
1389
|
+
Since it is a custom element, it by default isn't a block element, so you may want to give it:
|
|
1390
|
+
|
|
1391
|
+
```css
|
|
1392
|
+
nlx-touchpoint {
|
|
1393
|
+
display: block;
|
|
1394
|
+
height: 100%;
|
|
1395
|
+
}
|
|
1396
|
+
```
|
|
33
1397
|
|
|
34
|
-
|
|
1398
|
+
or similar styling.
|