@wysdym/agent 0.1.0
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 +228 -0
- package/dist/ChatWidget.d.ts +58 -0
- package/dist/index.cjs.js +1824 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.es.js +35567 -0
- package/dist/sdk/WysdymWidget.d.ts +108 -0
- package/dist/types/agent.d.ts +32 -0
- package/dist/types/analytics.d.ts +75 -0
- package/dist/types/api.d.ts +21 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/session.d.ts +55 -0
- package/dist/types/voice.d.ts +33 -0
- package/dist/vite.svg +1 -0
- package/package.json +99 -0
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @wysdym/agent
|
|
2
|
+
|
|
3
|
+
Official Wysdym Chat Widget for React applications. Embed an AI-powered voice and chat assistant into your website with just a few lines of code.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@wysdym/agent)
|
|
6
|
+
[](https://www.npmjs.com/package/@wysdym/agent)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @wysdym/agent
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
> **Peer Dependencies:** React ≥18 and React-DOM ≥18 are required.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ⚠️ CSS Import Required
|
|
19
|
+
|
|
20
|
+
**You must import the widget styles for the widget to render correctly:**
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import '@wysdym/agent/style.css';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Without this import, the widget will appear unstyled or broken. This is the most common setup issue.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { WysdymWidget } from '@wysdym/agent';
|
|
34
|
+
import '@wysdym/agent/style.css'; // Required!
|
|
35
|
+
|
|
36
|
+
export function App() {
|
|
37
|
+
return (
|
|
38
|
+
<WysdymWidget
|
|
39
|
+
agentId="your-agent-id"
|
|
40
|
+
mode="floating"
|
|
41
|
+
position="bottom-right"
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
That's it! The widget will appear as a floating button in the bottom-right corner of your page.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Display Modes
|
|
52
|
+
|
|
53
|
+
### Floating Mode (Default)
|
|
54
|
+
|
|
55
|
+
A floating button appears in the corner of the screen. When clicked, it expands into a chat interface.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<WysdymWidget
|
|
59
|
+
agentId="your-agent-id"
|
|
60
|
+
mode="floating"
|
|
61
|
+
position="bottom-right"
|
|
62
|
+
/>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Inline Mode
|
|
66
|
+
|
|
67
|
+
The widget embeds directly into your page layout, useful for dedicated support pages or embedded experiences.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
<WysdymWidget
|
|
71
|
+
agentId="your-agent-id"
|
|
72
|
+
mode="inline"
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Props Reference
|
|
79
|
+
|
|
80
|
+
### WysdymWidget (Recommended)
|
|
81
|
+
|
|
82
|
+
The primary component for most use cases.
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Required | Default | Description |
|
|
85
|
+
|------|------|----------|---------|-------------|
|
|
86
|
+
| `agentId` | `string` | ✓ | — | Your Wysdym agent ID |
|
|
87
|
+
| `mode` | `'floating' \| 'inline'` | | `'floating'` | Display mode |
|
|
88
|
+
| `position` | `'bottom-right' \| 'bottom-left'` | | `'bottom-right'` | Floating button position |
|
|
89
|
+
| `theme` | `'light' \| 'dark'` | | — | Color theme |
|
|
90
|
+
| `primaryColor` | `string` | | — | Primary brand color (CSS value) |
|
|
91
|
+
| `expandable` | `boolean` | | — | Allow expand/collapse by user |
|
|
92
|
+
| `deferInit` | `boolean` | | — | Defer initialization until triggered |
|
|
93
|
+
|
|
94
|
+
### ChatWidget (Advanced)
|
|
95
|
+
|
|
96
|
+
A lower-level component with full configuration options. Use when you need fine-grained control over the widget's appearance and behavior.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { ChatWidget } from '@wysdym/agent';
|
|
100
|
+
import '@wysdym/agent/style.css';
|
|
101
|
+
|
|
102
|
+
<ChatWidget
|
|
103
|
+
agentId="your-agent-id"
|
|
104
|
+
primaryColor="#BA6296"
|
|
105
|
+
mode="floating"
|
|
106
|
+
onExpandChange={(expanded) => console.log('Widget expanded:', expanded)}
|
|
107
|
+
/>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Prop | Type | Required | Default | Description |
|
|
111
|
+
|------|------|----------|---------|-------------|
|
|
112
|
+
| `agentId` | `string` | ✓ | — | Your Wysdym agent ID |
|
|
113
|
+
| `mode` | `'floating' \| 'inline'` | | `'floating'` | Display mode |
|
|
114
|
+
| `primaryColor` | `string` | | `'#BA6296'` | Primary brand color |
|
|
115
|
+
| `secondaryColor` | `string` | | `'#A0527A'` | Secondary brand color |
|
|
116
|
+
| `isExpanded` | `boolean` | | `false` | Start widget in expanded state |
|
|
117
|
+
| `onExpandChange` | `(expanded: boolean) => void` | | — | Callback when expanded state changes |
|
|
118
|
+
| `backendUrl` | `string` | | production URL | Custom backend URL (self-hosted) |
|
|
119
|
+
| `widgetTriggerText` | `string` | | `'Need help?'` | Text shown on trigger button |
|
|
120
|
+
| `widgetTriggerButtonText` | `string` | | `'Start a call'` | Button text for trigger |
|
|
121
|
+
| `widgetTriggerButtonIcon` | `string` | | `'Phone'` | Icon name for trigger button |
|
|
122
|
+
| `emailCollectionButtonText` | `string` | | `'Submit'` | Email form submit button text |
|
|
123
|
+
| `emailCollectionButtonIcon` | `string` | | `'ArrowRight'` | Email form button icon |
|
|
124
|
+
| `greetingTooltipEnabled` | `boolean` | | `true` | Show proactive greeting tooltip |
|
|
125
|
+
| `greetingTooltipText` | `string` | | — | Custom tooltip text |
|
|
126
|
+
| `initialAgentName` | `string` | | — | Agent name (before config loads) |
|
|
127
|
+
| `initialAgentFirstMessage` | `string` | | — | First message (before config loads) |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Styling
|
|
132
|
+
|
|
133
|
+
### CSS Import Options
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
// Recommended: Clean import path
|
|
137
|
+
import '@wysdym/agent/style.css';
|
|
138
|
+
|
|
139
|
+
// Alternative: Direct path
|
|
140
|
+
import '@wysdym/agent/dist/index.css';
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Style Isolation
|
|
144
|
+
|
|
145
|
+
Widget styles are scoped to `.wysdym-widget-container` and **will not affect your application's global styles**:
|
|
146
|
+
|
|
147
|
+
- Widget styles only apply inside the widget container
|
|
148
|
+
- Your existing Tailwind or custom CSS classes are unaffected
|
|
149
|
+
- No CSS reset or preflight styles leak to your host application
|
|
150
|
+
|
|
151
|
+
### Custom Branding
|
|
152
|
+
|
|
153
|
+
Use `primaryColor` and `secondaryColor` props to match your brand:
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<WysdymWidget
|
|
157
|
+
agentId="your-agent-id"
|
|
158
|
+
primaryColor="#6366F1" // Indigo
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Non-React / CDN Usage
|
|
165
|
+
|
|
166
|
+
For websites not using React, embed the widget via a script tag:
|
|
167
|
+
|
|
168
|
+
```html
|
|
169
|
+
<script
|
|
170
|
+
src="https://storage.googleapis.com/wysdym-widget-cdn-production/widget-loader.js"
|
|
171
|
+
data-auto-load="true"
|
|
172
|
+
data-agent-id="your-agent-id"
|
|
173
|
+
data-mode="floating"
|
|
174
|
+
data-position="bottom-right"
|
|
175
|
+
async
|
|
176
|
+
></script>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Generating Embed Code Programmatically
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { getEmbedCode } from '@wysdym/agent';
|
|
183
|
+
|
|
184
|
+
const embedCode = getEmbedCode('your-agent-id', {
|
|
185
|
+
mode: 'floating',
|
|
186
|
+
position: 'bottom-right'
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
console.log(embedCode);
|
|
190
|
+
// <script src="..."></script>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## TypeScript Support
|
|
196
|
+
|
|
197
|
+
Full TypeScript definitions are included. Import types as needed:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import type {
|
|
201
|
+
WysdymWidgetProps,
|
|
202
|
+
ChatWidgetProps,
|
|
203
|
+
GetEmbedCodeOptions,
|
|
204
|
+
EmbedMode,
|
|
205
|
+
FloatingPosition,
|
|
206
|
+
DisplayMode,
|
|
207
|
+
} from '@wysdym/agent';
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Changelog
|
|
213
|
+
|
|
214
|
+
See the [GitHub Releases](https://github.com/wysdym/widget/releases) page for version history and release notes.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Support
|
|
219
|
+
|
|
220
|
+
- **Documentation:** [docs.wysdym.ai](https://docs.wysdym.ai)
|
|
221
|
+
- **Issues:** [GitHub Issues](https://github.com/wysdym/widget/issues)
|
|
222
|
+
- **Email:** support@wysdym.ai
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT © [Wysdym](https://wysdym.ai)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the ChatWidget component.
|
|
4
|
+
*
|
|
5
|
+
* This is the lower-level, full-featured chat widget component.
|
|
6
|
+
* For most use cases, prefer the simpler `WysdymWidget` component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { ChatWidget } from '@wysdym/agent';
|
|
11
|
+
* import '@wysdym/agent/style.css';
|
|
12
|
+
*
|
|
13
|
+
* function App() {
|
|
14
|
+
* return (
|
|
15
|
+
* <ChatWidget
|
|
16
|
+
* companyToken="your-company-token"
|
|
17
|
+
* agentId="your-agent-id"
|
|
18
|
+
* primaryColor="#BA6296"
|
|
19
|
+
* mode="floating"
|
|
20
|
+
* />
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface ChatWidgetProps {
|
|
26
|
+
/** Company token for authentication (deprecated: no longer required for bootstrap) */
|
|
27
|
+
companyToken?: string;
|
|
28
|
+
/** The unique agent ID for your Wysdym agent (required) */
|
|
29
|
+
agentId: string;
|
|
30
|
+
/** Primary brand color (CSS color value) */
|
|
31
|
+
primaryColor?: string;
|
|
32
|
+
/** Secondary brand color (CSS color value) */
|
|
33
|
+
secondaryColor?: string;
|
|
34
|
+
/** Text shown on the widget trigger button */
|
|
35
|
+
widgetTriggerText?: string;
|
|
36
|
+
/** Button text for the widget trigger */
|
|
37
|
+
widgetTriggerButtonText?: string;
|
|
38
|
+
/** Icon name for the widget trigger button (e.g., 'Phone') */
|
|
39
|
+
widgetTriggerButtonIcon?: string;
|
|
40
|
+
/** Whether the widget starts in expanded state */
|
|
41
|
+
isExpanded?: boolean;
|
|
42
|
+
/** Callback fired when the expanded state changes */
|
|
43
|
+
onExpandChange?: (expanded: boolean) => void;
|
|
44
|
+
/** Custom backend URL override (for self-hosted deployments) */
|
|
45
|
+
backendUrl?: string;
|
|
46
|
+
/** Display mode: 'floating' (bottom corner) or 'inline' (embedded in container) */
|
|
47
|
+
mode?: 'floating' | 'inline';
|
|
48
|
+
/** Enable proactive greeting tooltip above trigger when collapsed (default: true) */
|
|
49
|
+
greetingTooltipEnabled?: boolean;
|
|
50
|
+
/** Custom tooltip text; if empty, uses agent first message or default */
|
|
51
|
+
greetingTooltipText?: string;
|
|
52
|
+
/** Agent name from config (used for tooltip before store loads agent) */
|
|
53
|
+
initialAgentName?: string;
|
|
54
|
+
/** Agent first message from config (used for tooltip before store loads agent) */
|
|
55
|
+
initialAgentFirstMessage?: string;
|
|
56
|
+
}
|
|
57
|
+
declare const ChatWidget: React.FC<ChatWidgetProps>;
|
|
58
|
+
export default ChatWidget;
|