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