@flowengage/react-chatbot 0.2.15 → 0.2.17
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.
|
@@ -26,10 +26,10 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
26
26
|
visitorEmail: "flowengage.visitorEmail"
|
|
27
27
|
}, ee = 1e4, te = 6e4, h = typeof window < "u", ne = () => {
|
|
28
28
|
if (!h) return "server-chat-id";
|
|
29
|
-
let e = window.
|
|
29
|
+
let e = window.localStorage.getItem(m.chatId);
|
|
30
30
|
if (e) return e;
|
|
31
31
|
let t = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
32
|
-
return window.
|
|
32
|
+
return window.localStorage.setItem(m.chatId, t), t;
|
|
33
33
|
}, re = () => h ? {
|
|
34
34
|
isOpen: !1,
|
|
35
35
|
activeScreen: window.sessionStorage.getItem(m.activeScreen) || "ai",
|
|
@@ -81,7 +81,7 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
81
81
|
throw n.status = 0, n.cause = t, n;
|
|
82
82
|
}
|
|
83
83
|
}, ce = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
84
|
-
let n = typeof window < "u" ? window.location.origin : "http://localhost", r = `${e}/api/widget/
|
|
84
|
+
let n = typeof window < "u" ? window.location.origin : "http://localhost", r = `${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
85
85
|
siteId: t,
|
|
86
86
|
origin: n
|
|
87
87
|
}).toString()}`;
|
|
@@ -2495,9 +2495,17 @@ function dn({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2495
2495
|
trackCount: n.length
|
|
2496
2496
|
}), Ke(r);
|
|
2497
2497
|
}, xt = async () => {
|
|
2498
|
-
if (fe(!0), S.current && g)
|
|
2499
|
-
|
|
2500
|
-
|
|
2498
|
+
if (fe(!0), S.current && g && typeof window < "u") {
|
|
2499
|
+
try {
|
|
2500
|
+
await S.current.trackVisitor({
|
|
2501
|
+
chatId: g,
|
|
2502
|
+
currentPagePath: window.location.pathname || "/"
|
|
2503
|
+
});
|
|
2504
|
+
} catch {}
|
|
2505
|
+
try {
|
|
2506
|
+
await S.current.updateChatStatus(g, "open");
|
|
2507
|
+
} catch {}
|
|
2508
|
+
}
|
|
2501
2509
|
}, St = async (e) => {
|
|
2502
2510
|
let t = dt(e);
|
|
2503
2511
|
if (!t || !S.current || !C.current) return t;
|
|
@@ -22057,7 +22065,7 @@ function Hh(e) {
|
|
|
22057
22065
|
function Uh(e) {
|
|
22058
22066
|
if (!e || typeof e != "string") return [];
|
|
22059
22067
|
let t = e.trim();
|
|
22060
|
-
if (!t) return [];
|
|
22068
|
+
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
22061
22069
|
let n = t.match(/https?:\/\/[^\s<>"']+/i);
|
|
22062
22070
|
if (n) return [{
|
|
22063
22071
|
field_key: "url",
|
|
@@ -22077,7 +22085,7 @@ function Wh(e) {
|
|
|
22077
22085
|
if (!e || typeof e != "string") return [];
|
|
22078
22086
|
let t = e.trim();
|
|
22079
22087
|
if (!t) return [];
|
|
22080
|
-
let n = [], r = /* @__PURE__ */ new Set(), i = (e, t) => {
|
|
22088
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = /\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\b/i, a = (e, t) => {
|
|
22081
22089
|
let i = String(t ?? "").trim().replace(/^["']|["']$/g, "");
|
|
22082
22090
|
if (!i || i.length > 800) return;
|
|
22083
22091
|
let a = `${e}\0${i}`;
|
|
@@ -22085,14 +22093,27 @@ function Wh(e) {
|
|
|
22085
22093
|
field_key: e,
|
|
22086
22094
|
value: i
|
|
22087
22095
|
}));
|
|
22088
|
-
},
|
|
22089
|
-
if (
|
|
22090
|
-
|
|
22091
|
-
|
|
22096
|
+
}, o = t.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22097
|
+
if (o) return a("Email Address", o[1]), n;
|
|
22098
|
+
let s = t.match(/\b(?:please\s+)?(?:enter|type|put)\s+(.+?)\s+in(?:to)?\s+(?:the\s+)?(?:full\s*name|full\s*name\s*field|name\s*field)\b/i);
|
|
22099
|
+
if (s && a("Full Name", s[1]), s = t.match(/\bfull\s*name,?\s*(?:please\s+)?(?:enter|type|put)\s+(.+?)(?:\.|$|!|\?)/i), s && a("Full Name", s[1]), s = t.match(/\bfull\s*name\s*(?:is|:|please\s+enter|-)\s*(.+?)(?:\.|$|(?=\s+(?:and|my\s+email|email|message))\b)/i), s && a("Full Name", s[1]), s = t.match(/\b(.+?)\s+for\s+(?:the\s+)?full\s*name\b/i), s) {
|
|
22100
|
+
let e = s[1].trim();
|
|
22101
|
+
e.length > 1 && e.length < 120 && !/@/.test(e) && a("Full Name", e);
|
|
22102
|
+
}
|
|
22103
|
+
if (s = t.match(/\b(?:email|e-mail)(?:\s*address)?\s*(?:is|:|please\s+use|enter|-)\s*([^\s@]+@[^\s@]+\.[^\s,]+)/i), s && a("Email Address", s[1]), s = t.match(/\b(?:enter|type|put)\s+([^\s@]+@[^\s@]+\.[^\s,]+)\s+in(?:to)?\s+(?:the\s+)?(?:email|e-mail)/i), s && a("Email Address", s[1]), s = t.match(/\b(?:message|comment)\s*(?:is|:|please\s+enter|-)\s*(.+)$/is), s) {
|
|
22104
|
+
let e = s[1].trim();
|
|
22105
|
+
e.length > 0 && a("Message", e);
|
|
22106
|
+
}
|
|
22107
|
+
if (!n.some((e) => /email/i.test(String(e.field_key)))) {
|
|
22108
|
+
let e = t.match(i);
|
|
22109
|
+
if (e) {
|
|
22110
|
+
let r = t.replace(e[0], "").trim().replace(/^(please|it's|it is|use|is|my email is|e-?mail is)\s*/i, "").replace(/[.,;:!?]+$/, "").trim();
|
|
22111
|
+
if (t.length <= 96 && r.length <= 36) return a("Email Address", e[1]), n;
|
|
22112
|
+
}
|
|
22092
22113
|
}
|
|
22093
|
-
if (
|
|
22094
|
-
let e = a[
|
|
22095
|
-
|
|
22114
|
+
if (n.length === 0) {
|
|
22115
|
+
let e = t.split(/\s+/).filter(Boolean).length, n = /[.!?]/.test(t) || e >= 6 || t.length >= 24 && e >= 5 || t.length >= 42, r = /^[A-Z][a-z]+\s+[A-Z][a-z]+$/.test(t.trim());
|
|
22116
|
+
n && t.length >= 16 && !i.test(t) && !r && a("Message", t);
|
|
22096
22117
|
}
|
|
22097
22118
|
return n;
|
|
22098
22119
|
}
|
|
@@ -22238,7 +22259,7 @@ function Jh(e) {
|
|
|
22238
22259
|
let e = r(), n = Uh(e);
|
|
22239
22260
|
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Wh(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
|
|
22240
22261
|
}
|
|
22241
|
-
if ($("fill_form_fields · normalized fields:", t), !t.length) return "No fields provided. Call list_page_forms, then fill_form_fields with { \"fields\": [ { \"field_key\": \"
|
|
22262
|
+
if ($("fill_form_fields · normalized fields:", t), !t.length) return "No fields provided. Call list_page_forms for field_key strings, then fill_form_fields with { \"fields\": [ { \"field_key\": \"<label or placeholder from list>\", \"value\": \"<user value>\" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.";
|
|
22242
22263
|
let n = [];
|
|
22243
22264
|
for (let e of t) {
|
|
22244
22265
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|