@telnyx/ai-chat-widget 2.0.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/README.md +34 -0
- package/dist/index.cjs +2339 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.mjs +47981 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +2339 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +99 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
import * as React_2 from 'react';
|
|
3
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
4
|
+
|
|
5
|
+
declare type BaseProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The endpoint to use for the chat widget
|
|
8
|
+
* @default `flow`
|
|
9
|
+
*/
|
|
10
|
+
endpoint: 'flow' | 'aida';
|
|
11
|
+
/**
|
|
12
|
+
* The base URL of the flow to execute, Defaults to `https://api.telnyx.com/v2/flow`
|
|
13
|
+
* @required
|
|
14
|
+
*/
|
|
15
|
+
chatAPIUrl: string;
|
|
16
|
+
/**
|
|
17
|
+
* The base URL of the feedback to send, Defaults to `https://api.telnyx.com/v2/ai/chatbot/feedback`
|
|
18
|
+
* @required
|
|
19
|
+
*/
|
|
20
|
+
feedbackAPIUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* The user info to send with the feedback
|
|
23
|
+
* @required
|
|
24
|
+
* The user info contains the user ID, token, api access key, api v2 token, two factor authentication, role, and expires at
|
|
25
|
+
* @example
|
|
26
|
+
* {
|
|
27
|
+
* id: '123',
|
|
28
|
+
* token: '123',
|
|
29
|
+
* apiAccessKey: '123',
|
|
30
|
+
* api_v2_token: '123',
|
|
31
|
+
* twoFactorAuth: '123',
|
|
32
|
+
* role: 'admin',
|
|
33
|
+
* expiresAt: '2025-01-01',
|
|
34
|
+
* }
|
|
35
|
+
* We use the api_v2_token to authenticate the user with the flow API.
|
|
36
|
+
* @info If you include in api_v2_token, it'll be sent as an authentication header in both EventSource and Feedback API.
|
|
37
|
+
*/
|
|
38
|
+
user: UserInfo;
|
|
39
|
+
/**
|
|
40
|
+
* The placeholders to be used in the chat widget
|
|
41
|
+
* @default ["Type your message here..."]
|
|
42
|
+
*/
|
|
43
|
+
placeholders?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* The action to be performed when the user clicks the help button
|
|
46
|
+
*/
|
|
47
|
+
onHelpAction?: () => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export declare const ChatWidget: ({ endpoint, chatAPIUrl, feedbackAPIUrl, user, onHelpAction, open, setOpen, placeholders, mountPosition, mountDirection, offsetX, offsetY, icon, }: ChatWidgetProps) => JSX.Element;
|
|
51
|
+
|
|
52
|
+
declare interface ChatWidgetNoMounting extends BaseProps {
|
|
53
|
+
open?: never;
|
|
54
|
+
setOpen?: never;
|
|
55
|
+
mountPosition?: never;
|
|
56
|
+
mountDirection?: never;
|
|
57
|
+
offsetX?: never;
|
|
58
|
+
offsetY?: never;
|
|
59
|
+
/**
|
|
60
|
+
* The icon to be used in the chat widget
|
|
61
|
+
* @default `ChatBubbleOvalLeftIcon`
|
|
62
|
+
*/
|
|
63
|
+
icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare type ChatWidgetProps = ChatWidgetNoMounting | ChatWidgetWithMounting;
|
|
67
|
+
|
|
68
|
+
declare interface ChatWidgetWithMounting extends BaseProps, MountingProps {
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare type MountingProps = {
|
|
72
|
+
open: boolean;
|
|
73
|
+
setOpen: (open: boolean) => void;
|
|
74
|
+
/**
|
|
75
|
+
* The offset of the widget on the x axis
|
|
76
|
+
* @default 0
|
|
77
|
+
*/
|
|
78
|
+
offsetX?: number;
|
|
79
|
+
/**
|
|
80
|
+
* The offset of the widget on the y axis
|
|
81
|
+
* @default 0
|
|
82
|
+
*/
|
|
83
|
+
offsetY?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The position of the widget
|
|
86
|
+
* Values: `top-left`, `top`, `top-right`, `right`, `bottom-right`, `bottom`, `bottom-left`, `left`
|
|
87
|
+
* @default `bottom-right`
|
|
88
|
+
*/
|
|
89
|
+
mountPosition: WidgetMountPosition;
|
|
90
|
+
/**
|
|
91
|
+
* The direction, inside or outside the container
|
|
92
|
+
* Values: `inside`, `outside`
|
|
93
|
+
* @default `inside`
|
|
94
|
+
*/
|
|
95
|
+
mountDirection: WidgetMountDirection;
|
|
96
|
+
icon?: never;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export declare const Tooltip: React_2.FC<TooltipPrimitive.TooltipProps>;
|
|
100
|
+
|
|
101
|
+
export declare const TooltipContent: {
|
|
102
|
+
({ className, sideOffset, ...props }: React_2.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>): JSX.Element;
|
|
103
|
+
displayName: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export declare const TooltipProvider: React_2.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
107
|
+
|
|
108
|
+
export declare const TooltipTrigger: React_2.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
109
|
+
|
|
110
|
+
declare type UserInfo = {
|
|
111
|
+
/**
|
|
112
|
+
* The user ID
|
|
113
|
+
* @required
|
|
114
|
+
*/
|
|
115
|
+
id: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* The user token
|
|
118
|
+
* @required
|
|
119
|
+
*/
|
|
120
|
+
token: string | null;
|
|
121
|
+
/**
|
|
122
|
+
* The user API access key
|
|
123
|
+
* @required
|
|
124
|
+
*/
|
|
125
|
+
apiAccessKey: string | null;
|
|
126
|
+
/**
|
|
127
|
+
* The user API v2 token
|
|
128
|
+
* @required
|
|
129
|
+
*/
|
|
130
|
+
api_v2_token: string | null;
|
|
131
|
+
/**
|
|
132
|
+
* The user two factor authentication
|
|
133
|
+
*/
|
|
134
|
+
twoFactorAuth?: boolean | null;
|
|
135
|
+
/**
|
|
136
|
+
* The user role
|
|
137
|
+
*/
|
|
138
|
+
role?: string | null;
|
|
139
|
+
/**
|
|
140
|
+
* The user expires at
|
|
141
|
+
*/
|
|
142
|
+
expiresAt?: number | null;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
declare const WIDGET_MOUNT_DIRECTION: {
|
|
146
|
+
readonly INSIDE: "inside";
|
|
147
|
+
readonly OUTSIDE: "outside";
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
declare const WIDGET_MOUNT_POSITIONS: {
|
|
151
|
+
readonly TOP_LEFT: "top-left";
|
|
152
|
+
readonly TOP: "top";
|
|
153
|
+
readonly TOP_RIGHT: "top-right";
|
|
154
|
+
readonly RIGHT: "right";
|
|
155
|
+
readonly BOTTOM_RIGHT: "bottom-right";
|
|
156
|
+
readonly BOTTOM: "bottom";
|
|
157
|
+
readonly BOTTOM_LEFT: "bottom-left";
|
|
158
|
+
readonly LEFT: "left";
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
declare type WidgetMountDirection = (typeof WIDGET_MOUNT_DIRECTION)[keyof typeof WIDGET_MOUNT_DIRECTION];
|
|
162
|
+
|
|
163
|
+
declare type WidgetMountPosition = (typeof WIDGET_MOUNT_POSITIONS)[keyof typeof WIDGET_MOUNT_POSITIONS];
|
|
164
|
+
|
|
165
|
+
export { }
|