@nlxai/touchpoint-ui 1.1.8-alpha.0 → 1.1.8-alpha.2
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/index.html +37 -5
- package/lib/App.d.ts +2 -0
- package/lib/bidirectional/automaticContext.d.ts +11 -4
- package/lib/bidirectional/commandHandler.d.ts +2 -5
- package/lib/components/FullscreenVoice.d.ts +1 -1
- package/lib/components/Header.d.ts +1 -1
- package/lib/components/Messages.d.ts +1 -1
- package/lib/components/Theme.d.ts +1 -1
- package/lib/components/VoiceMini.d.ts +1 -1
- package/lib/components/defaultModalities/DefaultCard.d.ts +1 -1
- package/lib/components/defaultModalities/DefaultCarousel.d.ts +1 -1
- package/lib/components/defaultModalities/DefaultDateInput.d.ts +1 -1
- package/lib/components/defaultModalities/shared.d.ts +5 -0
- package/lib/index.d.ts +55 -2
- package/lib/index.js +1182 -1132
- package/lib/index.umd.js +26 -26
- package/lib/interface.d.ts +408 -0
- package/lib/preview.d.ts +1 -1
- package/lib/types.d.ts +2 -320
- package/package.json +3 -2
- package/tsdoc.json +6 -0
package/index.html
CHANGED
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
</main>
|
|
91
91
|
<script type="module">
|
|
92
92
|
import { create, html } from "/src/index.tsx";
|
|
93
|
+
import * as z from "zod/v4";
|
|
93
94
|
|
|
94
95
|
const CustomLaunchButton = ({ className, onClick }) => {
|
|
95
96
|
return html`
|
|
@@ -134,19 +135,50 @@
|
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
const touchpoint = await create({
|
|
138
|
+
// https://dev.platform.nlx.ai/applications/fe041de0-bc87-4120-a6db-443ab1107ad3 in the dev workspace
|
|
137
139
|
config: {
|
|
138
140
|
applicationUrl:
|
|
139
|
-
"https://bots.dev.studio.nlx.ai/c/
|
|
141
|
+
"https://bots.dev.studio.nlx.ai/c/XeHWunu1RQOVcVzKIQoo5/cKdh8IsqmA0syks0R9oBh",
|
|
140
142
|
headers: {
|
|
141
|
-
"nlx-api-key": "
|
|
143
|
+
"nlx-api-key": "8afGyqKJoObPj4g-UFNUc65s",
|
|
142
144
|
},
|
|
143
|
-
userId: "
|
|
145
|
+
userId: "sdk-test-user",
|
|
144
146
|
languageCode: "en-US",
|
|
145
147
|
},
|
|
146
|
-
input: "
|
|
148
|
+
input: "voiceMini",
|
|
147
149
|
launchIcon: CustomLaunchButton,
|
|
148
|
-
|
|
150
|
+
bidirectional: {
|
|
151
|
+
custom(action, payload) {
|
|
152
|
+
console.log("Custom bidirectional action:", action, payload);
|
|
153
|
+
},
|
|
154
|
+
customizeAutomaticContext(arg) {
|
|
155
|
+
console.log("Customizing automatic context with arg:", arg);
|
|
156
|
+
arg.context.uri = "foo";
|
|
157
|
+
return arg;
|
|
158
|
+
},
|
|
159
|
+
},
|
|
149
160
|
});
|
|
161
|
+
|
|
162
|
+
touchpoint.setCustomBidirectionalCommands([
|
|
163
|
+
{
|
|
164
|
+
action: "burger",
|
|
165
|
+
description: "Order a hamburger",
|
|
166
|
+
schema: z.object({
|
|
167
|
+
type: z
|
|
168
|
+
.enum(["cheeseburger", "veggieburger", "hamburger"])
|
|
169
|
+
.describe("Which variety of burger to order"),
|
|
170
|
+
count: z
|
|
171
|
+
.number()
|
|
172
|
+
.min(1)
|
|
173
|
+
.max(200)
|
|
174
|
+
.default(1)
|
|
175
|
+
.describe("How many burgers to order"),
|
|
176
|
+
}),
|
|
177
|
+
handler: (burgerType) => {
|
|
178
|
+
console.log("Custom command executed with args:", burgerType);
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
]);
|
|
150
182
|
</script>
|
|
151
183
|
</body>
|
|
152
184
|
</html>
|
package/lib/App.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConversationHandler } from '@nlxai/core';
|
|
2
|
+
import { BidirectionalCustomCommand } from './interface';
|
|
2
3
|
import { NormalizedTouchpointConfiguration } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Main Touchpoint creation properties object
|
|
@@ -13,6 +14,7 @@ export interface AppRef {
|
|
|
13
14
|
setExpanded: (val: boolean) => void;
|
|
14
15
|
getExpanded: () => boolean;
|
|
15
16
|
getConversationHandler: () => ConversationHandler;
|
|
17
|
+
setCustomBidirectionalCommands: (commands: BidirectionalCustomCommand[]) => void;
|
|
16
18
|
}
|
|
17
19
|
declare const App: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<AppRef>>;
|
|
18
20
|
export default App;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ConversationHandler } from '@nlxai/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { BidirectionalContext, BidirectionalCustomCommand, PageState } from '../interface';
|
|
3
|
+
export declare const gatherAutomaticContext: (handler: ConversationHandler, customCommands: BidirectionalCustomCommand[], override: (arg: {
|
|
4
|
+
context: BidirectionalContext;
|
|
5
|
+
state: PageState;
|
|
6
|
+
}) => {
|
|
7
|
+
context: BidirectionalContext;
|
|
8
|
+
state: PageState;
|
|
9
|
+
}, setPageState: (state: PageState) => void) => {
|
|
10
|
+
teardown: () => void;
|
|
11
|
+
onCustomCommandsChange: (commands: BidirectionalCustomCommand[]) => void;
|
|
12
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ConversationHandler } from '@nlxai/core';
|
|
2
|
-
import { BidirectionalConfig } from '../
|
|
2
|
+
import { PageState, BidirectionalConfig } from '../interface';
|
|
3
3
|
export declare const commandHandler: (handler: ConversationHandler, bidirectional: BidirectionalConfig, pageState: {
|
|
4
|
-
current:
|
|
5
|
-
formElements: Record<string, Element>;
|
|
6
|
-
links: Record<string, string>;
|
|
7
|
-
};
|
|
4
|
+
current: PageState;
|
|
8
5
|
}) => () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { Context, ConversationHandler } from '@nlxai/core';
|
|
3
|
-
import { ColorMode, InitializeConversation, CustomModalityComponent } from '../
|
|
3
|
+
import { ColorMode, InitializeConversation, CustomModalityComponent } from '../interface';
|
|
4
4
|
import { ModalitiesWithContext } from '../voice';
|
|
5
5
|
interface Props {
|
|
6
6
|
colorMode: ColorMode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { Response, ConversationHandler, ApplicationMessage } from '@nlxai/core';
|
|
3
|
-
import { CustomModalityComponent, ColorMode } from '../
|
|
3
|
+
import { CustomModalityComponent, ColorMode } from '../interface';
|
|
4
4
|
export interface MessagesProps {
|
|
5
5
|
isWaiting: boolean;
|
|
6
6
|
handler: ConversationHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, ConversationHandler } from '@nlxai/core';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import { CustomModalityComponent } from '../
|
|
3
|
+
import { CustomModalityComponent } from '../interface';
|
|
4
4
|
export declare const VoiceMini: FC<{
|
|
5
5
|
customModalities: Record<string, CustomModalityComponent<unknown>>;
|
|
6
6
|
handler: ConversationHandler;
|
|
@@ -3,10 +3,15 @@ export interface SaveAs {
|
|
|
3
3
|
type: "slot" | "context";
|
|
4
4
|
id: string;
|
|
5
5
|
}
|
|
6
|
+
export interface CardRow {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
6
10
|
export interface CardData {
|
|
7
11
|
id?: string;
|
|
8
12
|
thumbnail?: string;
|
|
9
13
|
thumbnailAlt?: string;
|
|
14
|
+
rows?: CardRow[];
|
|
10
15
|
label?: string;
|
|
11
16
|
value?: string;
|
|
12
17
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BaseText, SmallText } from './components/ui/Typography';
|
|
|
6
6
|
import { CustomCard, CustomCardRow, CustomCardImageRow } from './components/ui/CustomCard';
|
|
7
7
|
import { Carousel } from './components/ui/Carousel';
|
|
8
8
|
import { DateInput } from './components/ui/DateInput';
|
|
9
|
-
import { TouchpointConfiguration } from './
|
|
9
|
+
import { TouchpointConfiguration, BidirectionalCustomCommand } from './interface';
|
|
10
10
|
import * as Icons from "./components/ui/Icons";
|
|
11
11
|
export { analyzePageForms, type InteractiveElementInfo, type PageForms, type AccessibilityInformation, } from './bidirectional/analyzePageForms';
|
|
12
12
|
/**
|
|
@@ -30,7 +30,7 @@ export { type CustomCardProps, type CustomCardRowProps, } from './components/ui/
|
|
|
30
30
|
export { type DateInputProps } from './components/ui/DateInput';
|
|
31
31
|
export { type IconButtonProps, type IconButtonType, } from './components/ui/IconButton';
|
|
32
32
|
export { type TextButtonProps } from './components/ui/TextButton';
|
|
33
|
-
export {
|
|
33
|
+
export type { WindowSize, ColorMode, ChoiceMessage, CustomModalityComponent, Theme, InitializeConversation, CustomLaunchButton, Input, InputField, PageState, BidirectionalContext, BidirectionalConfig, TouchpointConfiguration, BidirectionalCustomCommand, } from './interface';
|
|
34
34
|
/**
|
|
35
35
|
* Instance of a Touchpoint UI component
|
|
36
36
|
*/
|
|
@@ -47,6 +47,59 @@ export interface TouchpointInstance {
|
|
|
47
47
|
* Method to remove the Touchpoint UI from the DOM
|
|
48
48
|
*/
|
|
49
49
|
teardown: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Sets currently available custom bidirectional commands.
|
|
52
|
+
* This allows you to define custom commands that can be used in the voice bot.
|
|
53
|
+
* The commands will be available in the voice bot and can be used to trigger actions.
|
|
54
|
+
*
|
|
55
|
+
* Example:
|
|
56
|
+
* ```javascript
|
|
57
|
+
* client.setCustomBidirectionalCommands([
|
|
58
|
+
* {
|
|
59
|
+
* action: "Meal",
|
|
60
|
+
* description: "add a meal to your flight",
|
|
61
|
+
* schema: {
|
|
62
|
+
* enum: ["standard", "vegetarian", "vegan", "gluten-free"],
|
|
63
|
+
* },
|
|
64
|
+
* handler: (value) => {
|
|
65
|
+
* console.log("Meal option:", value);
|
|
66
|
+
* },
|
|
67
|
+
* },
|
|
68
|
+
* ]);
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* This will allow the voice bot to use the command `Meal` with the value `standard`, `vegetarian`, `vegan`, or `gluten-free`.
|
|
72
|
+
*
|
|
73
|
+
* When using more complex arguments, a library such as [Zod](https://zod.dev) can be useful:
|
|
74
|
+
*
|
|
75
|
+
* ```javascript
|
|
76
|
+
* import * as z from "zod/v4";
|
|
77
|
+
*
|
|
78
|
+
* const schema = z.object({
|
|
79
|
+
* "name": z.string().describe("The customer's name, such as John Doe"),
|
|
80
|
+
* "email": z.string().email().describe("The customer's email address"),
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* client.setCustomBidirectionalCommands([
|
|
84
|
+
* {
|
|
85
|
+
* action: "Meal",
|
|
86
|
+
* description: "add a meal to your flight",
|
|
87
|
+
* schema: z.toJSONSchema(schema, {io: "input"}),
|
|
88
|
+
* handler: (value) => {
|
|
89
|
+
* const result = z.safeParse(schema, value);
|
|
90
|
+
* if (result.success) {
|
|
91
|
+
* // result.data is now type safe and TypeScript can reason about it
|
|
92
|
+
* console.log("Meal option:", result.data);
|
|
93
|
+
* } else {
|
|
94
|
+
* console.error("Failed to parse Meal option:", result.error);
|
|
95
|
+
* }
|
|
96
|
+
* },
|
|
97
|
+
* },
|
|
98
|
+
* ]);
|
|
99
|
+
* ```
|
|
100
|
+
* @param commands - A list containing the custom commands to set.
|
|
101
|
+
*/
|
|
102
|
+
setCustomBidirectionalCommands: (commands: BidirectionalCustomCommand[]) => void;
|
|
50
103
|
}
|
|
51
104
|
/**
|
|
52
105
|
* Creates a new Touchpoint UI instance and appends it to the document body
|