@mypatientspace/chatbot-widget 1.0.32 → 1.0.34

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 CHANGED
@@ -83,12 +83,13 @@ yarn preview
83
83
 
84
84
  ## Web Integration
85
85
 
86
- ### Minimal Setup (uses all defaults)
86
+ ### Minimal Setup
87
87
  ```html
88
88
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
89
89
  <script>
90
90
  ChatbotWidget.init({
91
- apiEndpoint: 'https://your-api.com/chat'
91
+ apiEndpoint: 'https://your-api.com/chat',
92
+ token: 'your-auth-token'
92
93
  });
93
94
  </script>
94
95
  ```
@@ -99,19 +100,57 @@ yarn preview
99
100
  <script>
100
101
  ChatbotWidget.init({
101
102
  apiEndpoint: 'https://your-api.com/chat',
102
- apiKey: 'your-api-key',
103
+ token: 'your-auth-token',
103
104
  headerTitle: 'Health Support',
104
105
  greeting: 'Hi! How can I help?',
105
106
  brandingText: 'Powered by MyCompany',
106
- brandingLogo: '/logo.png',
107
+ headerIcon: '/logo.png',
107
108
  fabIcon: '/avatar.png',
108
109
  placeholder: 'Ask me anything...',
109
110
  position: 'bottom-left',
110
- quickActions: [
111
- { id: '1', label: 'Help', icon: 'info', message: 'I need help' }
112
- ],
111
+ quickActions: ['I need help', 'Book appointment'],
113
112
  theme: {
114
- colors: { primary: '#ff6600' }
113
+ // All color properties are optional - only set what you want to change
114
+ colors: {
115
+ // Main colors
116
+ primary: '#ff6600', // FAB button, links, main accent
117
+ primaryDark: '#cc5200', // Hover states
118
+ secondary: '#2d3748', // Header background
119
+ accent: '#4299e1', // Secondary accent
120
+ accentLight: '#bee3f8', // Light accent
121
+
122
+ // Status colors
123
+ success: '#48bb78', // Success states
124
+ info: '#4299e1', // Info states
125
+ error: '#f56565', // Error states
126
+
127
+ // Background colors
128
+ background: '#ffffff', // Chat window background
129
+ surface: '#f7fafc', // Input/card backgrounds
130
+
131
+ // Text colors
132
+ text: '#2d3748', // Primary text
133
+ textLight: '#718096', // Secondary text, timestamps
134
+
135
+ // Message bubbles
136
+ userBubble: '#ff6600', // User message background
137
+ userBubbleText: '#ffffff', // User message text
138
+ botBubble: '#edf2f7', // Bot message background
139
+ botBubbleText: '#2d3748', // Bot message text
140
+
141
+ // Borders
142
+ border: '#e2e8f0', // Border color
143
+ borderLight: '#edf2f7', // Light border
144
+
145
+ // Other
146
+ white: '#ffffff', // White color
147
+ recording: '#f56565', // Voice recording indicator
148
+ },
149
+
150
+ // Typography and shape
151
+ fontFamily: 'Inter, system-ui, sans-serif',
152
+ borderRadius: '8px',
153
+ shadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
115
154
  }
116
155
  });
117
156
  </script>
@@ -154,28 +193,27 @@ Embed the chat inside an existing element:
154
193
  </script>
155
194
  ```
156
195
 
157
- ### Using embedMode
196
+ ### Using floatingMode
158
197
 
159
- Enable embedded styling without a specific container:
198
+ Enable floating mode with FAB button (classic chatbot style):
160
199
 
161
200
  ```html
162
201
  <script>
163
202
  ChatbotWidget.init({
164
203
  apiEndpoint: 'https://your-api.com/chat',
165
- embedMode: true
204
+ floatingMode: true
166
205
  });
167
206
  </script>
168
207
  ```
169
208
 
170
209
  ### Comparison
171
210
 
172
- | Feature | `containerSelector` | `embedMode: true` |
173
- |---------|---------------------|-------------------|
174
- | Container | Your element | Auto-created |
175
- | Sizing | Your CSS controls it | 100% of parent |
176
- | FAB button | Hidden | Hidden |
177
- | Chat visibility | Always open | Always open |
178
- | On destroy | Container preserved | Container removed |
211
+ | Feature | Embedded (default) | `floatingMode: true` |
212
+ |---------|-------------------|----------------------|
213
+ | FAB button | Hidden | Shown |
214
+ | Chat visibility | Always open | Opens on click |
215
+ | Position | Fills container | Fixed bottom-right/left |
216
+ | Sizing | 100% of parent | 380x520px |
179
217
 
180
218
  ## Mobile Integration
181
219
 
@@ -292,9 +330,92 @@ const ChatScreen = () => {
292
330
  };
293
331
  ```
294
332
 
