@nlxai/touchpoint-ui 1.2.5 → 1.2.6

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