@mypatientspace/chatbot-widget 1.0.74 → 1.0.76
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 +193 -154
- package/dist/mypatientspace-demo.es.js +7205 -7048
- package/dist/mypatientspace-demo.umd.js +343 -284
- package/dist/mypatientspace-widget.es.js +4921 -4827
- package/dist/mypatientspace-widget.umd.js +197 -138
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,14 @@ A standalone chatbot widget that third-party websites can embed via a single `<s
|
|
|
8
8
|
|
|
9
9
|
- Self-contained React application bundled into a single JS file
|
|
10
10
|
- Easy integration with any website
|
|
11
|
-
-
|
|
12
|
-
- Customizable theming
|
|
11
|
+
- Embedded mode (default) or floating button mode
|
|
12
|
+
- Customizable theming with light, dark, and system color modes
|
|
13
13
|
- Style isolation (won't conflict with host site CSS)
|
|
14
14
|
- Native mobile support via WebView
|
|
15
|
+
- Voice input support
|
|
16
|
+
- Quick action buttons
|
|
17
|
+
- Survey/questionnaire support
|
|
18
|
+
- Content citations with overlay view
|
|
15
19
|
|
|
16
20
|
## Tech Stack
|
|
17
21
|
|
|
@@ -83,57 +87,6 @@ yarn build:demo # Demo only
|
|
|
83
87
|
yarn preview
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
## Demo Widget
|
|
87
|
-
|
|
88
|
-
An embeddable demo page with configuration panel and live preview. Useful for testing and showcasing the widget.
|
|
89
|
-
|
|
90
|
-
### Via CDN
|
|
91
|
-
|
|
92
|
-
```html
|
|
93
|
-
<div id="chatbot-demo" style="height: 600px;"></div>
|
|
94
|
-
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-demo.umd.js"></script>
|
|
95
|
-
<script>
|
|
96
|
-
ChatbotWidgetDemo.init({
|
|
97
|
-
containerSelector: '#chatbot-demo',
|
|
98
|
-
showJsonEditor: true,
|
|
99
|
-
initialConfig: {
|
|
100
|
-
apiEndpoint: 'https://your-api.com/chat',
|
|
101
|
-
token: 'your-auth-token',
|
|
102
|
-
headerTitle: 'My Healthcare Bot',
|
|
103
|
-
theme: { colors: { primary: '#007bff' } }
|
|
104
|
-
},
|
|
105
|
-
onConfigChange: (config) => console.log('Config:', config)
|
|
106
|
-
});
|
|
107
|
-
</script>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
> **Note:** The "Use Mock API" toggle is only available in development mode (`yarn dev`). When embedding the demo in production, you must provide `apiEndpoint` and `token` in the `initialConfig`.
|
|
111
|
-
|
|
112
|
-
### Demo API
|
|
113
|
-
|
|
114
|
-
```javascript
|
|
115
|
-
ChatbotWidgetDemo.init(config); // Initialize demo
|
|
116
|
-
ChatbotWidgetDemo.destroy(); // Remove demo
|
|
117
|
-
ChatbotWidgetDemo.update(config); // Update configuration
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Demo Configuration
|
|
121
|
-
|
|
122
|
-
| Option | Type | Default | Description |
|
|
123
|
-
|--------|------|---------|-------------|
|
|
124
|
-
| `containerSelector` | `string` | Required | CSS selector for container |
|
|
125
|
-
| `showConfigPanel` | `boolean` | `true` | Show left config panel |
|
|
126
|
-
| `showPreviewPanel` | `boolean` | `true` | Show right preview panel |
|
|
127
|
-
| `showJsonEditor` | `boolean` | `true` | Show Form/JSON toggle |
|
|
128
|
-
| `showDisplaySettings` | `boolean` | `true` | Show display settings section |
|
|
129
|
-
| `showSessionSettings` | `boolean` | `true` | Show session settings section |
|
|
130
|
-
| `showAppearanceSettings` | `boolean` | `true` | Show appearance section |
|
|
131
|
-
| `showThemeSettings` | `boolean` | `true` | Show theme colors section |
|
|
132
|
-
| `showContentSettings` | `boolean` | `true` | Show content settings section |
|
|
133
|
-
| `showQuickActions` | `boolean` | `true` | Show quick actions section |
|
|
134
|
-
| `initialConfig` | `Partial<WidgetConfig>` | `{}` | Pre-fill widget config (including `apiEndpoint` and `token`) |
|
|
135
|
-
| `onConfigChange` | `(config) => void` | - | Called when config changes |
|
|
136
|
-
|
|
137
90
|
## Web Integration
|
|
138
91
|
|
|
139
92
|
### Minimal Setup
|
|
@@ -141,7 +94,7 @@ ChatbotWidgetDemo.update(config); // Update configuration
|
|
|
141
94
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
142
95
|
<script>
|
|
143
96
|
ChatbotWidget.init({
|
|
144
|
-
apiEndpoint: 'https://your-api.com
|
|
97
|
+
apiEndpoint: 'https://your-api.com',
|
|
145
98
|
token: 'your-auth-token'
|
|
146
99
|
});
|
|
147
100
|
</script>
|
|
@@ -152,60 +105,61 @@ ChatbotWidgetDemo.update(config); // Update configuration
|
|
|
152
105
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
153
106
|
<script>
|
|
154
107
|
ChatbotWidget.init({
|
|
155
|
-
|
|
108
|
+
// API & Auth
|
|
109
|
+
apiEndpoint: 'https://your-api.com',
|
|
156
110
|
token: 'your-auth-token',
|
|
111
|
+
userType: 'patient', // 'patient' (default) or 'staff'
|
|
112
|
+
assistantId: 'your-assistant-id',
|
|
113
|
+
|
|
114
|
+
// Display mode
|
|
115
|
+
floatingMode: true, // false = embedded (default), true = FAB button
|
|
116
|
+
position: 'bottom-left', // FAB position (default: 'bottom-right')
|
|
117
|
+
hideExpandButton: true, // Hide expand/minimize button from header
|
|
118
|
+
showCloseSlot: true, // Empty placeholder for custom close button
|
|
119
|
+
|
|
120
|
+
// Content
|
|
157
121
|
headerTitle: 'Health Support',
|
|
122
|
+
headerSubtitle: 'Online now',
|
|
158
123
|
greeting: 'Hi! How can I help?',
|
|
124
|
+
placeholder: 'Ask me anything...',
|
|
159
125
|
brandingText: 'Powered by MyCompany',
|
|
126
|
+
disclaimerText: 'AI can make mistakes. Verify important information.',
|
|
160
127
|
headerIcon: '/logo.png',
|
|
161
|
-
fabIcon: '/avatar.png',
|
|
162
|
-
placeholder: 'Ask me anything...',
|
|
163
|
-
position: 'bottom-left',
|
|
164
|
-
colorMode: 'system', // 'light', 'dark', or 'system' (auto-detect)
|
|
128
|
+
fabIcon: '/avatar.png', // Only used in floating mode
|
|
165
129
|
quickActions: ['I need help', 'Book appointment'],
|
|
130
|
+
|
|
131
|
+
// Appearance
|
|
132
|
+
colorMode: 'system', // 'light', 'dark', or 'system' (auto-detect)
|
|
166
133
|
theme: {
|
|
167
|
-
// All color properties are optional - only set what you want to change
|
|
168
134
|
colors: {
|
|
169
|
-
// Main colors
|
|
170
135
|
primary: '#ff6600', // FAB button, links, main accent
|
|
171
136
|
primaryDark: '#cc5200', // Hover states
|
|
172
137
|
secondary: '#2d3748', // Header background
|
|
173
|
-
|
|
174
|
-
accentLight: '#bee3f8', // Light accent
|
|
175
|
-
|
|
176
|
-
// Status colors
|
|
177
|
-
success: '#48bb78', // Success states
|
|
178
|
-
info: '#4299e1', // Info states
|
|
179
|
-
error: '#f56565', // Error states
|
|
180
|
-
|
|
181
|
-
// Background colors
|
|
138
|
+
headerText: '#ffffff', // Header text color
|
|
182
139
|
background: '#ffffff', // Chat window background
|
|
183
140
|
surface: '#f7fafc', // Input/card backgrounds
|
|
184
|
-
|
|
185
|
-
// Text colors
|
|
186
141
|
text: '#2d3748', // Primary text
|
|
187
142
|
textLight: '#718096', // Secondary text, timestamps
|
|
188
|
-
|
|
189
|
-
// Message bubbles
|
|
190
143
|
userBubble: '#ff6600', // User message background
|
|
191
144
|
userBubbleText: '#ffffff', // User message text
|
|
192
145
|
botBubble: '#edf2f7', // Bot message background
|
|
193
146
|
botBubbleText: '#2d3748', // Bot message text
|
|
194
|
-
|
|
195
|
-
// Borders
|
|
196
|
-
border: '#e2e8f0', // Border color
|
|
197
|
-
borderLight: '#edf2f7', // Light border
|
|
198
|
-
|
|
199
|
-
// Other
|
|
200
|
-
white: '#ffffff', // White color
|
|
201
|
-
recording: '#f56565', // Voice recording indicator
|
|
202
147
|
},
|
|
203
|
-
|
|
204
|
-
// Typography and shape
|
|
205
148
|
fontFamily: 'Inter, system-ui, sans-serif',
|
|
206
149
|
borderRadius: '8px',
|
|
207
150
|
shadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
208
|
-
}
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
// Callbacks
|
|
154
|
+
onOpen: () => console.log('Chat opened'),
|
|
155
|
+
onClose: () => console.log('Chat closed'),
|
|
156
|
+
onMessageSent: (message) => console.log('Sent:', message),
|
|
157
|
+
onMessageReceived: (message) => console.log('Received:', message),
|
|
158
|
+
onQuickAction: (action) => console.log('Quick action:', action),
|
|
159
|
+
onStreamChunk: (chunk) => console.log('Chunk:', chunk),
|
|
160
|
+
onCitationClick: (citation) => console.log('Citation:', citation),
|
|
161
|
+
onNewChat: () => console.log('New chat started'),
|
|
162
|
+
onWidgetReady: (api) => console.log('Widget ready:', api),
|
|
209
163
|
});
|
|
210
164
|
</script>
|
|
211
165
|
```
|
|
@@ -215,21 +169,76 @@ ChatbotWidgetDemo.update(config); // Update configuration
|
|
|
215
169
|
import '@mypatientspace/chatbot-widget';
|
|
216
170
|
|
|
217
171
|
ChatbotWidget.init({
|
|
218
|
-
apiEndpoint: 'https://your-api.com
|
|
172
|
+
apiEndpoint: 'https://your-api.com'
|
|
219
173
|
});
|
|
220
174
|
```
|
|
221
175
|
|
|
176
|
+
### Patient & Staff Integration
|
|
177
|
+
|
|
178
|
+
The widget supports two user types with separate API routing. Each type uses different backend endpoints for chat, message history, and assistant lookup.
|
|
179
|
+
|
|
180
|
+
#### Patient (Default)
|
|
181
|
+
|
|
182
|
+
Patient mode is the default — no `userType` needed:
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<script>
|
|
186
|
+
ChatbotWidget.init({
|
|
187
|
+
apiEndpoint: 'https://your-api.com',
|
|
188
|
+
token: 'your-auth-token'
|
|
189
|
+
});
|
|
190
|
+
</script>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
API endpoints used:
|
|
194
|
+
- `POST /api/patient/chat/stream` — Send messages
|
|
195
|
+
- `GET /api/patient/chat/messages` — Load history
|
|
196
|
+
- `GET /api/patient/assistant` — Get assistant config
|
|
197
|
+
|
|
198
|
+
#### Staff
|
|
199
|
+
|
|
200
|
+
Staff mode requires `userType: 'staff'` along with `contextPatientId` and `patientTypeId`:
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<script>
|
|
204
|
+
ChatbotWidget.init({
|
|
205
|
+
apiEndpoint: 'https://your-api.com',
|
|
206
|
+
token: 'your-auth-token',
|
|
207
|
+
userType: 'staff',
|
|
208
|
+
contextPatientId: 'patient-123',
|
|
209
|
+
patientTypeId: 'type-456'
|
|
210
|
+
});
|
|
211
|
+
</script>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
API endpoints used:
|
|
215
|
+
- `POST /api/staff/chat/stream` — Send messages (includes `contextPatientId` in body)
|
|
216
|
+
- `GET /api/staff/chat/messages` — Load history (requires `contextPatientId` query param)
|
|
217
|
+
- `GET /api/staff/assistant/{patientTypeId}` — Get assistant config
|
|
218
|
+
|
|
219
|
+
#### Required Fields by User Type
|
|
220
|
+
|
|
221
|
+
| Field | Patient | Staff |
|
|
222
|
+
|-------|---------|-------|
|
|
223
|
+
| `apiEndpoint` | Required | Required |
|
|
224
|
+
| `token` | Required | Required |
|
|
225
|
+
| `userType` | Optional (default) | `'staff'` |
|
|
226
|
+
| `contextPatientId` | Optional | Required |
|
|
227
|
+
| `patientTypeId` | - | Required |
|
|
228
|
+
|
|
222
229
|
### API Methods
|
|
223
230
|
```javascript
|
|
224
|
-
ChatbotWidget.open();
|
|
225
|
-
ChatbotWidget.close();
|
|
226
|
-
ChatbotWidget.toggle();
|
|
227
|
-
ChatbotWidget.
|
|
231
|
+
ChatbotWidget.open(); // Open chat window
|
|
232
|
+
ChatbotWidget.close(); // Close chat window
|
|
233
|
+
ChatbotWidget.toggle(); // Toggle open/close
|
|
234
|
+
ChatbotWidget.startNewChat(); // Clear session and start new chat
|
|
235
|
+
ChatbotWidget.update(config); // Update widget configuration
|
|
236
|
+
ChatbotWidget.destroy(); // Remove widget completely
|
|
228
237
|
```
|
|
229
238
|
|
|
230
239
|
## Embedded Mode
|
|
231
240
|
|
|
232
|
-
By default, the widget
|
|
241
|
+
By default, the widget is embedded inside a container element. You can enable floating mode for a FAB button popup.
|
|
233
242
|
|
|
234
243
|
### Using containerSelector
|
|
235
244
|
|
|
@@ -241,7 +250,7 @@ Embed the chat inside an existing element:
|
|
|
241
250
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
242
251
|
<script>
|
|
243
252
|
ChatbotWidget.init({
|
|
244
|
-
apiEndpoint: 'https://your-api.com
|
|
253
|
+
apiEndpoint: 'https://your-api.com',
|
|
245
254
|
containerSelector: '#my-chat'
|
|
246
255
|
});
|
|
247
256
|
</script>
|
|
@@ -254,7 +263,7 @@ Enable floating mode with FAB button (classic chatbot style):
|
|
|
254
263
|
```html
|
|
255
264
|
<script>
|
|
256
265
|
ChatbotWidget.init({
|
|
257
|
-
apiEndpoint: 'https://your-api.com
|
|
266
|
+
apiEndpoint: 'https://your-api.com',
|
|
258
267
|
floatingMode: true
|
|
259
268
|
});
|
|
260
269
|
</script>
|
|
@@ -294,7 +303,7 @@ class ChatActivity : AppCompatActivity() {
|
|
|
294
303
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
295
304
|
<script>
|
|
296
305
|
ChatbotWidget.init({
|
|
297
|
-
apiEndpoint: 'https://your-api.com
|
|
306
|
+
apiEndpoint: 'https://your-api.com'
|
|
298
307
|
});
|
|
299
308
|
ChatbotWidget.open();
|
|
300
309
|
</script>
|
|
@@ -338,7 +347,7 @@ class ChatViewController: UIViewController {
|
|
|
338
347
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
339
348
|
<script>
|
|
340
349
|
ChatbotWidget.init({
|
|
341
|
-
apiEndpoint: 'https://your-api.com
|
|
350
|
+
apiEndpoint: 'https://your-api.com'
|
|
342
351
|
});
|
|
343
352
|
ChatbotWidget.open();
|
|
344
353
|
</script>
|
|
@@ -351,6 +360,48 @@ class ChatViewController: UIViewController {
|
|
|
351
360
|
}
|
|
352
361
|
```
|
|
353
362
|
|
|
363
|
+
### iOS (Objective-C)
|
|
364
|
+
```objc
|
|
365
|
+
#import <UIKit/UIKit.h>
|
|
366
|
+
#import <WebKit/WebKit.h>
|
|
367
|
+
|
|
368
|
+
@interface ChatViewController : UIViewController
|
|
369
|
+
@property (nonatomic, strong) WKWebView *webView;
|
|
370
|
+
@end
|
|
371
|
+
|
|
372
|
+
@implementation ChatViewController
|
|
373
|
+
|
|
374
|
+
- (void)viewDidLoad {
|
|
375
|
+
[super viewDidLoad];
|
|
376
|
+
|
|
377
|
+
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
|
|
378
|
+
config.preferences.javaScriptEnabled = YES;
|
|
379
|
+
|
|
380
|
+
self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
|
|
381
|
+
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
382
|
+
[self.view addSubview:self.webView];
|
|
383
|
+
|
|
384
|
+
NSString *html = @"<!DOCTYPE html>"
|
|
385
|
+
"<html>"
|
|
386
|
+
"<head>"
|
|
387
|
+
"<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>"
|
|
388
|
+
"<style>body { margin: 0; padding: 0; }</style>"
|
|
389
|
+
"</head>"
|
|
390
|
+
"<body>"
|
|
391
|
+
"<script src='https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js'></script>"
|
|
392
|
+
"<script>"
|
|
393
|
+
"ChatbotWidget.init({ apiEndpoint: 'https://your-api.com' });"
|
|
394
|
+
"ChatbotWidget.open();"
|
|
395
|
+
"</script>"
|
|
396
|
+
"</body>"
|
|
397
|
+
"</html>";
|
|
398
|
+
|
|
399
|
+
[self.webView loadHTMLString:html baseURL:[NSURL URLWithString:@"https://your-domain.com"]];
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
@end
|
|
403
|
+
```
|
|
404
|
+
|
|
354
405
|
### React Native
|
|
355
406
|
```jsx
|
|
356
407
|
import { WebView } from 'react-native-webview';
|
|
@@ -366,7 +417,7 @@ const ChatScreen = () => {
|
|
|
366
417
|
<script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
|
|
367
418
|
<script>
|
|
368
419
|
ChatbotWidget.init({
|
|
369
|
-
apiEndpoint: 'https://your-api.com
|
|
420
|
+
apiEndpoint: 'https://your-api.com'
|
|
370
421
|
});
|
|
371
422
|
ChatbotWidget.open();
|
|
372
423
|
</script>
|
|
@@ -388,27 +439,34 @@ const ChatScreen = () => {
|
|
|
388
439
|
|
|
389
440
|
### All Options
|
|
390
441
|
|
|
391
|
-
| Option | Type |
|
|
392
|
-
|
|
393
|
-
| `apiEndpoint` | `string` |
|
|
394
|
-
| `token` | `string` |
|
|
395
|
-
| `
|
|
396
|
-
| `
|
|
397
|
-
| `
|
|
398
|
-
| `
|
|
399
|
-
| `
|
|
400
|
-
| `
|
|
401
|
-
| `
|
|
402
|
-
| `
|
|
403
|
-
| `
|
|
404
|
-
| `
|
|
405
|
-
| `
|
|
406
|
-
| `
|
|
407
|
-
| `
|
|
408
|
-
| `
|
|
409
|
-
| `
|
|
410
|
-
| `
|
|
411
|
-
| `
|
|
442
|
+
| Option | Type | Default | Description |
|
|
443
|
+
|--------|------|---------|-------------|
|
|
444
|
+
| `apiEndpoint` | `string` | - | Base API URL, e.g. `https://your-api.com` (widget offline if not set) |
|
|
445
|
+
| `token` | `string` | - | Auth token for API requests |
|
|
446
|
+
| `userType` | `'patient' \| 'staff'` | `'patient'` | User type for API endpoint routing |
|
|
447
|
+
| `patientTypeId` | `string` | - | Patient type ID for staff assistant lookup (required when `userType` is `'staff'`) |
|
|
448
|
+
| `sessionId` | `string` | - | Existing session ID to resume |
|
|
449
|
+
| `assistantId` | `string` | - | Specific assistant ID to use |
|
|
450
|
+
| `contextPatientId` | `string` | - | Patient context for the chat |
|
|
451
|
+
| `loadHistory` | `boolean` | `true` | Load previous chat history |
|
|
452
|
+
| `colorMode` | `'light' \| 'dark' \| 'system'` | `'light'` | Color mode for the widget |
|
|
453
|
+
| `theme` | `ThemeConfig` | - | Custom theme colors, fonts, border radius, shadow |
|
|
454
|
+
| `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'` | FAB button position |
|
|
455
|
+
| `containerSelector` | `string` | - | CSS selector for embedded container |
|
|
456
|
+
| `floatingMode` | `boolean` | `false` | Show FAB button and floating chat |
|
|
457
|
+
| `hideExpandButton` | `boolean` | `false` | Hide the expand/minimize button from header |
|
|
458
|
+
| `showCloseSlot` | `boolean` | `false` | Show empty circle placeholder for custom close button |
|
|
459
|
+
| `greeting` | `string` | From API | Initial bot greeting message |
|
|
460
|
+
| `placeholder` | `string` | From API | Input field placeholder text |
|
|
461
|
+
| `headerTitle` | `string` | From API | Chat window header title |
|
|
462
|
+
| `headerSubtitle` | `string` | From API | Chat window header subtitle |
|
|
463
|
+
| `headerIcon` | `string` | From API | Header icon image URL |
|
|
464
|
+
| `fabIcon` | `string` | From API | FAB button image URL |
|
|
465
|
+
| `brandingText` | `string` | From API | Footer branding text |
|
|
466
|
+
| `disclaimerText` | `string` | From API | Disclaimer text below input area |
|
|
467
|
+
| `quickActions` | `string[]` | From API | Predefined quick action buttons |
|
|
468
|
+
|
|
469
|
+
> **Note:** Content fields (`greeting`, `headerTitle`, `placeholder`, `brandingText`, `headerIcon`, `fabIcon`, `quickActions`, `disclaimerText`) are loaded from the assistant's API configuration by default. Setting them in the widget config overrides the API values.
|
|
412
470
|
|
|
413
471
|
### Callbacks
|
|
414
472
|
|
|
@@ -420,35 +478,14 @@ const ChatScreen = () => {
|
|
|
420
478
|
| `onMessageReceived` | `(message: Message)` | Called after bot response completes |
|
|
421
479
|
| `onQuickAction` | `(action: string)` | Called when quick action is clicked |
|
|
422
480
|
| `onStreamChunk` | `(chunk: string)` | Called for each streamed response chunk |
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
```typescript
|
|
427
|
-
interface Message {
|
|
428
|
-
id: string;
|
|
429
|
-
content: string;
|
|
430
|
-
sender: 'user' | 'bot';
|
|
431
|
-
timestamp: Date;
|
|
432
|
-
status: 'sending' | 'sent' | 'error';
|
|
433
|
-
audioUrl?: string; // Base64 audio data URL for TTS playback
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
### ThemeConfig Interface
|
|
438
|
-
|
|
439
|
-
```typescript
|
|
440
|
-
interface ThemeConfig {
|
|
441
|
-
colors?: Partial<ThemeColors>; // Any subset of theme colors
|
|
442
|
-
fontFamily?: string;
|
|
443
|
-
borderRadius?: string;
|
|
444
|
-
shadow?: string;
|
|
445
|
-
}
|
|
446
|
-
```
|
|
481
|
+
| `onCitationClick` | `(citation: Citation)` | Called when a content card is clicked |
|
|
482
|
+
| `onNewChat` | `()` | Called when user starts a new chat |
|
|
483
|
+
| `onWidgetReady` | `(api: WidgetApi)` | Called when widget is ready with API methods |
|
|
447
484
|
|
|
448
485
|
### Available Theme Colors
|
|
449
486
|
|
|
450
|
-
| Color | Default | Description |
|
|
451
|
-
|
|
487
|
+
| Color | Light Default | Description |
|
|
488
|
+
|-------|---------------|-------------|
|
|
452
489
|
| `primary` | `#00c2d1` | FAB button, links, main accent |
|
|
453
490
|
| `primaryDark` | `#017992` | Hover states |
|
|
454
491
|
| `secondary` | `#3c4d73` | Header background |
|
|
@@ -467,25 +504,27 @@ interface ThemeConfig {
|
|
|
467
504
|
| `border` | `#d1d5db` | Border color |
|
|
468
505
|
| `borderLight` | `#e5e7eb` | Light border |
|
|
469
506
|
| `error` | `#ef4444` | Error states |
|
|
507
|
+
| `errorBackground` | `#fef2f2` | Error background |
|
|
470
508
|
| `white` | `#ffffff` | White color |
|
|
471
509
|
| `recording` | `#ef4444` | Voice recording indicator |
|
|
510
|
+
| `headerText` | `#ffffff` | Header text and icon color |
|
|
511
|
+
| `scrollbarThumb` | `rgba(60, 77, 115, 0.2)` | Scrollbar thumb color |
|
|
512
|
+
| `scrollbarThumbHover` | `rgba(60, 77, 115, 0.3)` | Scrollbar thumb hover |
|
|
513
|
+
|
|
514
|
+
### Default Fallback Values
|
|
472
515
|
|
|
473
|
-
|
|
516
|
+
Content fields are resolved with this priority: **Config > Assistant API > Component default**
|
|
474
517
|
|
|
475
|
-
|
|
|
476
|
-
|
|
518
|
+
| Field | Component Fallback |
|
|
519
|
+
|-------|-------------------|
|
|
477
520
|
| `headerTitle` | "AI Doctor" |
|
|
478
521
|
| `greeting` | "Hello! Welcome to our healthcare support. How can I assist you today?" |
|
|
479
522
|
| `placeholder` | "Type a message..." |
|
|
480
523
|
| `brandingText` | "Developed by myPatientSpace" |
|
|
481
|
-
| `
|
|
482
|
-
| `
|
|
483
|
-
| `
|
|
484
|
-
| `
|
|
485
|
-
| `loadHistory` | true |
|
|
486
|
-
| `containerSelector` | undefined (creates container in body) |
|
|
487
|
-
| `floatingMode` | false (embedded is default) |
|
|
488
|
-
| `quickActions` | Book Appointment, Hours, Contact, Location |
|
|
524
|
+
| `disclaimerText` | "AI can make mistakes. Verify important information." |
|
|
525
|
+
| `headerIcon` | MPS logo |
|
|
526
|
+
| `fabIcon` | MPS logo |
|
|
527
|
+
| `quickActions` | Empty (from API only) |
|
|
489
528
|
|
|
490
529
|
## License
|
|
491
530
|
|