@flowengage/react-chatbot 7.0.18 → 7.0.20

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.
@@ -3484,7 +3484,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
3484
3484
  }, $t = async (e, t = "", n = null, i = {}) => {
3485
3485
  let a = typeof e == "string" ? e.trim() : "";
3486
3486
  if (!a || !k.current || !y || l !== "ready" || Ve) return;
3487
- Zt(), mt.current = !1;
3487
+ Zt();
3488
3488
  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;
3489
3489
  if (pt.current && o.test(a) && !/^\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.test(a)) {
3490
3490
  let { url: e, section: t } = pt.current;
@@ -30279,13 +30279,13 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30279
30279
  requestEndSession: () => {
30280
30280
  se.current = !0;
30281
30281
  }
30282
- })), n = i ? je(i) : null, u = !!n?.transcript, p = !!(i && He(i)), m = typeof window < "u" ? window.location.pathname : "/", h = typeof document < "u" ? document.title : "", g = m === "/" || m === "", _ = null;
30282
+ })), n = i ? je(i) : null, u = !!n?.transcript, p = !!(i && He(i)), m = typeof window < "u" ? window.location.pathname : "/", h = typeof document < "u" ? document.title : "", g = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", _ = g === "/" || g === "", y = null;
30283
30283
  try {
30284
30284
  let e = await fetch(`${a}/api/voice/signed-url?siteId=${encodeURIComponent(i || "")}`, {
30285
30285
  method: "GET",
30286
30286
  headers: { "Content-Type": "application/json" }
30287
30287
  });
30288
- if (e.ok) _ = (await e.json()).signedUrl || null, _ && console.log("[FlowEngage] ✅ Using signed ElevenLabs URL");
30288
+ if (e.ok) y = (await e.json()).signedUrl || null, y && console.log("[FlowEngage] ✅ Using signed ElevenLabs URL");
30289
30289
  else if (e.status === 429) {
30290
30290
  let t = await e.json().catch(() => ({}));
30291
30291
  throw Error(t.message || "Too many voice sessions started. Please wait a minute before trying again.");
@@ -30294,23 +30294,23 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30294
30294
  if (e.message && e.message.includes("Too many voice sessions")) throw e;
30295
30295
  console.warn("[FlowEngage] ⚠️ Signed URL fetch error:", e.message);
30296
30296
  }
30297
- let y = {
30297
+ let x = {
30298
30298
  clientTools: t,
30299
30299
  connectionType: "websocket",
30300
30300
  minSpeechDurationMs: 50,
30301
- ..._ ? { signedUrl: _ } : { agentId: r }
30302
- }, x = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), S = "";
30303
- h && h.includes("|") && (S = h.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
30304
- let T = S || x || "this page";
30305
- if (_) if (p) y.overrides = { agent: { firstMessage: `Here we are — I've taken you to the ${T} page.` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${T}" (${m})`);
30306
- else if (u) y.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } };
30301
+ ...y ? { signedUrl: y } : { agentId: r }
30302
+ }, S = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), T = "";
30303
+ h && h.includes("|") && (T = h.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
30304
+ let oe = T || S || "this page";
30305
+ if (y) if (p) x.overrides = { agent: { firstMessage: `Here we are — I've taken you to the ${oe} page.` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${oe}" (${m})`);
30306
+ else if (u) x.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } };
30307
30307
  else {
30308
30308
  let e = f || "";
30309
- y.overrides = { agent: { firstMessage: g ? e ? `Hi, welcome to ${e}!` : "Hi, welcome!" : `Welcome to the ${T} page!` } }, g || console.log(`[FlowEngage] 🏠 Page-context override: "${T}" for ${m}`);
30309
+ x.overrides = { agent: { firstMessage: _ ? e ? `Hi, welcome to ${e}!` : "Hi, welcome!" : `Welcome to the ${oe} page!` } }, _ || console.log(`[FlowEngage] 🏠 Page-context override: "${oe}" for ${m}`);
30310
30310
  }
30311
- else u && (y.overrides = { agent: { firstMessage: "" } });
30312
- let oe = !1, he = p ? `NAVIGATION COMPLETE — Your brief intro has been spoken. PRIOR CONVERSATION CONTEXT (continue from here — do NOT re-introduce yourself):\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow speak 2-3 sentences about this page from your knowledge, referring to the visitor's prior context if relevant. Then ask the visitor exactly this: "Would you like to know about a specific section, or should I give you a complete overview?" Then STOP — wait for their reply. Do NOT auto-highlight or auto-walkthrough.` : null, ge = !1, _e = !p && !u ? "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, ve = await bD.startSession({
30313
- ...y,
30311
+ else u && (x.overrides = { agent: { firstMessage: "" } });
30312
+ let he = !1, ge = p ? `NAVIGATION COMPLETE — Your brief intro has been spoken. PRIOR CONVERSATION CONTEXT (continue from here — do NOT re-introduce yourself):\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow speak 2-3 sentences about this page from your knowledge, referring to the visitor's prior context if relevant. Then ask the visitor exactly this: "Would you like to know about a specific section, or should I give you a complete overview?" Then STOP — wait for their reply. Do NOT auto-highlight or auto-walkthrough.` : null, _e = !1, ve = !p && !u ? "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, ye = await bD.startSession({
30313
+ ...x,
30314
30314
  onConnect: ({ conversationId: e }) => {
30315
30315
  ie.current = e, ae.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
30316
30316
  },
@@ -30325,16 +30325,16 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30325
30325
  se.current = !1, me();
30326
30326
  return;
30327
30327
  }
