@flowengage/react-chatbot 5.0.37 → 5.0.39
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.
|
@@ -29386,8 +29386,10 @@ function Ck(e) {
|
|
|
29386
29386
|
$("flowengage_navigate → real navigation", a);
|
|
29387
29387
|
let e = typeof window < "u" && !!(window.next?.router || window.__NEXT_ROUTER__ || window.__remixRouter || window.__staticRouterHydrationData || window.___gatsby || window.___navigate || window.__VUE_ROUTER__ || window.__NUXT__ || window.$nuxt || window.ng?.getComponent || typeof document < "u" && document.querySelector("[ng-version]") || window.__sveltekit_data || typeof document < "u" && document.querySelector("[data-sveltekit-hydrate]"));
|
|
29388
29388
|
if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), e && qn(3e3), Tr(a, { voiceActive: !0 }).catch(() => {}), e) try {
|
|
29389
|
-
let e =
|
|
29390
|
-
|
|
29389
|
+
let e = new URL(a, window.location.origin).pathname;
|
|
29390
|
+
await new Promise((e) => setTimeout(e, 350));
|
|
29391
|
+
let t = typeof window < "u" ? window.location.pathname : e, n = typeof window < "u" ? window.location.href : a, r = t === e, i = (t.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home";
|
|
29392
|
+
return $("flowengage_navigate → SPA nav complete. target:", e, "actual:", t), r ? `OK_NAVIGATE_SPA. Navigation confirmed. Visitor is now at: ${n}. Page name: "${i}". Continue with your response about this page — do NOT say "I have navigated you to..." (the page is already changing visually). Just start talking about the content.` : `OK_NAVIGATE_SPA. IMPORTANT: Navigation was interrupted. The visitor is currently at ${n} (page: "${i}"), NOT the page you tried to navigate to. Adjust your response to describe the page the visitor is ACTUALLY on right now.`;
|
|
29391
29393
|
} catch {}
|
|
29392
29394
|
return "OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.";
|
|
29393
29395
|
} catch (e) {
|
|
@@ -29985,11 +29987,11 @@ function Nk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
29985
29987
|
});
|
|
29986
29988
|
}
|
|
29987
29989
|
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 = p(null), fe = o((e = "minimized") => {
|
|
29990
|
+
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 = p(!1), pe = o((e = "minimized") => {
|
|
29989
29991
|
E.current = e, re.current = !0, queueMicrotask(() => {
|
|
29990
29992
|
ee.current || (ee.current = !0, T.current?.());
|
|
29991
29993
|
});
|
|
29992
|
-
}, [u]),
|
|
29994
|
+
}, [u]), me = o(async (e) => {
|
|
29993
29995
|
re.current = !0;
|
|
29994
29996
|
try {
|
|
29995
29997
|
await C.current?.endSession?.();
|
|
@@ -30019,10 +30021,10 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30019
30021
|
l,
|
|
30020
30022
|
s
|
|
30021
30023
|
]);
|
|
30022
|
-
return T.current = () =>
|
|
30024
|
+
return T.current = () => me(E.current === "chat" ? t : n), c(() => {
|
|
30023
30025
|
te.current = y;
|
|
30024
30026
|
}, [y]), c(() => {
|
|
30025
|
-
f &&
|
|
30027
|
+
f && pe("chat");
|
|
30026
30028
|
}, [f]), c(() => {
|
|
30027
30029
|
let e = !1, i = null, o = null, c = null;
|
|
30028
30030
|
return (async () => {
|
|
@@ -30086,42 +30088,42 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30086
30088
|
m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
30087
30089
|
let S = x || y || "this page";
|
|
30088
30090
|
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,
|
|
30091
|
+
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, me = await _D.startSession({
|
|
30090
30092
|
..._,
|
|
30091
30093
|
onConnect: ({ conversationId: e }) => {
|
|
30092
30094
|
ie.current = e, ae.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
30093
30095
|
},
|
|
30094
30096
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
30095
30097
|
onModeChange: ({ mode: t }) => {
|
|
30096
|
-
if (
|
|
30097
|
-
|
|
30098
|
-
|
|
30099
|
-
|
|
30100
|
-
|
|
30101
|
-
|
|
30102
|
-
|
|
30103
|
-
|
|
30104
|
-
|
|
30105
|
-
if (oe && !T) {
|
|
30106
|
-
T = !0;
|
|
30107
|
-
try {
|
|
30108
|
-
C.current?.sendUserMessage?.("continue with the tour");
|
|
30109
|
-
} catch {}
|
|
30110
|
-
}
|
|
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);
|
|
30098
|
+
if (e) return;
|
|
30099
|
+
if (t === "speaking") {
|
|
30100
|
+
de.current &&= (clearTimeout(de.current), null), v("speaking"), ce.current = "speaking", le.current = !0, fe.current = !1, ue.current &&= (clearTimeout(ue.current), null);
|
|
30101
|
+
return;
|
|
30102
|
+
}
|
|
30103
|
+
let n = ce.current;
|
|
30104
|
+
if (ce.current = "listening", se.current) {
|
|
30105
|
+
se.current = !1, pe();
|
|
30106
|
+
return;
|
|
30118
30107
|
}
|
|
30108
|
+
if (oe && !T) {
|
|
30109
|
+
T = !0;
|
|
30110
|
+
try {
|
|
30111
|
+
C.current?.sendUserMessage?.("continue with the tour");
|
|
30112
|
+
} catch {}
|
|
30113
|
+
}
|
|
30114
|
+
n === "speaking" && le.current && !te.current && (ce.current = "thinking", v("thinking")), de.current && clearTimeout(de.current), de.current = setTimeout(() => {
|
|
30115
|
+
e || ce.current !== "speaking" && (fe.current || (de.current = null, ce.current = "listening", v("listening"), le.current && !te.current && (ue.current && clearTimeout(ue.current), ue.current = setTimeout(() => {
|
|
30116
|
+
if (!e && ce.current === "listening" && !te.current) try {
|
|
30117
|
+
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.");
|
|
30118
|
+
} catch {}
|
|
30119
|
+
}, 4e3))));
|
|
30120
|
+
}, 1200);
|
|
30119
30121
|
},
|
|
30120
30122
|
onMessage: (t) => {
|
|
30121
30123
|
if (e) return;
|
|
30122
30124
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
30123
30125
|
if (r) {
|
|
30124
|
-
if (n === "user" && (w.current = r, ue.current &&= (clearTimeout(ue.current), null)), u.current = [...u.current, {
|
|
30126
|
+
if (n === "user" && (w.current = r, fe.current = !0, de.current &&= (clearTimeout(de.current), null), ce.current = "thinking", v("thinking"), ue.current &&= (clearTimeout(ue.current), null)), u.current = [...u.current, {
|
|
30125
30127
|
sender: n,
|
|
30126
30128
|
message: r,
|
|
30127
30129
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -30130,13 +30132,13 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30130
30132
|
e && Ae(a, e);
|
|
30131
30133
|
} catch {}
|
|
30132
30134
|
if (Ak(n, r)) {
|
|
30133
|
-
|
|
30135
|
+
pe("minimized");
|
|
30134
30136
|
return;
|
|
30135
30137
|
}
|
|
30136
30138
|
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 {
|
|
30137
30139
|
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.");
|
|
30138
30140
|
} catch {}
|
|
30139
|
-
else D.current >= 5 &&
|
|
30141
|
+
else D.current >= 5 && pe("minimized");
|
|
30140
30142
|
}
|
|
30141
30143
|
},
|
|
30142
30144
|
onError: (t) => {
|
|
@@ -30149,7 +30151,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30149
30151
|
try {
|
|
30150
30152
|
C.current?.setMicMuted?.(!0);
|
|
30151
30153
|
} catch {}
|
|
30152
|
-
b(!0), v("error"),
|
|
30154
|
+
b(!0), v("error"), pe("chat");
|
|
30153
30155
|
}
|
|
30154
30156
|
},
|
|
30155
30157
|
onDisconnect: (t) => {
|
|
@@ -30166,21 +30168,21 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30166
30168
|
try {
|
|
30167
30169
|
C.current?.setMicMuted?.(!0);
|
|
30168
30170
|
} catch {}
|
|
30169
|
-
b(!0),
|
|
30171
|
+
b(!0), pe("chat");
|
|
30170
30172
|
}
|
|
30171
30173
|
});
|
|
30172
30174
|
if (e) {
|
|
30173
|
-
|
|
30175
|
+
me.endSession().catch(() => {});
|
|
30174
30176
|
return;
|
|
30175
30177
|
}
|
|
30176
|
-
i =
|
|
30178
|
+
i = me, C.current = me, v("listening");
|
|
30177
30179
|
try {
|
|
30178
30180
|
let e = typeof window < "u" ? window.location.href : "", r = "[]";
|
|
30179
30181
|
try {
|
|
30180
30182
|
r = await t.list_page_forms();
|
|
30181
30183
|
} catch {}
|
|
30182
30184
|
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` : "";
|
|
30183
|
-
|
|
30185
|
+
me.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30184
30186
|
} catch {}
|
|
30185
30187
|
if (typeof window < "u") {
|
|
30186
30188
|
let t = window.location.pathname, n = () => {
|
|
@@ -30210,7 +30212,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30210
30212
|
}, 0)));
|
|
30211
30213
|
}
|
|
30212
30214
|
})(), () => {
|
|
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);
|
|
30215
|
+
e = !0, re.current = !0, kr(), ue.current &&= (clearTimeout(ue.current), null), de.current &&= (clearTimeout(de.current), null), le.current = !1, fe.current = !1, ce.current = "idle", o && typeof window < "u" && (window.history.pushState = o), c && typeof window < "u" && window.removeEventListener("popstate", c);
|
|
30214
30216
|
let t = i || C.current, n = ie.current, r = ae.current;
|
|
30215
30217
|
if (t?.endSession?.().catch(() => {}), n && l && s) {
|
|
30216
30218
|
let e = r ? Math.round((Date.now() - r) / 1e3) : 0, t = JSON.stringify({
|
|
@@ -30232,7 +30234,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30232
30234
|
r,
|
|
30233
30235
|
a,
|
|
30234
30236
|
s,
|
|
30235
|
-
|
|
30237
|
+
pe
|
|
30236
30238
|
]), c(() => {
|
|
30237
30239
|
if (!x) return;
|
|
30238
30240
|
let e = (e) => {
|
|
@@ -30418,7 +30420,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30418
30420
|
children: [
|
|
30419
30421
|
/* @__PURE__ */ _("button", {
|
|
30420
30422
|
onClick: () => {
|
|
30421
|
-
S(!1), E.current = "chat",
|
|
30423
|
+
S(!1), E.current = "chat", me(t);
|
|
30422
30424
|
},
|
|
30423
30425
|
style: {
|
|
30424
30426
|
display: "flex",
|
|
@@ -30447,7 +30449,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30447
30449
|
}),
|
|
30448
30450
|
/* @__PURE__ */ _("button", {
|
|
30449
30451
|
onClick: () => {
|
|
30450
|
-
S(!1), E.current = "minimized",
|
|
30452
|
+
S(!1), E.current = "minimized", me(n);
|
|
30451
30453
|
},
|
|
30452
30454
|
style: {
|
|
30453
30455
|
display: "flex",
|