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