@flowengage/react-chatbot 5.0.34 → 5.0.36
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.
|
@@ -29406,7 +29406,7 @@ function Ck(e) {
|
|
|
29406
29406
|
let t = hk(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
|
|
29407
29407
|
Sk();
|
|
29408
29408
|
let i = hr(n || null, r || null);
|
|
29409
|
-
return !i && r && (await new Promise((e) => setTimeout(e, 500)), Sk(), i = hr(null, r)), i ? (vO(i), $("flowengage_highlight ✓", r || n), `OK_HIGHLIGHT: "${r || n}"
|
|
29409
|
+
return !i && r && (await new Promise((e) => setTimeout(e, 500)), Sk(), i = hr(null, r)), i ? (vO(i), $("flowengage_highlight ✓", r || n), `OK_HIGHLIGHT: "${r || n}". WALKTHROUGH: If you are mid-walkthrough and have more sections to cover, continue immediately to the next section — do NOT pause or wait for the visitor to speak between sections.`) : ($("flowengage_highlight ✖ no element for:", r || n), `Could not find "${r || n}" on the current page. Try a shorter phrase matching a visible heading.`);
|
|
29410
29410
|
},
|
|
29411
29411
|
flowengage_read_content: async (e) => {
|
|
29412
29412
|
$("flowengage_read_content ▶", e);
|
|
@@ -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 = 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 = 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]), fe = 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 = () => fe(E.current === "chat" ? t : n), c(() => {
|
|
30023
30023
|
te.current = y;
|
|
30024
30024
|
}, [y]), c(() => {
|
|
30025
|
-
f &&
|
|
30025
|
+
f && de("chat");
|
|
30026
30026
|
}, [f]), c(() => {
|
|
30027
30027
|
let e = !1, i = null, o = null, c = null;
|
|
30028
30028
|
return (async () => {
|
|
@@ -30086,16 +30086,18 @@ 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, fe = 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 (
|
|
30096
|
+
if (e) return;
|
|
30097
|
+
let n = t === "speaking" ? "speaking" : "listening";
|
|
30098
|
+
if (v(n), ce.current = n, t === "speaking" && (le.current = !0, ue.current &&= (clearTimeout(ue.current), null)), t === "listening") {
|
|
30097
30099
|
if (se.current) {
|
|
30098
|
-
se.current = !1,
|
|
30100
|
+
se.current = !1, de();
|
|
30099
30101
|
return;
|
|
30100
30102
|
}
|
|
30101
30103
|
if (oe && !T) {
|
|
@@ -30104,13 +30106,18 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30104
30106
|
C.current?.sendUserMessage?.("continue with the tour");
|
|
30105
30107
|
} catch {}
|
|
30106
30108
|
}
|
|
30109
|
+
le.current && !te.current && (ue.current && clearTimeout(ue.current), ue.current = setTimeout(() => {
|
|
30110
|
+
if (!e && ce.current === "listening" && !te.current) try {
|
|
30111
|
+
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.");
|
|
30112
|
+
} catch {}
|
|
30113
|
+
}, 4e3));
|
|
30107
30114
|
}
|
|
30108
30115
|
},
|
|
30109
30116
|
onMessage: (t) => {
|
|
30110
30117
|
if (e) return;
|
|
30111
30118
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
30112
30119
|
if (r) {
|
|
30113
|
-
if (n === "user" && (w.current = r), u.current = [...u.current, {
|
|
30120
|
+
if (n === "user" && (w.current = r, ue.current &&= (clearTimeout(ue.current), null)), u.current = [...u.current, {
|
|
30114
30121
|
sender: n,
|
|
30115
30122
|
message: r,
|
|
30116
30123
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -30119,13 +30126,13 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30119
30126
|
e && Ae(a, e);
|
|
30120
30127
|
} catch {}
|
|
30121
30128
|
if (Ak(n, r)) {
|
|
30122
|
-
|
|
30129
|
+
de("minimized");
|
|
30123
30130
|
return;
|
|
30124
30131
|
}
|
|
30125
30132
|
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 {
|
|
30126
30133
|
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.");
|
|
30127
30134
|
} catch {}
|
|
30128
|
-
else D.current >= 5 &&
|
|
30135
|
+
else D.current >= 5 && de("minimized");
|
|
30129
30136
|
}
|
|
30130
30137
|
},
|
|
30131
30138
|
onError: (t) => {
|
|
@@ -30138,7 +30145,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30138
30145
|
try {
|
|
30139
30146
|
C.current?.setMicMuted?.(!0);
|
|
30140
30147
|
} catch {}
|
|
30141
|
-
b(!0), v("error"),
|
|
30148
|
+
b(!0), v("error"), de("chat");
|
|
30142
30149
|
}
|
|
30143
30150
|
},
|
|
30144
30151
|
onDisconnect: (t) => {
|
|
@@ -30155,21 +30162,21 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30155
30162
|
try {
|
|
30156
30163
|
C.current?.setMicMuted?.(!0);
|
|
30157
30164
|
} catch {}
|
|
30158
|
-
b(!0),
|
|
30165
|
+
b(!0), de("chat");
|
|
30159
30166
|
}
|
|
30160
30167
|
});
|
|
30161
30168
|
if (e) {
|
|
30162
|
-
|
|
30169
|
+
fe.endSession().catch(() => {});
|
|
30163
30170
|
return;
|
|
30164
30171
|
}
|
|
30165
|
-
i =
|
|
30172
|
+
i = fe, C.current = fe, v("listening");
|
|
30166
30173
|
try {
|
|
30167
30174
|
let e = typeof window < "u" ? window.location.href : "", r = "[]";
|
|
30168
30175
|
try {
|
|
30169
30176
|
r = await t.list_page_forms();
|
|
30170
30177
|
} catch {}
|
|
30171
30178
|
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` : "";
|
|
30172
|
-
|
|
30179
|
+
fe.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30173
30180
|
} catch {}
|
|
30174
30181
|
if (typeof window < "u") {
|
|
30175
30182
|
let t = window.location.pathname, n = () => {
|
|
@@ -30199,7 +30206,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30199
30206
|
}, 0)));
|
|
30200
30207
|
}
|
|
30201
30208
|
})(), () => {
|
|
30202
|
-
e = !0, re.current = !0, kr(), o && typeof window < "u" && (window.history.pushState = o), c && typeof window < "u" && window.removeEventListener("popstate", c);
|
|
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);
|
|
30203
30210
|
let t = i || C.current, n = ie.current, r = ae.current;
|
|
30204
30211
|
if (t?.endSession?.().catch(() => {}), n && l && s) {
|
|
30205
30212
|
let e = r ? Math.round((Date.now() - r) / 1e3) : 0, t = JSON.stringify({
|
|
@@ -30221,7 +30228,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30221
30228
|
r,
|
|
30222
30229
|
a,
|
|
30223
30230
|
s,
|
|
30224
|
-
|
|
30231
|
+
de
|
|
30225
30232
|
]), c(() => {
|
|
30226
30233
|
if (!x) return;
|
|
30227
30234
|
let e = (e) => {
|
|
@@ -30407,7 +30414,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30407
30414
|
children: [
|
|
30408
30415
|
/* @__PURE__ */ _("button", {
|
|
30409
30416
|
onClick: () => {
|
|
30410
|
-
S(!1), E.current = "chat",
|
|
30417
|
+
S(!1), E.current = "chat", fe(t);
|
|
30411
30418
|
},
|
|
30412
30419
|
style: {
|
|
30413
30420
|
display: "flex",
|
|
@@ -30436,7 +30443,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30436
30443
|
}),
|
|
30437
30444
|
/* @__PURE__ */ _("button", {
|
|
30438
30445
|
onClick: () => {
|
|
30439
|
-
S(!1), E.current = "minimized",
|
|
30446
|
+
S(!1), E.current = "minimized", fe(n);
|
|
30440
30447
|
},
|
|
30441
30448
|
style: {
|
|
30442
30449
|
display: "flex",
|