@flowengage/react-chatbot 7.0.9 → 7.0.11
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.
|
@@ -3521,20 +3521,36 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3521
3521
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
3522
3522
|
currentPageTitle: typeof window < "u" ? document.title : void 0,
|
|
3523
3523
|
currentPagePath: typeof window < "u" ? window.location.pathname : void 0
|
|
3524
|
-
}), s = o.chat_history || []
|
|
3525
|
-
if (
|
|
3526
|
-
let e =
|
|
3527
|
-
|
|
3524
|
+
}), s = o.chat_history || [];
|
|
3525
|
+
if (o.navigate?.url) {
|
|
3526
|
+
let { url: e, section: t } = o.navigate;
|
|
3527
|
+
Sr(e, {
|
|
3528
3528
|
siteId: i?.siteId,
|
|
3529
3529
|
apiBaseUrl: i?.apiBaseUrl
|
|
3530
|
-
}).then((
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
let
|
|
3534
|
-
|
|
3535
|
-
},
|
|
3530
|
+
}).then((n) => {
|
|
3531
|
+
n && Or(e, { voiceActive: Et.current }).then((e) => {
|
|
3532
|
+
t && setTimeout(() => {
|
|
3533
|
+
let e = _r(null, t);
|
|
3534
|
+
e && vr(e);
|
|
3535
|
+
}, e ? 300 : 150);
|
|
3536
3536
|
});
|
|
3537
3537
|
});
|
|
3538
|
+
} else {
|
|
3539
|
+
let e = [...s].reverse().find((e) => e.sender === "bot" || e.sender === "assistant");
|
|
3540
|
+
if (e?.message) {
|
|
3541
|
+
let t = Fr(e.message);
|
|
3542
|
+
t && Sr(t.url, {
|
|
3543
|
+
siteId: i?.siteId,
|
|
3544
|
+
apiBaseUrl: i?.apiBaseUrl
|
|
3545
|
+
}).then((e) => {
|
|
3546
|
+
e && Or(t.url, { voiceActive: Et.current }).then((e) => {
|
|
3547
|
+
t.section && setTimeout(() => {
|
|
3548
|
+
let e = _r(null, t.section);
|
|
3549
|
+
e && vr(e);
|
|
3550
|
+
}, e ? 300 : 150);
|
|
3551
|
+
});
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3538
3554
|
}
|
|
3539
3555
|
S(Pr(s)), re(!!o.is_human_handled), te(o.is_human_handled ? "agent" : "ai"), we(!1), ke(!1), await k.current.updateChatStatus(y, "messageSent");
|
|
3540
3556
|
} catch (e) {
|
|
@@ -28926,16 +28942,22 @@ function ZO() {
|
|
|
28926
28942
|
}), e;
|
|
28927
28943
|
}
|
|
28928
28944
|
function QO() {
|
|
28929
|
-
return ZO().map((e, t) =>
|
|
28930
|
-
|
|
28931
|
-
|
|
28932
|
-
|
|
28933
|
-
|
|
28934
|
-
|
|
28935
|
-
|
|
28936
|
-
|
|
28937
|
-
|
|
28938
|
-
|
|
28945
|
+
return ZO().map((e, t) => {
|
|
28946
|
+
let n = {
|
|
28947
|
+
formIndex: 0,
|
|
28948
|
+
fieldIndex: t,
|
|
28949
|
+
tag: e.tagName,
|
|
28950
|
+
type: e.type || "text",
|
|
28951
|
+
name: e.name || null,
|
|
28952
|
+
id: e.id || null,
|
|
28953
|
+
label: XO(e),
|
|
28954
|
+
placeholder: e.placeholder || null
|
|
28955
|
+
};
|
|
28956
|
+
return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
|
|
28957
|
+
value: e.value,
|
|
28958
|
+
text: e.text.trim()
|
|
28959
|
+
})), n.currentValue = e.value || null), n;
|
|
28960
|
+
});
|
|
28939
28961
|
}
|
|
28940
28962
|
function $O() {
|
|
28941
28963
|
let e = [];
|
|
@@ -29405,6 +29427,9 @@ function wk(e) {
|
|
|
29405
29427
|
for (; Date.now() < t && !(typeof window < "u" && window.location.pathname === e);) await new Promise((e) => setTimeout(e, 80));
|
|
29406
29428
|
let n = typeof window < "u" ? window.location.pathname : e, r = typeof window < "u" ? window.location.href : a, i = n === e, o = (n.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home";
|
|
29407
29429
|
$("fwh-navigate-mvp → SPA nav complete. target:", e, "actual:", n);
|
|
29430
|
+
try {
|
|
29431
|
+
typeof window < "u" && window.scrollTo(0, 0);
|
|
29432
|
+
} catch {}
|
|
29408
29433
|
let s = [], c = Date.now() + 12e3;
|
|
29409
29434
|
for (; Date.now() < c && (await new Promise((e) => setTimeout(e, 300)), s = Ck(), !(s.length >= 1)););
|
|
29410
29435
|
Sk(), $("fwh-navigate-mvp → page headings collected:", s);
|
|
@@ -29555,6 +29580,58 @@ function wk(e) {
|
|
|
29555
29580
|
return $("fwh-search-mvp ✖", e.message), "Search failed. Use fwh-read-content-mvp to read the current page instead.";
|
|
29556
29581
|
}
|
|
29557
29582
|
},
|
|
29583
|
+
"fwh-list-nav-links-mvp": async () => {
|
|
29584
|
+
if ($("fwh-list-nav-links-mvp ▶"), typeof window > "u") return "Cannot read navigation (no browser context).";
|
|
29585
|
+
let e = /* @__PURE__ */ new Map(), t = [], n = [
|
|
29586
|
+
"nav a",
|
|
29587
|
+
"[role='navigation'] a",
|
|
29588
|
+
"header a",
|
|
29589
|
+
".navbar a",
|
|
29590
|
+
".nav a",
|
|
29591
|
+
".menu a",
|
|
29592
|
+
".navigation a",
|
|
29593
|
+
".header a",
|
|
29594
|
+
"[class*='nav'] a",
|
|
29595
|
+
"[class*='menu'] a",
|
|
29596
|
+
"[class*='header'] a"
|
|
29597
|
+
];
|
|
29598
|
+
if (JO((t) => {
|
|
29599
|
+
for (let r of n) try {
|
|
29600
|
+
t.querySelectorAll(r).forEach((t) => {
|
|
29601
|
+
if (KO(t)) return;
|
|
29602
|
+
let n = t.getAttribute("href"), r = (t.textContent || "").replace(/\s+/g, " ").trim();
|
|
29603
|
+
if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
|
|
29604
|
+
try {
|
|
29605
|
+
let e = qO(t);
|
|
29606
|
+
if (e.display === "none" || e.visibility === "hidden") return;
|
|
29607
|
+
} catch {}
|
|
29608
|
+
let i = r.toLowerCase() + "|" + n;
|
|
29609
|
+
e.has(i) || e.set(i, {
|
|
29610
|
+
text: r,
|
|
29611
|
+
href: n
|
|
29612
|
+
});
|
|
29613
|
+
});
|
|
29614
|
+
} catch {}
|
|
29615
|
+
t.querySelectorAll("select").forEach((t) => {
|
|
29616
|
+
if (KO(t)) return;
|
|
29617
|
+
let n = XO(t);
|
|
29618
|
+
/nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
|
|
29619
|
+
if (!r.value || r.disabled) return;
|
|
29620
|
+
let i = r.text.trim();
|
|
29621
|
+
if (!i) return;
|
|
29622
|
+
let a = i.toLowerCase() + "|" + r.value;
|
|
29623
|
+
e.has(a) || e.set(a, {
|
|
29624
|
+
text: i,
|
|
29625
|
+
href: r.value,
|
|
29626
|
+
isSelectOption: !0,
|
|
29627
|
+
selectLabel: n || t.name || "dropdown"
|
|
29628
|
+
});
|
|
29629
|
+
});
|
|
29630
|
+
});
|
|
29631
|
+
}), e.forEach((e) => t.push(e)), !t.length) return "NAV_LINKS: No navigation links found on this page. Use fwh-read-content-mvp to read page content or fwh-search-mvp to search the site.";
|
|
29632
|
+
let r = t.slice(0, 50).map((e, t) => `${t + 1}. "${e.text}"${e.isSelectOption ? ` (dropdown option in "${e.selectLabel}")` : ""} → ${e.href}`).join("\n");
|
|
29633
|
+
return $("fwh-list-nav-links-mvp ✓", `${t.length} links`), `NAV_LINKS (${t.length} total, showing up to 50):\n${r}\n\nIMPORTANT: Use the EXACT text shown above when reading link names to the visitor. Do NOT rename, abbreviate, or invent options not listed here. To navigate, call fwh-navigate-mvp with the href value.`;
|
|
29634
|
+
},
|
|
29558
29635
|
"fwh-end-session-mvp": async () => ($("fwh-end-session-mvp ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
29559
29636
|
"fwh-get-current-page-mvp": async () => {
|
|
29560
29637
|
if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
|
|
@@ -30297,7 +30374,7 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30297
30374
|
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 && (a = [...new Set(n)].slice(0, 15).join(" | "));
|
|
30298
30375
|
} catch {}
|
|
30299
30376
|
let o = u && !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` : "";
|
|
30300
|
-
ve.sendContextualUpdate(`${o}
|
|
30377
|
+
ve.sendContextualUpdate(`${o}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${a}. SiteId: ${i || "unknown"}. Forms: ${r}. The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: If the visitor requests a walkthrough, you MUST call fwh-get-current-page-mvp first (zero speech) to get the exact highlightable headings — do NOT use these approximate headings for highlighting. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
30301
30378
|
} catch {}
|
|
30302
30379
|
if (typeof window < "u") {
|
|
30303
30380
|
let t = window.location.pathname, n = () => {
|