@snf/qa-bot-core 0.2.11-rc.3 → 0.2.11
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 +43 -1
- package/build/static/js/main.js +1 -1
- package/build/static/js/main.js.map +1 -1
- package/dist/qa-bot-core.js +2 -2
- package/dist/qa-bot-core.js.map +1 -1
- package/dist/qa-bot-core.standalone.js +3 -3
- package/dist/qa-bot-core.standalone.js.map +1 -1
- package/dist/qa-bot-core.umd.cjs +1 -1
- package/dist/qa-bot-core.umd.cjs.map +1 -1
- package/dist/types/utils/fix-markdown-links.d.ts +9 -3
- package/dist/types/utils/logger.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -332,6 +332,47 @@ const processedFlow = applyFlowSettings(myFlow, {
|
|
|
332
332
|
|
|
333
333
|
The `disableOnOptions: true` setting automatically sets `chatDisabled: true` for steps that have `options` or `checkboxes`, and `chatDisabled: false` for steps without them (unless you've explicitly set `chatDisabled` yourself).
|
|
334
334
|
|
|
335
|
+
#### History Tracking for Custom Flows
|
|
336
|
+
|
|
337
|
+
When building custom flows, you may want certain important messages to be saved in session history so they can be restored when a user revisits a previous session. By default, messages defined with the `message:` property in flow steps may not be tracked in history.
|
|
338
|
+
|
|
339
|
+
Use the `withHistory` and `withHistoryFn` helpers to ensure messages are tracked:
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
import { withHistory, withHistoryFn } from '@snf/qa-bot-core';
|
|
343
|
+
|
|
344
|
+
const myFlow = {
|
|
345
|
+
// Static message - use withHistory()
|
|
346
|
+
ask_email: {
|
|
347
|
+
message: withHistory("Please enter your email address:"),
|
|
348
|
+
path: "next_step"
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
// Dynamic message - use withHistoryFn()
|
|
352
|
+
show_summary: {
|
|
353
|
+
message: withHistoryFn(() => {
|
|
354
|
+
const data = getFormData();
|
|
355
|
+
return `Summary:\nName: ${data.name}\nEmail: ${data.email}`;
|
|
356
|
+
}),
|
|
357
|
+
options: ["Submit", "Cancel"],
|
|
358
|
+
path: "submit"
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
// Success message with important data (e.g., ticket links)
|
|
362
|
+
success: {
|
|
363
|
+
message: withHistoryFn(() => generateSuccessMessage(result)),
|
|
364
|
+
options: ["Back to Menu"],
|
|
365
|
+
path: "start"
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**When to use these helpers:**
|
|
371
|
+
- `withHistory(string)` - For static messages you want restored in history
|
|
372
|
+
- `withHistoryFn(fn)` - For dynamic/computed messages (summaries, API responses with links)
|
|
373
|
+
|
|
374
|
+
**Tip:** You don't need to wrap every message - only the important ones that would be valuable when restoring a session (like ticket confirmations, summaries, or API responses).
|
|
375
|
+
|
|
335
376
|
### Session Management
|
|
336
377
|
|
|
337
378
|
The bot automatically manages conversation sessions with unique session IDs:
|
|
@@ -411,7 +452,8 @@ localStorage.removeItem('QA_BOT_DEBUG');
|
|
|
411
452
|
When enabled, you'll see styled console output for:
|
|
412
453
|
- Library version on load
|
|
413
454
|
- Session lifecycle events (CREATED, RESET, RESTORED)
|
|
414
|
-
-
|
|
455
|
+
- History operations (message tracking, session restore)
|
|
456
|
+
- Message tracking (which messages are being saved to history)
|
|
415
457
|
|
|
416
458
|
Errors and warnings always display regardless of the debug flag.
|
|
417
459
|
|