30328
- if (he && !oe) {
30329
- oe = !0;
30328
+ if (ge && !he) {
30329
+ he = !0;
30330
30330
  try {
30331
- C.current?.sendContextualUpdate?.(he);
30331
+ C.current?.sendContextualUpdate?.(ge);
30332
30332
  } catch {}
30333
30333
  }
30334
- if (_e && !ge) {
30335
- ge = !0;
30334
+ if (ve && !_e) {
30335
+ _e = !0;
30336
30336
  try {
30337
- C.current?.sendContextualUpdate?.(_e);
30337
+ C.current?.sendContextualUpdate?.(ve);
30338
30338
  } catch {}
30339
30339
  }
30340
30340
  fe.current && clearTimeout(fe.current), fe.current = setTimeout(() => {
@@ -30399,10 +30399,10 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30399
30399
  }
30400
30400
  });
30401
30401
  if (e) {
30402
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ve.endSession().catch(() => {});
30402
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ye.endSession().catch(() => {});
30403
30403
  return;
30404
30404
  }
30405
- o = ve, C.current = ve, v("listening");
30405
+ o = ye, C.current = ye, v("listening");
30406
30406
  try {
30407
30407
  let e = typeof window < "u" ? window.location.href : "", r = "[]";
30408
30408
  try {
@@ -30414,7 +30414,7 @@ function Ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30414
30414
  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(" | "));
30415
30415
  } catch {}
30416
30416
  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` : "";
30417
- 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.`);
30417
+ ye.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.`);
30418
30418
  } catch {}
30419
30419
  if (typeof window < "u") {
30420
30420
  let t = window.location.pathname, n = () => {
@@ -30948,61 +30948,66 @@ function zk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30948
30948
  })
30949
30949
  })
30950
30950
  }),
30951
- /* @__PURE__ */ _("div", {
30952
- style: {
30953
- minWidth: 0,
30954
- maxWidth: s ? "100%" : "250px",
30955
- width: "100%",
30956
- justifySelf: "center",
30957
- display: "grid",
30958
- gridTemplateColumns: "minmax(72px, 40%) minmax(0, 60%)",
30959
- alignItems: "center"
30960
- },
30961
- children: [/* @__PURE__ */ g("div", {
30951
+ (() => {
30952
+ let t = !!i, n = !!e.hasCustomTitle, r = t || n, a = t || !r, o = n || !r, c = a && o;
30953
+ return /* @__PURE__ */ _("div", {
30962
30954
  style: {
30963
30955
  minWidth: 0,
30964
- display: "flex",
30956
+ maxWidth: s ? "100%" : "250px",
30957
+ width: "100%",
30958
+ justifySelf: "center",
30959
+ display: "grid",
30960
+ gridTemplateColumns: c ? "minmax(72px, 40%) minmax(0, 60%)" : "1fr",
30965
30961
  alignItems: "center",
30966
- justifyContent: "center",
30967
- height: "40px"
30962
+ justifyItems: c ? "stretch" : "center"
30968
30963
  },
30969
- children: i ? /* @__PURE__ */ g(Ak, {
30970
- logo: i,
30964
+ children: [a && /* @__PURE__ */ g("div", {
30971
30965
  style: {
30972
- height: "34px",
30973
- width: "100%",
30974
- maxWidth: "96px"
30975
- }
30976
- }) : /* @__PURE__ */ g("div", {
30977
- style: {
30978
- width: "40px",
30979
- height: "40px",
30980
- flexShrink: 0
30966
+ minWidth: 0,
30967
+ display: "flex",
30968
+ alignItems: "center",
30969
+ justifyContent: "center",
30970
+ height: "40px"
30981
30971
  },
30982
- children: /* @__PURE__ */ g(jk, { title: e.chatTitle })
30983
- })
30984
- }), /* @__PURE__ */ g("div", {
30985
- style: {
30986
- minWidth: 0,
30987
- display: "flex",
30988
- alignItems: "center"
30989
- },
30990
- children: /* @__PURE__ */ g("span", {
30972
+ children: i ? /* @__PURE__ */ g(Ak, {
30973
+ logo: i,
30974
+ style: {
30975
+ height: "34px",
30976
+ width: "100%",
30977
+ maxWidth: "96px"
30978
+ }
30979
+ }) : /* @__PURE__ */ g("div", {
30980
+ style: {
30981
+ width: "40px",
30982
+ height: "40px",
30983
+ flexShrink: 0
30984
+ },
30985
+ children: /* @__PURE__ */ g(jk, { title: e.chatTitle })
30986
+ })
30987
+ }), o && /* @__PURE__ */ g("div", {
30991
30988
  style: {
30992
- fontSize: "15px",
30993
- fontWeight: 600,
30994
- color: "#111827",
30995
- letterSpacing: "-0.01em",
30996
- lineHeight: 1.2,
30997
- overflow: "hidden",
30998
- textOverflow: "ellipsis",
30999
- whiteSpace: "nowrap"
30989
+ minWidth: 0,
30990
+ display: "flex",
30991
+ alignItems: "center",
30992
+ justifyContent: c ? "flex-start" : "center"
31000
30993
  },
31001
- title: e.chatTitle,
31002
- children: e.chatTitle
31003
- })
31004
- })]
31005
- }),
30994
+ children: /* @__PURE__ */ g("span", {
30995
+ style: {
30996
+ fontSize: "15px",
30997
+ fontWeight: 600,
30998
+ color: "#111827",
30999
+ letterSpacing: "-0.01em",
31000
+ lineHeight: 1.2,
31001
+ overflow: "hidden",
31002
+ textOverflow: "ellipsis",
31003
+ whiteSpace: "nowrap"
31004
+ },
31005
+ title: e.chatTitle,
31006
+ children: e.chatTitle
31007
+ })
31008
+ })]
31009
+ });
31010
+ })(),
31006
31011
  /* @__PURE__ */ _("div", {
31007
31012
  style: {
31008
31013
  position: "relative",
@@ -31631,6 +31636,7 @@ function Bk() {
31631
31636
  voiceLabel: Ae.voiceLabel || "Voice",
31632
31637
  textLabel: Ae.textLabel || "Text",
31633
31638
  chatTitle: Ae.headerName || "Chat with FlowEngage",
31639
+ hasCustomTitle: !!(Ae.headerName && String(Ae.headerName).trim()),
31634
31640
  introGreeting: Ze,
31635
31641
  inputPlaceholder: Ae.inputPlaceholder || "Type your message",
31636
31642
  analysingLabel: Ae.analysingLabel || "analysing..."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "7.0.18",
3
+ "version": "7.0.20",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",