@mypatientspace/chatbot-widget 1.0.75 → 1.0.77

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
@@ -94,7 +94,7 @@ yarn preview
94
94
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
95
95
  <script>
96
96
  ChatbotWidget.init({
97
- apiEndpoint: 'https://your-api.com/chat',
97
+ apiEndpoint: 'https://your-api.com',
98
98
  token: 'your-auth-token'
99
99
  });
100
100
  </script>
@@ -106,8 +106,9 @@ yarn preview
106
106
  <script>
107
107
  ChatbotWidget.init({
108
108
  // API & Auth
109
- apiEndpoint: 'https://your-api.com/chat',
109
+ apiEndpoint: 'https://your-api.com',
110
110
  token: 'your-auth-token',
111
+ userType: 'patient', // 'patient' (default) or 'staff'
111
112
  assistantId: 'your-assistant-id',
112
113
 
113
114
  // Display mode
@@ -168,10 +169,63 @@ yarn preview
168
169
  import '@mypatientspace/chatbot-widget';
169
170
 
170
171
  ChatbotWidget.init({
171
- apiEndpoint: 'https://your-api.com/chat'
172
+ apiEndpoint: 'https://your-api.com'
172
173
  });
173
174
  ```
174
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
+
175
229
  ### API Methods
176
230
  ```javascript
177
231
  ChatbotWidget.open(); // Open chat window
@@ -196,7 +250,7 @@ Embed the chat inside an existing element:
196
250
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
197
251
  <script>
198
252
  ChatbotWidget.init({
199
- apiEndpoint: 'https://your-api.com/chat',
253
+ apiEndpoint: 'https://your-api.com',
200
254
  containerSelector: '#my-chat'
201
255
  });
202
256
  </script>
@@ -209,7 +263,7 @@ Enable floating mode with FAB button (classic chatbot style):
209
263
  ```html
210
264
  <script>
211
265
  ChatbotWidget.init({
212
- apiEndpoint: 'https://your-api.com/chat',
266
+ apiEndpoint: 'https://your-api.com',
213
267
  floatingMode: true
214
268
  });
215
269
  </script>
@@ -249,7 +303,7 @@ class ChatActivity : AppCompatActivity() {
249
303
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
250
304
  <script>
251
305
  ChatbotWidget.init({
252
- apiEndpoint: 'https://your-api.com/chat'
306
+ apiEndpoint: 'https://your-api.com'
253
307
  });
254
308
  ChatbotWidget.open();
255
309
  </script>
@@ -293,7 +347,7 @@ class ChatViewController: UIViewController {
293
347
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
294
348
  <script>
295
349
  ChatbotWidget.init({
296
- apiEndpoint: 'https://your-api.com/chat'
350
+ apiEndpoint: 'https://your-api.com'
297
351
  });
298
352
  ChatbotWidget.open();
299
353
  </script>
@@ -336,7 +390,7 @@ class ChatViewController: UIViewController {
336
390
  "<body>"
337
391
  "<script src='https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js'></script>"
338
392
  "<script>"
339
- "ChatbotWidget.init({ apiEndpoint: 'https://your-api.com/chat' });"
393
+ "ChatbotWidget.init({ apiEndpoint: 'https://your-api.com' });"
340
394
  "ChatbotWidget.open();"
341
395
  "</script>"
342
396
  "</body>"
@@ -363,7 +417,7 @@ const ChatScreen = () => {
363
417
  <script src="https://unpkg.com/@mypatientspace/chatbot-widget@latest/dist/mypatientspace-widget.umd.js"></script>
364
418
  <script>
365
419
  ChatbotWidget.init({
366
- apiEndpoint: 'https://your-api.com/chat'
420
+ apiEndpoint: 'https://your-api.com'
367
421
  });
368
422
  ChatbotWidget.open();
369
423
  </script>
@@ -387,8 +441,10 @@ const ChatScreen = () => {
387
441
 
388
442
  | Option | Type | Default | Description |
389
443
  |--------|------|---------|-------------|
390
- | `apiEndpoint` | `string` | - | Chat API endpoint URL (widget offline if not set) |
444
+ | `apiEndpoint` | `string` | - | Base API URL, e.g. `https://your-api.com` (widget offline if not set) |
391
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'`) |
392
448
  | `sessionId` | `string` | - | Existing session ID to resume |
393
449
  | `assistantId` | `string` | - | Specific assistant ID to use |
394
450
  | `contextPatientId` | `string` | - | Patient context for the chat |