@flowengage/react-chatbot 8.0.114 → 8.0.116
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.
|
@@ -4289,7 +4289,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4289
4289
|
onMessageSync: Xt,
|
|
4290
4290
|
beaconSyncVoiceTranscript: (e) => {
|
|
4291
4291
|
let t = H.current, n = $e.current;
|
|
4292
|
-
return !t || !n || !Array.isArray(e) || !e.length ? !1 : (t.beaconSyncVoice(n, e) || t.syncVoice(n, e).catch(() => {}),
|
|
4292
|
+
return !t || !n || !Array.isArray(e) || !e.length ? !1 : (t.beaconSyncVoice(n, e) || t.syncVoice(n, e).catch(() => {}), !0);
|
|
4293
4293
|
},
|
|
4294
4294
|
endConversation: Zt,
|
|
4295
4295
|
startNewChat: Qt,
|
|
@@ -13679,7 +13679,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13679
13679
|
let e = h || "";
|
|
13680
13680
|
S.greeting = v || (y ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${E}! How may I help you?`), y || console.log(`[FlowEngage] 🏠 Page-context greeting: "${T}" for ${m}`);
|
|
13681
13681
|
}
|
|
13682
|
-
let ee = !1, te = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, ie = !1, ae = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, N = !1, P = !1, se = x && !!b && !ge.current,
|
|
13682
|
+
let ee = !1, te = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, ie = !1, ae = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, N = !1, P = !1, se = x && !!b && !ge.current, le = await kh.startSession({
|
|
13683
13683
|
...S,
|
|
13684
13684
|
onConnect: ({ conversationId: e }) => {
|
|
13685
13685
|
Pe.current = e, Ie.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
@@ -13812,12 +13812,12 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13812
13812
|
}
|
|
13813
13813
|
});
|
|
13814
13814
|
if (e) {
|
|
13815
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
13815
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), le.endSession().catch(() => {});
|
|
13816
13816
|
return;
|
|
13817
13817
|
}
|
|
13818
|
-
o =
|
|
13818
|
+
o = le, L.current = le, D("listening");
|
|
13819
13819
|
try {
|
|
13820
|
-
sessionStorage.setItem(`el_conv_${i}`,
|
|
13820
|
+
sessionStorage.setItem(`el_conv_${i}`, le.getId());
|
|
13821
13821
|
} catch {}
|
|
13822
13822
|
parent.postMessage({ type: "AGENT_EXPAND" }, "*");
|
|
13823
13823
|
try {
|
|
@@ -13831,7 +13831,7 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13831
13831
|
n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (o = [...new Set(n)].slice(0, 15).join(" | "));
|
|
13832
13832
|
} catch {}
|
|
13833
13833
|
let s = r && !p ? `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` : "";
|
|
13834
|
-
|
|
13834
|
+
le.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${b ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), le.sendContextualUpdate(v_(e, o, a));
|
|
13835
13835
|
} catch {}
|
|
13836
13836
|
if (typeof window < "u") {
|
|
13837
13837
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -13840,54 +13840,54 @@ function k_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13840
13840
|
} catch {
|
|
13841
13841
|
return ((e || "/").replace(/\/+$/, "") || "/").toLowerCase();
|
|
13842
13842
|
}
|
|
13843
|
-
},
|
|
13843
|
+
}, a = () => {
|
|
13844
13844
|
if (e) return;
|
|
13845
|
-
let
|
|
13846
|
-
if (r(
|
|
13847
|
-
t =
|
|
13845
|
+
let a = window.location.pathname;
|
|
13846
|
+
if (r(a) === r(t)) {
|
|
13847
|
+
t = a;
|
|
13848
13848
|
return;
|
|
13849
13849
|
}
|
|
13850
13850
|
if (Date.now() - n < 8e3) {
|
|
13851
|
-
t =
|
|
13851
|
+
t = a;
|
|
13852
13852
|
return;
|
|
13853
13853
|
}
|
|
13854
|
-
let
|
|
13855
|
-
t =
|
|
13856
|
-
let
|
|
13854
|
+
let o = typeof window < "u" && window.__fe_agent_nav || null, s = A && r(a) === r(A) || Gn() || o && Date.now() - o.ts < 15e3 && r(o.path) === r(a), c = t;
|
|
13855
|
+
t = a;
|
|
13856
|
+
let l = window.location.href, u = typeof document < "u" ? document.title : "", d = typeof document < "u" ? Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell")).map((e) => ({
|
|
13857
13857
|
tag: e.tagName,
|
|
13858
13858
|
text: e.textContent.trim()
|
|
13859
13859
|
})).filter((e) => e.text.length > 0 && e.text.length < 200).slice(0, 20) : [];
|
|
13860
13860
|
try {
|
|
13861
13861
|
Pn();
|
|
13862
13862
|
} catch {}
|
|
13863
|
-
let
|
|
13864
|
-
if (
|
|
13865
|
-
typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${
|
|
13866
|
-
|
|
13867
|
-
L.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
|
|
13863
|
+
let f = d.map((e) => e.text).join(" | "), p = (e) => (e.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", m = p(c), h = p(a);
|
|
13864
|
+
if (s) {
|
|
13865
|
+
if (typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${c}" → "${a}"`), ce(i) !== "auto") try {
|
|
13866
|
+
L.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${h}" page (${l}) at their request — this was YOUR action, not theirs. Page title: "${u}". Sections: ${JSON.stringify(d)}. Say: "Here we are on the ${h} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
|
|
13868
13867
|
} catch {}
|
|
13868
|
+
else console.log("[FlowEngage] auto-nav — skipping the arrival acknowledgment turn");
|
|
13869
13869
|
try {
|
|
13870
|
-
L.current?.sendContextualUpdate?.(v_(
|
|
13870
|
+
L.current?.sendContextualUpdate?.(v_(l, f));
|
|
13871
13871
|
} catch {}
|
|
13872
13872
|
return;
|
|
13873
13873
|
}
|
|
13874
13874
|
typeof window < "u" && (window.__fe_user_nav_during_speech = {
|
|
13875
|
-
fromPath:
|
|
13876
|
-
toPath:
|
|
13877
|
-
fromPageName:
|
|
13878
|
-
toPageName:
|
|
13875
|
+
fromPath: c,
|
|
13876
|
+
toPath: a,
|
|
13877
|
+
fromPageName: m,
|
|
13878
|
+
toPageName: h,
|
|
13879
13879
|
ts: Date.now()
|
|
13880
|
-
}), console.log(`[FlowEngage] visitor navigation detected: "${
|
|
13880
|
+
}), console.log(`[FlowEngage] visitor navigation detected: "${c}" → "${a}" (agent target: ${A || "none"})`);
|
|
13881
13881
|
try {
|
|
13882
|
-
L.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${
|
|
13882
|
+
L.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${h}" page (${l}). Page title: "${u}". Sections: ${JSON.stringify(d)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${h} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${h}" only.]`);
|
|
13883
13883
|
} catch {}
|
|
13884
13884
|
try {
|
|
13885
|
-
L.current?.sendContextualUpdate?.(v_(
|
|
13885
|
+
L.current?.sendContextualUpdate?.(v_(l, f));
|
|
13886
13886
|
} catch {}
|
|
13887
13887
|
};
|
|
13888
13888
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
13889
|
-
c(...e), setTimeout(
|
|
13890
|
-
}, f = () => setTimeout(
|
|
13889
|
+
c(...e), setTimeout(a, 50);
|
|
13890
|
+
}, f = () => setTimeout(a, 50), window.addEventListener("popstate", f);
|
|
13891
13891
|
}
|
|
13892
13892
|
} catch (r) {
|
|
13893
13893
|
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (D("error"), Ne.current = "chat", window.setTimeout(() => {
|