@flowengage/react-chatbot 5.0.35 → 5.0.37
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.
|
@@ -29482,7 +29482,7 @@ function Ck(e) {
|
|
|
29482
29482
|
}), a = await r.json();
|
|
29483
29483
|
if ($("flowengage_page_content · HTTP", r.status, "success:", a.success), !a.success) {
|
|
29484
29484
|
let e = a.error || "Failed to get page content.";
|
|
29485
|
-
return $("flowengage_page_content ✖", e), e
|
|
29485
|
+
return $("flowengage_page_content ✖", e), `${e} FALLBACK REQUIRED: This page is not in the search index. Call flowengage_read_content (no parameters) immediately to read the live page content directly from the visitor's browser — do NOT tell the visitor you cannot access the page.`;
|
|
29486
29486
|
}
|
|
29487
29487
|
return $("flowengage_page_content ✓", `title: ${a.title}`, `sections: ${(a.sections || []).length}`, `content: ${(a.content || "").length} chars`), JSON.stringify({
|
|
29488
29488
|
title: a.title,
|
|
@@ -29985,11 +29985,11 @@ function Nk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
29985
29985
|
});
|
|
29986
29986
|
}
|
|
29987
29987
|
function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s, chatId: l, historyRef: u, onMessageSync: d, voiceEndCounter: f }) {
|
|
29988
|
-
let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = p(0), se = p(!1), ce = p("idle"), le = p(!1), ue = p(null), de = o((e = "minimized") => {
|
|
29988
|
+
let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = p(0), se = p(!1), ce = p("idle"), le = p(!1), ue = p(null), de = p(null), fe = o((e = "minimized") => {
|
|
29989
29989
|
E.current = e, re.current = !0, queueMicrotask(() => {
|
|
29990
29990
|
ee.current || (ee.current = !0, T.current?.());
|
|
29991
29991
|
});
|
|
29992
|
-
}, [u]),
|
|
29992
|
+
}, [u]), pe = o(async (e) => {
|
|
29993
29993
|
re.current = !0;
|
|
29994
29994
|
try {
|
|
29995
29995
|
await C.current?.endSession?.();
|
|
@@ -30019,10 +30019,10 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30019
30019
|
l,
|
|
30020
30020
|
s
|
|
30021
30021
|
]);
|
|
30022
|
-
return T.current = () =>
|
|
30022
|
+
return T.current = () => pe(E.current === "chat" ? t : n), c(() => {
|
|
30023
30023
|
te.current = y;
|
|
30024
30024
|
}, [y]), c(() => {
|
|
30025
|
-
f &&
|
|
30025
|
+
f && fe("chat");
|
|
30026
30026
|
}, [f]), c(() => {
|
|
30027
30027
|
let e = !1, i = null, o = null, c = null;
|
|
30028
30028
|
return (async () => {
|
|
@@ -30086,18 +30086,20 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30086
30086
|
m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
30087
30087
|
let S = x || y || "this page";
|
|
30088
30088
|
g ? f ? (_.overrides = { agent: { firstMessage: `I've navigated you to the ${S} page. Let me walk you through what's here.` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${S}" (${p})`)) : d ? _.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } } : h || (_.overrides = { agent: { firstMessage: `Hi! I see you are currently on the ${S} page. Are you looking for something specific here?` } }, console.log(`[FlowEngage] 🏠 Page-context override: "${S}" for ${p}`)) : d && (_.overrides = { agent: { firstMessage: "" } });
|
|
30089
|
-
let T = !1, oe = f ? `NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a ? je(a) : null)?.transcript || ""}\n\n` : null,
|
|
30089
|
+
let T = !1, oe = f ? `NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a ? je(a) : null)?.transcript || ""}\n\n` : null, pe = await _D.startSession({
|
|
30090
30090
|
..._,
|
|
30091
30091
|
onConnect: ({ conversationId: e }) => {
|
|
30092
30092
|
ie.current = e, ae.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
30093
30093
|
},
|
|
30094
30094
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
30095
30095
|
onModeChange: ({ mode: t }) => {
|
|
30096
|
-
if (e)
|
|
30097
|
-
|
|
30098
|
-
|
|
30099
|
-
|
|
30100
|
-
|
|
30096
|
+
if (!e) {
|
|
30097
|
+
if (t === "speaking") {
|
|
30098
|
+
de.current &&= (clearTimeout(de.current), null), v("speaking"), ce.current = "speaking", le.current = !0, ue.current &&= (clearTimeout(ue.current), null);
|
|
30099
|
+
return;
|
|
30100
|
+
}
|
|
30101
|
+
if (ce.current = "listening", se.current) {
|
|
30102
|
+
se.current = !1, fe();
|
|
30101
30103
|
return;
|
|
30102
30104
|
}
|
|
30103
30105
|
if (oe && !T) {
|
|
@@ -30106,11 +30108,13 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30106
30108
|
C.current?.sendUserMessage?.("continue with the tour");
|
|
30107
30109
|
} catch {}
|
|
30108
30110
|
}
|
|
30109
|
-
|
|
30110
|
-
|
|
30111
|
-
|
|
30112
|
-
|
|
30113
|
-
|
|
30111
|
+
de.current && clearTimeout(de.current), de.current = setTimeout(() => {
|
|
30112
|
+
e || ce.current === "listening" && (de.current = null, v("listening"), le.current && !te.current && (ue.current && clearTimeout(ue.current), ue.current = setTimeout(() => {
|
|
30113
|
+
if (!e && ce.current === "listening" && !te.current) try {
|
|
30114
|
+
C.current?.sendContextualUpdate?.("The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.");
|
|
30115
|
+
} catch {}
|
|
30116
|
+
}, 4e3)));
|
|
30117
|
+
}, 1200);
|
|
30114
30118
|
}
|
|
30115
30119
|
},
|
|
30116
30120
|
onMessage: (t) => {
|
|
@@ -30126,13 +30130,13 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30126
30130
|
e && Ae(a, e);
|
|
30127
30131
|
} catch {}
|
|
30128
30132
|
if (Ak(n, r)) {
|
|
30129
|
-
|
|
30133
|
+
fe("minimized");
|
|
30130
30134
|
return;
|
|
30131
30135
|
}
|
|
30132
30136
|
if (te.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (D.current += 1, D.current === 2) try {
|
|
30133
30137
|
C.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the flowengage_end_session tool to end the voice session. Do NOT ask again after that.");
|
|
30134
30138
|
} catch {}
|
|
30135
|
-
else D.current >= 5 &&
|
|
30139
|
+
else D.current >= 5 && fe("minimized");
|
|
30136
30140
|
}
|
|
30137
30141
|
},
|
|
30138
30142
|
onError: (t) => {
|
|
@@ -30145,7 +30149,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30145
30149
|
try {
|
|
30146
30150
|
C.current?.setMicMuted?.(!0);
|
|
30147
30151
|
} catch {}
|
|
30148
|
-
b(!0), v("error"),
|
|
30152
|
+
b(!0), v("error"), fe("chat");
|
|
30149
30153
|
}
|
|
30150
30154
|
},
|
|
30151
30155
|
onDisconnect: (t) => {
|
|
@@ -30162,21 +30166,21 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30162
30166
|
try {
|
|
30163
30167
|
C.current?.setMicMuted?.(!0);
|
|
30164
30168
|
} catch {}
|
|
30165
|
-
b(!0),
|
|
30169
|
+
b(!0), fe("chat");
|
|
30166
30170
|
}
|
|
30167
30171
|
});
|
|
30168
30172
|
if (e) {
|
|
30169
|
-
|
|
30173
|
+
pe.endSession().catch(() => {});
|
|
30170
30174
|
return;
|
|
30171
30175
|
}
|
|
30172
|
-
i =
|
|
30176
|
+
i = pe, C.current = pe, v("listening");
|
|
30173
30177
|
try {
|
|
30174
30178
|
let e = typeof window < "u" ? window.location.href : "", r = "[]";
|
|
30175
30179
|
try {
|
|
30176
30180
|
r = await t.list_page_forms();
|
|
30177
30181
|
} catch {}
|
|
30178
30182
|
let i = d && !f ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
|
|
30179
|
-
|
|
30183
|
+
pe.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30180
30184
|
} catch {}
|
|
30181
30185
|
if (typeof window < "u") {
|
|
30182
30186
|
let t = window.location.pathname, n = () => {
|
|
@@ -30206,7 +30210,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30206
30210
|
}, 0)));
|
|
30207
30211
|
}
|
|
30208
30212
|
})(), () => {
|
|
30209
|
-
e = !0, re.current = !0, kr(), ue.current &&= (clearTimeout(ue.current), null), le.current = !1, ce.current = "idle", o && typeof window < "u" && (window.history.pushState = o), c && typeof window < "u" && window.removeEventListener("popstate", c);
|
|
30213
|
+
e = !0, re.current = !0, kr(), ue.current &&= (clearTimeout(ue.current), null), de.current &&= (clearTimeout(de.current), null), le.current = !1, ce.current = "idle", o && typeof window < "u" && (window.history.pushState = o), c && typeof window < "u" && window.removeEventListener("popstate", c);
|
|
30210
30214
|
let t = i || C.current, n = ie.current, r = ae.current;
|
|
30211
30215
|
if (t?.endSession?.().catch(() => {}), n && l && s) {
|
|
30212
30216
|
let e = r ? Math.round((Date.now() - r) / 1e3) : 0, t = JSON.stringify({
|
|
@@ -30228,7 +30232,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30228
30232
|
r,
|
|
30229
30233
|
a,
|
|
30230
30234
|
s,
|
|
30231
|
-
|
|
30235
|
+
fe
|
|
30232
30236
|
]), c(() => {
|
|
30233
30237
|
if (!x) return;
|
|
30234
30238
|
let e = (e) => {
|
|
@@ -30414,7 +30418,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30414
30418
|
children: [
|
|
30415
30419
|
/* @__PURE__ */ _("button", {
|
|
30416
30420
|
onClick: () => {
|
|
30417
|
-
S(!1), E.current = "chat",
|
|
30421
|
+
S(!1), E.current = "chat", pe(t);
|
|
30418
30422
|
},
|
|
30419
30423
|
style: {
|
|
30420
30424
|
display: "flex",
|
|
@@ -30443,7 +30447,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30443
30447
|
}),
|
|
30444
30448
|
/* @__PURE__ */ _("button", {
|
|
30445
30449
|
onClick: () => {
|
|
30446
|
-
S(!1), E.current = "minimized",
|
|
30450
|
+
S(!1), E.current = "minimized", pe(n);
|
|
30447
30451
|
},
|
|
30448
30452
|
style: {
|
|
30449
30453
|
display: "flex",
|