295
- ## Default Configuration
333
+ ## Configuration Reference
334
+
335
+ ### All Options
336
+
337
+ | Option | Type | Required | Description |
338
+ |--------|------|----------|-------------|
339
+ | `apiEndpoint` | `string` | No | Chat API endpoint URL (widget offline if not set) |
340
+ | `token` | `string` | No | Auth token for API requests |
341
+ | `sessionId` | `string` | No | Existing session ID to resume |
342
+ | `assistantId` | `string` | No | Specific assistant ID to use |
343
+ | `contextPatientId` | `string` | No | Patient context for the chat |
344
+ | `loadHistory` | `boolean` | No | Load previous chat history (default: true) |
345
+ | `theme` | `ThemeConfig` | No | Custom theme (see Theme Configuration below) |
346
+ | `position` | `'bottom-right' \| 'bottom-left'` | No | FAB button position |
347
+ | `containerSelector` | `string` | No | CSS selector for embedded container |
348
+ | `floatingMode` | `boolean` | No | Show FAB button and floating chat (default: false) |
349
+ | `greeting` | `string` | No | Initial bot greeting message |
350
+ | `placeholder` | `string` | No | Input field placeholder text |
351
+ | `headerTitle` | `string` | No | Chat window header title |
352
+ | `headerSubtitle` | `string` | No | Chat window header subtitle |
353
+ | `headerIcon` | `string` | No | Header icon image URL |
354
+ | `fabIcon` | `string` | No | FAB button image URL |
355
+ | `brandingText` | `string` | No | Footer branding text |
356
+ | `quickActions` | `string[]` | No | Predefined quick action buttons (displayed as labels and sent as messages) |
357
+
358
+ ### Callbacks
359
+
360
+ | Callback | Parameters | Description |
361
+ |----------|------------|-------------|
362
+ | `onOpen` | `()` | Called when chat window opens |
363
+ | `onClose` | `()` | Called when chat window closes |
364
+ | `onMessageSent` | `(message: Message)` | Called after user sends a message |
365
+ | `onMessageReceived` | `(message: Message)` | Called after bot response completes |
366
+ | `onQuickAction` | `(action: string)` | Called when quick action is clicked |
367
+ | `onStreamChunk` | `(chunk: string)` | Called for each streamed response chunk |
368
+
369
+ ### Message Interface
370
+
371
+ ```typescript
372
+ interface Message {
373
+ id: string;
374
+ content: string;
375
+ sender: 'user' | 'bot';
376
+ timestamp: Date;
377
+ status: 'sending' | 'sent' | 'error';
378
+ audioUrl?: string; // Base64 audio data URL for TTS playback
379
+ }
380
+ ```
381
+
382
+ ### ThemeConfig Interface
383
+
384
+ ```typescript
385
+ interface ThemeConfig {
386
+ colors?: Partial<ThemeColors>; // Any subset of theme colors
387
+ fontFamily?: string;
388
+ borderRadius?: string;
389
+ shadow?: string;
390
+ }
391
+ ```
296
392
 
297
- When no value is provided, these defaults are used:
393
+ ### Available Theme Colors
394
+
395
+ | Color | Default | Description |
396
+ |-------|---------|-------------|
397
+ | `primary` | `#00c2d1` | FAB button, links, main accent |
398
+ | `primaryDark` | `#017992` | Hover states |
399
+ | `secondary` | `#3c4d73` | Header background |
400
+ | `accent` | `#33b1e6` | Secondary accent color |
401
+ | `accentLight` | `#b8ebff` | Light accent |
402
+ | `success` | `#00dec4` | Success states |
403
+ | `info` | `#30d7ed` | Info states |
404
+ | `background` | `#ffffff` | Chat window background |
405
+ | `surface` | `#fdfefe` | Input/card backgrounds |
406
+ | `text` | `#3c4d73` | Primary text |
407
+ | `textLight` | `#6b7280` | Secondary text, timestamps |
408
+ | `userBubble` | `#00c2d1` | User message background |
409
+ | `userBubbleText` | `#ffffff` | User message text |
410
+ | `botBubble` | `#e0f7fa` | Bot message background |
411
+ | `botBubbleText` | `#3c4d73` | Bot message text |
412
+ | `border` | `#d1d5db` | Border color |
413
+ | `borderLight` | `#e5e7eb` | Light border |
414
+ | `error` | `#ef4444` | Error states |
415
+ | `white` | `#ffffff` | White color |
416
+ | `recording` | `#ef4444` | Voice recording indicator |
417
+
418
+ ## Default Values
298
419
 
299
420
  | Option | Default Value |
300
421
  |--------|---------------|
@@ -302,11 +423,12 @@ When no value is provided, these defaults are used:
302
423
  | `greeting` | "Hello! Welcome to our healthcare support. How can I assist you today?" |
303
424
  | `placeholder` | "Type a message..." |
304
425
  | `brandingText` | "Developed by myPatientSpace" |
305
- | `brandingLogo` | https://web.mypatientspace.com/img/logo-symbol.png |
426
+ | `headerIcon` | https://web.mypatientspace.com/img/logo-symbol.png |
306
427
  | `fabIcon` | https://web.mypatientspace.com/img/logo-symbol.png |
307
428
  | `position` | "bottom-right" |
308
- | `containerSelector` | undefined (floating mode) |
309
- | `embedMode` | false (auto-enabled when containerSelector is set) |
429
+ | `loadHistory` | true |
430
+ | `containerSelector` | undefined (creates container in body) |
431
+ | `floatingMode` | false (embedded is default) |
310
432
  | `quickActions` | Book Appointment, Hours, Contact, Location |
311
433
 
312
434
  ## License