@flowengage/react-chatbot 8.0.25 → 8.0.26
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.
|
@@ -2925,10 +2925,10 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2925
2925
|
return r.url === n && Date.now() - r.at < 4e3 ? Promise.resolve({
|
|
2926
2926
|
navigated: !0,
|
|
2927
2927
|
deduped: !0
|
|
2928
|
-
}) :
|
|
2928
|
+
}) : (ht.current = {
|
|
2929
2929
|
url: n,
|
|
2930
2930
|
at: Date.now()
|
|
2931
|
-
}
|
|
2931
|
+
}, Pr(e, t));
|
|
2932
2932
|
}, []), _t = p([]), vt = p(null), yt = p(null), bt = p(null), xt = p(!1), St = p(!1), Ct = p(""), wt = p(null), Tt = p(null), Et = p([]), Dt = p(0), Ot = p(se), kt = p([]), At = p(!1), jt = p(!1), Mt = p(i), Nt = p({
|
|
2933
2933
|
notifyRouteChange: () => {},
|
|
2934
2934
|
cleanup: () => {}
|
|
@@ -3307,27 +3307,18 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3307
3307
|
zt("socket:call_unavailable"), rt(Hr(e, "This visitor is not available for a call right now.")), te(!0);
|
|
3308
3308
|
}), f.on("call:error", (e = {}) => {
|
|
3309
3309
|
zt("socket:call_error"), rt(Hr(e, "We couldn't connect the call right now.")), te(!0);
|
|
3310
|
-
}), f.on("visitor:navigate", async ({ url: e, section:
|
|
3311
|
-
|
|
3312
|
-
if (!
|
|
3313
|
-
|
|
3314
|
-
apiBaseUrl: t.apiBaseUrl
|
|
3315
|
-
})) {
|
|
3316
|
-
C();
|
|
3310
|
+
}), f.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
|
|
3311
|
+
e && gt(e, { voiceActive: jt.current }).then(({ navigated: e, reason: r }) => {
|
|
3312
|
+
if (!e) {
|
|
3313
|
+
r === "not-found" ? C() : r === "already-on-page" && w();
|
|
3317
3314
|
return;
|
|
3318
3315
|
}
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
i && setTimeout(() => {
|
|
3326
|
-
let e = Sr(null, i);
|
|
3327
|
-
e && Cr(e);
|
|
3328
|
-
}, 300);
|
|
3329
|
-
});
|
|
3330
|
-
}
|
|
3316
|
+
let i = t || n;
|
|
3317
|
+
!i || !jt.current || setTimeout(() => {
|
|
3318
|
+
let e = Sr(null, i);
|
|
3319
|
+
e && Cr(e);
|
|
3320
|
+
}, 300);
|
|
3321
|
+
});
|
|
3331
3322
|
}), f.on("visitor:highlight", ({ sectionId: e, sectionText: t } = {}) => {
|
|
3332
3323
|
if (!e && !t) return;
|
|
3333
3324
|
let n = Sr(e || null, t || null);
|
|
@@ -3579,12 +3570,12 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3579
3570
|
return null;
|
|
3580
3571
|
}
|
|
3581
3572
|
}
|
|
3582
|
-
let nn = async (e, t = "", n = null,
|
|
3583
|
-
let
|
|
3584
|
-
if (!
|
|
3573
|
+
let nn = async (e, t = "", n = null, i = {}) => {
|
|
3574
|
+
let a = typeof e == "string" ? e.trim() : "";
|
|
3575
|
+
if (!a || !j.current || !y || l !== "ready" || He) return;
|
|
3585
3576
|
$t(), mt.current = !1;
|
|
3586
|
-
let
|
|
3587
|
-
if (pt.current &&
|
|
3577
|
+
let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, s = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, c = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3578
|
+
if (pt.current && o.test(a) && !s.test(a)) {
|
|
3588
3579
|
let { url: e, section: t } = pt.current;
|
|
3589
3580
|
pt.current = null, mt.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), gt(e, { voiceActive: jt.current }).then(({ navigated: e, reason: n }) => {
|
|
3590
3581
|
if (!e) {
|
|
@@ -3596,80 +3587,71 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3596
3587
|
e && Cr(e);
|
|
3597
3588
|
}, 300);
|
|
3598
3589
|
});
|
|
3599
|
-
} else
|
|
3600
|
-
let
|
|
3601
|
-
id:
|
|
3590
|
+
} else o.test(a) || (pt.current = null);
|
|
3591
|
+
let u = `pending-user-${Date.now()}`, d = {
|
|
3592
|
+
id: u,
|
|
3602
3593
|
sender: "user",
|
|
3603
3594
|
message: e,
|
|
3604
3595
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3605
3596
|
isPending: !0,
|
|
3606
|
-
type:
|
|
3607
|
-
metadata:
|
|
3597
|
+
type: i?.type || "text",
|
|
3598
|
+
metadata: i?.metadata || void 0,
|
|
3608
3599
|
...n || {}
|
|
3609
3600
|
};
|
|
3610
|
-
S((e) => [...e,
|
|
3611
|
-
let
|
|
3612
|
-
if (
|
|
3613
|
-
|
|
3601
|
+
S((e) => [...e, d]);
|
|
3602
|
+
let f = E;
|
|
3603
|
+
if (f) try {
|
|
3604
|
+
f = Pt(await j.current.checkHumanHandled(y));
|
|
3614
3605
|
} catch {}
|
|
3615
|
-
if (
|
|
3606
|
+
if (f && A.current?.connected) {
|
|
3616
3607
|
A.current.emit("customer:message", {
|
|
3617
3608
|
chatId: y,
|
|
3618
3609
|
content: e,
|
|
3619
3610
|
sender: "user",
|
|
3620
3611
|
email: me || void 0,
|
|
3621
|
-
type:
|
|
3622
|
-
metadata:
|
|
3612
|
+
type: i?.type || "text",
|
|
3613
|
+
metadata: i?.metadata || {},
|
|
3623
3614
|
...n || {}
|
|
3624
3615
|
});
|
|
3625
3616
|
return;
|
|
3626
3617
|
}
|
|
3627
3618
|
Ae(!0);
|
|
3628
3619
|
try {
|
|
3629
|
-
let
|
|
3620
|
+
let o = await j.current.sendAiMessage(y, e, r, t, {
|
|
3630
3621
|
...n || {},
|
|
3631
3622
|
...me ? { email: me } : {}
|
|
3632
3623
|
}, {
|
|
3633
|
-
...
|
|
3624
|
+
...i,
|
|
3634
3625
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
3635
3626
|
currentPageTitle: typeof window < "u" ? document.title : void 0,
|
|
3636
3627
|
currentPagePath: typeof window < "u" ? window.location.pathname : void 0,
|
|
3637
3628
|
currentPageContent: tn() || void 0
|
|
3638
|
-
}),
|
|
3629
|
+
}), s = o.chat_history || [];
|
|
3639
3630
|
if (console.log("[FWH Nav Debug] API response fields:", {
|
|
3640
|
-
has_navigate: !!
|
|
3641
|
-
navigate:
|
|
3642
|
-
has_pending_navigate: !!
|
|
3643
|
-
pending_navigate:
|
|
3644
|
-
last_bot_msg: [...
|
|
3645
|
-
}),
|
|
3631
|
+
has_navigate: !!o.navigate,
|
|
3632
|
+
navigate: o.navigate,
|
|
3633
|
+
has_pending_navigate: !!o.pending_navigate,
|
|
3634
|
+
pending_navigate: o.pending_navigate,
|
|
3635
|
+
last_bot_msg: [...s].reverse().find((e) => e.sender === "bot")?.message?.substring(0, 80)
|
|
3636
|
+
}), o.pending_navigate?.url) {
|
|
3646
3637
|
let e = {
|
|
3647
|
-
url:
|
|
3648
|
-
section:
|
|
3638
|
+
url: o.pending_navigate.url,
|
|
3639
|
+
section: o.pending_navigate.section || null
|
|
3649
3640
|
};
|
|
3650
|
-
|
|
3651
|
-
siteId: i?.siteId,
|
|
3652
|
-
apiBaseUrl: i?.apiBaseUrl
|
|
3653
|
-
}).then((t) => {
|
|
3641
|
+
c.test(a) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), gt(e.url, { voiceActive: jt.current }).then(({ navigated: t, reason: n }) => {
|
|
3654
3642
|
if (!t) {
|
|
3655
|
-
C();
|
|
3643
|
+
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3656
3644
|
return;
|
|
3657
3645
|
}
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
}
|
|
3663
|
-
e.section && setTimeout(() => {
|
|
3664
|
-
let t = Sr(null, e.section);
|
|
3665
|
-
t && Cr(t);
|
|
3666
|
-
}, 300);
|
|
3667
|
-
});
|
|
3646
|
+
e.section && setTimeout(() => {
|
|
3647
|
+
let t = Sr(null, e.section);
|
|
3648
|
+
t && Cr(t);
|
|
3649
|
+
}, 300);
|
|
3668
3650
|
})) : (pt.current = e, console.log("[FWH Nav] Stored pending nav →", pt.current));
|
|
3669
3651
|
}
|
|
3670
|
-
if (
|
|
3652
|
+
if (o.navigate?.url) if (mt.current) mt.current = !1;
|
|
3671
3653
|
else {
|
|
3672
|
-
let { url: e, section: t } =
|
|
3654
|
+
let { url: e, section: t } = o.navigate;
|
|
3673
3655
|
gt(e, { voiceActive: jt.current }).then(({ navigated: e, reason: n }) => {
|
|
3674
3656
|
if (!e) {
|
|
3675
3657
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
@@ -3682,7 +3664,7 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3682
3664
|
});
|
|
3683
3665
|
}
|
|
3684
3666
|
else {
|
|
3685
|
-
let e = [...
|
|
3667
|
+
let e = [...s].reverse().find((e) => e.sender === "bot" || e.sender === "assistant");
|
|
3686
3668
|
if (e?.message) {
|
|
3687
3669
|
let t = Vr(e.message);
|
|
3688
3670
|
t && Dr(t.url, {
|
|
@@ -3706,9 +3688,9 @@ function Kr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3706
3688
|
});
|
|
3707
3689
|
}
|
|
3708
3690
|
}
|
|
3709
|
-
S(Br(
|
|
3691
|
+
S(Br(s)), D(!!o.is_human_handled), re(o.is_human_handled ? "agent" : "ai"), De(!1), Ae(!1), await j.current.updateChatStatus(y, "messageSent");
|
|
3710
3692
|
} catch (e) {
|
|
3711
|
-
S((e) => e.filter((e) => e.id !==
|
|
3693
|
+
S((e) => e.filter((e) => e.id !== u)), De(!1), Ae(!1), e.status === 429 ? (Me(!0), Fe(e.message), window.setTimeout(() => {
|
|
3712
3694
|
Me(!1), Fe("");
|
|
3713
3695
|
}, ie)) : h(e);
|
|
3714
3696
|
}
|