@flowengage/react-chatbot 8.0.92 → 8.0.93
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.
|
@@ -13420,14 +13420,14 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13420
13420
|
_e.current = t;
|
|
13421
13421
|
let S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), C = "";
|
|
13422
13422
|
g && g.includes("|") && (C = g.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
13423
|
-
let w = C || S || "this page",
|
|
13423
|
+
let w = C || S || "", T = w ? `the ${w} page` : "this page", D = (() => {
|
|
13424
13424
|
if (!u?.targetUrl) return !0;
|
|
13425
13425
|
try {
|
|
13426
13426
|
return new URL(u.targetUrl, window.location.href).pathname.replace(/\/$/, "") === window.location.pathname.replace(/\/$/, "");
|
|
13427
13427
|
} catch {
|
|
13428
13428
|
return !0;
|
|
13429
13429
|
}
|
|
13430
|
-
})(),
|
|
13430
|
+
})(), k = (() => {
|
|
13431
13431
|
if (!u?.targetUrl) return null;
|
|
13432
13432
|
try {
|
|
13433
13433
|
return new URL(u.targetUrl, window.location.href).pathname;
|
|
@@ -13435,16 +13435,16 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13435
13435
|
return null;
|
|
13436
13436
|
}
|
|
13437
13437
|
})();
|
|
13438
|
-
if (p && !
|
|
13438
|
+
if (p && !D) x.greeting = `You're on ${T}. What would you like to know?`, console.warn(`[FlowEngage] nav target "${u?.pageName}" not reached — on "${w}" instead; not claiming navigation`);
|
|
13439
13439
|
else if (p) {
|
|
13440
|
-
let e = u?.pageName
|
|
13441
|
-
x.greeting = `I have navigated you
|
|
13442
|
-
} else if (r) x.greeting = `Welcome back! I see you're now on
|
|
13440
|
+
let e = u?.pageName ? `the ${u.pageName} page` : T;
|
|
13441
|
+
x.greeting = `I have navigated you to ${e}. Do you want to know about any specific section or want a complete overview?`, console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${m})`);
|
|
13442
|
+
} else if (r) x.greeting = `Welcome back! I see you're now on ${T}. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;
|
|
13443
13443
|
else {
|
|
13444
13444
|
let e = f || "";
|
|
13445
|
-
x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to
|
|
13445
|
+
x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
|
|
13446
13446
|
}
|
|
13447
|
-
let
|
|
13447
|
+
let A = !1, ee = 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, re = !1, N = 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, ye = !1, Ce = !1, Oe = b && !!y && !fe.current, ze = await hh.startSession({
|
|
13448
13448
|
...x,
|
|
13449
13449
|
onConnect: ({ conversationId: e }) => {
|
|
13450
13450
|
Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
@@ -13484,28 +13484,28 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13484
13484
|
je.current = !1, Fe();
|
|
13485
13485
|
return;
|
|
13486
13486
|
}
|
|
13487
|
-
if (
|
|
13488
|
-
|
|
13487
|
+
if (Oe && !Ce && !ie.current && !fe.current) {
|
|
13488
|
+
Ce = !0, A = !0, ne = !0;
|
|
13489
13489
|
try {
|
|
13490
13490
|
P.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
|
|
13491
13491
|
} catch {}
|
|
13492
13492
|
}
|
|
13493
|
-
if (
|
|
13494
|
-
|
|
13493
|
+
if (ee && !A) {
|
|
13494
|
+
A = !0;
|
|
13495
13495
|
try {
|
|
13496
|
-
P.current?.sendContextualUpdate?.(
|
|
13496
|
+
P.current?.sendContextualUpdate?.(ee);
|
|
13497
13497
|
} catch {}
|
|
13498
13498
|
}
|
|
13499
|
-
if (
|
|
13500
|
-
|
|
13499
|
+
if (N && !re) {
|
|
13500
|
+
re = !0;
|
|
13501
13501
|
try {
|
|
13502
|
-
P.current?.sendContextualUpdate?.(
|
|
13502
|
+
P.current?.sendContextualUpdate?.(N);
|
|
13503
13503
|
} catch {}
|
|
13504
13504
|
}
|
|
13505
|
-
if (
|
|
13506
|
-
|
|
13505
|
+
if (j && !ne) {
|
|
13506
|
+
ne = !0;
|
|
13507
13507
|
try {
|
|
13508
|
-
P.current?.sendContextualUpdate?.(
|
|
13508
|
+
P.current?.sendContextualUpdate?.(j);
|
|
13509
13509
|
} catch {}
|
|
13510
13510
|
}
|
|
13511
13511
|
z.current && clearTimeout(z.current), z.current = setTimeout(() => {
|
|
@@ -13526,7 +13526,7 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13526
13526
|
}
|
|
13527
13527
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
13528
13528
|
if (r) {
|
|
13529
|
-
if (n === "user" && (ve.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ne.current = !0, z.current &&= (clearTimeout(z.current), null), R.current !== "speaking" && (E("thinking"), R.current = "thinking"),
|
|
13529
|
+
if (n === "user" && (ve.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ne.current = !0, z.current &&= (clearTimeout(z.current), null), R.current !== "speaking" && (E("thinking"), R.current = "thinking"), Oe && !ye && !ie.current && !fe.current && (ye = !0, se.current = r, ce.current = !0, P.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), P.current?.setMicMuted?.(!0), ae.current || (ae.current = !0, oe.current = 0, te(!0), Re()))), l.current = [...l.current, {
|
|
13530
13530
|
sender: n,
|
|
13531
13531
|
message: r,
|
|
13532
13532
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -13576,12 +13576,12 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13576
13576
|
}
|
|
13577
13577
|
});
|
|
13578
13578
|
if (e) {
|
|
13579
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
13579
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ze.endSession().catch(() => {});
|
|
13580
13580
|
return;
|
|
13581
13581
|
}
|
|
13582
|
-
o =
|
|
13582
|
+
o = ze, P.current = ze, E("listening");
|
|
13583
13583
|
try {
|
|
13584
|
-
sessionStorage.setItem(`el_conv_${i}`,
|
|
13584
|
+
sessionStorage.setItem(`el_conv_${i}`, ze.getId());
|
|
13585
13585
|
} catch {}
|
|
13586
13586
|
parent.postMessage({ type: "AGENT_EXPAND" }, "*");
|
|
13587
13587
|
try {
|
|
@@ -13595,7 +13595,7 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13595
13595
|
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(" | "));
|
|
13596
13596
|
} catch {}
|
|
13597
13597
|
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` : "";
|
|
13598
|
-
|
|
13598
|
+
ze.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. 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. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
13599
13599
|
} catch {}
|
|
13600
13600
|
if (typeof window < "u") {
|
|
13601
13601
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -13611,7 +13611,7 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13611
13611
|
t = i;
|
|
13612
13612
|
return;
|
|
13613
13613
|
}
|
|
13614
|
-
if (
|
|
13614
|
+
if (k && r(i) === r(k)) {
|
|
13615
13615
|
t = i;
|
|
13616
13616
|
return;
|
|
13617
13617
|
}
|
|
@@ -13639,7 +13639,7 @@ function f_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13639
13639
|
fromPageName: u,
|
|
13640
13640
|
toPageName: d,
|
|
13641
13641
|
ts: Date.now()
|
|
13642
|
-
}), console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${
|
|
13642
|
+
}), console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${k || "none"})`);
|
|
13643
13643
|
try {
|
|
13644
13644
|
P.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} 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 "${d}" only.]`);
|
|
13645
13645
|
} catch {}
|