@chatwidgetai/chat-widget 0.1.5 → 0.1.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/README.md +7 -8
- package/dist/ai-chat-widget.umd.js +39834 -0
- package/dist/ai-chat-widget.umd.js.map +1 -0
- package/dist/api/client.d.ts +3 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/components/ChatWidget.d.ts +1 -1
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/components/ChatWindow.d.ts +1 -1
- package/dist/components/ChatWindow.d.ts.map +1 -1
- package/dist/components/Message.d.ts.map +1 -1
- package/dist/components/MessageInput.d.ts.map +1 -1
- package/dist/components/SuggestedQuestions.d.ts +2 -2
- package/dist/components/SuggestedQuestions.d.ts.map +1 -1
- package/dist/hooks/useChat.d.ts +0 -1
- package/dist/hooks/useChat.d.ts.map +1 -1
- package/dist/index.esm.js +20 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -28
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/umd.d.ts +0 -1
- package/dist/umd.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Embeddable AI assistant widget for React applications. The package wraps the AI
|
|
|
12
12
|
- **Agent support** – seamlessly handles widgets with custom actions and follow-up approvals.
|
|
13
13
|
- **Hook-first API** for building bespoke chat surfaces while reusing the data flows.
|
|
14
14
|
- **Browser friendly** UMD bundle (`window.AIChatWidget.mount`) for non-React hosts.
|
|
15
|
+
- **No API key required** – widget ID acts as the access token for simplified integration.
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
@@ -40,7 +41,6 @@ export function SupportChat() {
|
|
|
40
41
|
return (
|
|
41
42
|
<ChatWidget
|
|
42
43
|
widgetId="64f6e3e4d12b4a9c8f3c1234"
|
|
43
|
-
apiKey="sk_live_example-key"
|
|
44
44
|
apiUrl="https://api.my-rag-backend.com"
|
|
45
45
|
position="bottom-right"
|
|
46
46
|
theme="auto"
|
|
@@ -51,7 +51,9 @@ export function SupportChat() {
|
|
|
51
51
|
}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
The widget automatically pulls its configuration (branding, behavior, suggestions, etc.) from your backend. Only `widgetId`
|
|
54
|
+
The widget automatically pulls its configuration (branding, behavior, suggestions, etc.) from your backend. Only `widgetId` is required; `apiUrl` defaults to `window.location.origin`.
|
|
55
|
+
|
|
56
|
+
> **Security Note**: Keep your Widget ID confidential. It acts as the access token for your widget and should not be exposed in public repositories.
|
|
55
57
|
|
|
56
58
|
---
|
|
57
59
|
|
|
@@ -59,15 +61,14 @@ The widget automatically pulls its configuration (branding, behavior, suggestion
|
|
|
59
61
|
|
|
60
62
|
| Prop | Type | Required | Description |
|
|
61
63
|
| -------------- | --------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------ |
|
|
62
|
-
| `widgetId` | `string` | ✅ | Widget identifier created in the AI Console.
|
|
63
|
-
| `apiKey` | `string` | ✅ | Public API key with `widget:*` access. |
|
|
64
|
+
| `widgetId` | `string` | ✅ | Widget identifier created in the AI Console. Keep this confidential. |
|
|
64
65
|
| `apiUrl` | `string` | ❌ | Base URL of your widget API. Defaults to `window.location.origin`. |
|
|
65
66
|
| `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | ❌ | Launcher position (overridden by backend appearance settings). |
|
|
66
67
|
| `theme` | `'light' \| 'dark' \| 'auto'` | ❌ | Force a theme instead of the configured one. |
|
|
67
68
|
| `primaryColor` | `string` | ❌ | Override the accent color (CSS color string). |
|
|
68
69
|
| `onOpen` | `() => void` | ❌ | Fired when the chat window opens. |
|
|
69
70
|
| `onClose` | `() => void` | ❌ | Fired when the chat window closes. |
|
|
70
|
-
| `onMessage` | `(message: ConversationMessage) => void` | ❌ | Called for every new message, including the user
|
|
71
|
+
| `onMessage` | `(message: ConversationMessage) => void` | ❌ | Called for every new message, including the user's own messages. |
|
|
71
72
|
| `onError` | `(error: Error) => void` | ❌ | Called when an API error or transport failure occurs. |
|
|
72
73
|
|
|
73
74
|
---
|
|
@@ -77,7 +78,7 @@ The widget automatically pulls its configuration (branding, behavior, suggestion
|
|
|
77
78
|
```tsx
|
|
78
79
|
import { useChat } from '@chatwidgetai/chat-widget';
|
|
79
80
|
|
|
80
|
-
export function CustomChat({ widgetId
|
|
81
|
+
export function CustomChat({ widgetId }: { widgetId: string }) {
|
|
81
82
|
const {
|
|
82
83
|
messages,
|
|
83
84
|
isLoading,
|
|
@@ -90,7 +91,6 @@ export function CustomChat({ widgetId, apiKey }: { widgetId: string; apiKey: str
|
|
|
90
91
|
submitFeedback,
|
|
91
92
|
} = useChat({
|
|
92
93
|
widgetId,
|
|
93
|
-
apiKey,
|
|
94
94
|
apiUrl: 'https://api.my-rag-backend.com',
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -111,7 +111,6 @@ A bundled UMD build is published as `dist/ai-chat-widget.umd.js`. After includin
|
|
|
111
111
|
<script>
|
|
112
112
|
window.AIChatWidget.mount({
|
|
113
113
|
widgetId: '64f6e3e4d12b4a9c8f3c1234',
|
|
114
|
-
apiKey: 'sk_live_example-key',
|
|
115
114
|
apiUrl: 'https://api.my-rag-backend.com',
|
|
116
115
|
position: 'bottom-right',
|
|
117
116
|
theme: 'auto',
|