lisichatbot 1.5.7 → 1.5.8
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/package.json +1 -1
- package/src/index.js +29 -11
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1975,14 +1975,24 @@ async function handleNext() {
|
|
|
1975
1975
|
if (currentStep.onNext) {
|
|
1976
1976
|
try {
|
|
1977
1977
|
disableNextButton();
|
|
1978
|
+
|
|
1979
|
+
// ✅ NEW: Create showMessage helper function
|
|
1980
|
+
const showMessage = (message) => {
|
|
1981
|
+
console.log('💬 showMessage called:', message);
|
|
1982
|
+
addMessage(message, 'bot', false, null);
|
|
1983
|
+
scrollToBottom();
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
// ✅ Pass showMessage as third parameter
|
|
1978
1987
|
const result = await currentStep.onNext(
|
|
1979
1988
|
chatState.currentSelection ? chatState.currentSelection.value : null,
|
|
1980
|
-
chatState.data
|
|
1989
|
+
chatState.data,
|
|
1990
|
+
showMessage // ✅ NEW: Third parameter
|
|
1981
1991
|
);
|
|
1982
1992
|
|
|
1983
|
-
// ✅
|
|
1993
|
+
// ✅ Still support showMessage in return object for backwards compatibility
|
|
1984
1994
|
if (result && typeof result === 'object' && result.showMessage) {
|
|
1985
|
-
console.log('💬 onNext displaying message:', result.showMessage);
|
|
1995
|
+
console.log('💬 onNext displaying message from return:', result.showMessage);
|
|
1986
1996
|
addMessage(result.showMessage, 'bot', false, null);
|
|
1987
1997
|
scrollToBottom();
|
|
1988
1998
|
}
|
|
@@ -2317,7 +2327,22 @@ async function showNextStep() {
|
|
|
2317
2327
|
|
|
2318
2328
|
if (nextStep.onStart) {
|
|
2319
2329
|
try {
|
|
2320
|
-
|
|
2330
|
+
// ✅ NEW: Create showMessage helper function
|
|
2331
|
+
const showMessage = (message) => {
|
|
2332
|
+
console.log('💬 showMessage called:', message);
|
|
2333
|
+
addMessage(message, 'bot', false, null);
|
|
2334
|
+
scrollToBottom();
|
|
2335
|
+
};
|
|
2336
|
+
|
|
2337
|
+
// ✅ Pass showMessage as second parameter
|
|
2338
|
+
const result = await nextStep.onStart(chatState.data, showMessage);
|
|
2339
|
+
|
|
2340
|
+
// ✅ Still support showMessage in return object for backwards compatibility
|
|
2341
|
+
if (result && typeof result === 'object' && result.showMessage) {
|
|
2342
|
+
console.log('💬 onStart displaying message from return:', result.showMessage);
|
|
2343
|
+
addMessage(result.showMessage, 'bot', false, null);
|
|
2344
|
+
scrollToBottom();
|
|
2345
|
+
}
|
|
2321
2346
|
|
|
2322
2347
|
// ✅ NEW: Check if onStart wants to update steps by field name
|
|
2323
2348
|
if (result && typeof result === 'object' && result.updateStepByField) {
|
|
@@ -2467,13 +2492,6 @@ async function showNextStep() {
|
|
|
2467
2492
|
}
|
|
2468
2493
|
}
|
|
2469
2494
|
|
|
2470
|
-
// ✅ NEW: Check if onStart wants to display a message in chat
|
|
2471
|
-
if (result && typeof result === 'object' && result.showMessage) {
|
|
2472
|
-
console.log('💬 onStart displaying message:', result.showMessage);
|
|
2473
|
-
addMessage(result.showMessage, 'bot', false, null);
|
|
2474
|
-
scrollToBottom();
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
2495
|
// ✅ NEW: Check if onStart wants to jump to a specific step
|
|
2478
2496
|
if (result && typeof result === 'object' && typeof result.goToStep === 'number') {
|
|
2479
2497
|
console.log(`🎯 onStart requested jump to step ${result.goToStep}`);
|