@flowengage/react-chatbot 8.0.73 → 8.0.76

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.
@@ -2913,7 +2913,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2913
2913
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2914
2914
  }]);
2915
2915
  }, []), w = o(() => {
2916
- S((e) => [...e, {
2916
+ S((e) => e.slice(-3).some((e) => (e.sender === "bot" || e.sender === "assistant") && /already on (that|this|the)\b/i.test(String(e.message || ""))) ? e : [...e, {
2917
2917
  id: `nav-already-${e.length}-${Math.random().toString(36).slice(2, 8)}`,
2918
2918
  sender: "bot",
2919
2919
  message: "Looks like you're already on this page!",
@@ -3326,7 +3326,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3326
3326
  return;
3327
3327
  }
3328
3328
  let i = t || n;
3329
- !i || !yt.current || setTimeout(() => {
3329
+ i && setTimeout(() => {
3330
3330
  let e = cr(null, i);
3331
3331
  e && lr(e);
3332
3332
  }, 300);
@@ -3669,13 +3669,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3669
3669
  n === "not-found" ? C() : n === "already-on-page" && w();
3670
3670
  return;
3671
3671
  }
3672
- !t || !yt.current || setTimeout(() => {
3672
+ t && setTimeout(() => {
3673
3673
  let e = cr(null, t);
3674
3674
  e && lr(e);
3675
3675
  }, 300);
3676
3676
  });
3677
3677
  }
3678
- else {
3678
+ else if (o.highlight?.section) {
3679
+ let e = o.highlight.section;
3680
+ setTimeout(() => {
3681
+ let t = cr(null, e);
3682
+ t && lr(t);
3683
+ }, 150);
3684
+ } else {
3679
3685
  let e = [...s].reverse().find((e) => e.sender === "bot" || e.sender === "assistant");
3680
3686
  if (e?.message) {
3681
3687
  let t = Dr(e.message);
@@ -8903,7 +8909,7 @@ async function Pm(e) {
8903
8909
  let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await Nm(t, n, r);
8904
8910
  f?.({ emailOnFile: !!m.emailOnFile });
8905
8911
  let h = { type: "Start" };
8906
- e.greeting !== void 0 && (h.greeting = e.greeting || null), e.greetingAlreadySpoken && (h.greetingAlreadySpoken = !0);
8912
+ e.greeting !== void 0 && (h.greeting = e.greeting || null);
8907
8913
  let g = await navigator.mediaDevices.getUserMedia({ audio: {
8908
8914
  channelCount: 1,
8909
8915
  echoCancellation: !0,
@@ -12982,13 +12988,8 @@ function Mg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12982
12988
  let e = f || "";
12983
12989
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${w} page!`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
12984
12990
  }
12985
- let ee = !1, O = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [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, k = !1, ne = !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, re = r && !p, A = !1, ie = re ? `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, oe = !1, _e = !1, Te = b && !!y && !de.current, De = !1;
12986
- if (typeof window < "u" && window.speechSynthesis && x.greeting) try {
12987
- window.speechSynthesis.cancel(), window.speechSynthesis.speak(new SpeechSynthesisUtterance(x.greeting)), De = !0;
12988
- } catch {}
12989
- let R = await Fm.startSession({
12991
+ let ee = !1, O = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [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, k = !1, ne = !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, re = r && !p, A = !1, ie = re ? `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, oe = !1, _e = !1, Te = b && !!y && !de.current, De = await Fm.startSession({
12990
12992
  ...x,
12991
- greetingAlreadySpoken: De,
12992
12993
  onConnect: ({ conversationId: e }) => {
12993
12994
  Ce.current = e, F.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
12994
12995
  },
@@ -13103,10 +13104,10 @@ function Mg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13103
13104
  }
13104
13105
  });
13105
13106
  if (e) {
13106
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), R.endSession().catch(() => {});
13107
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), De.endSession().catch(() => {});
13107
13108
  return;
13108
13109
  }
13109
- o = R, N.current = R, T("listening");
13110
+ o = De, N.current = De, T("listening");
13110
13111
  try {
13111
13112
  let e = typeof window < "u" ? window.location.href : "", a = "[]";
13112
13113
  try {
@@ -13118,7 +13119,7 @@ function Mg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13118
13119
  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(" | "));
13119
13120
  } catch {}
13120
13121
  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` : "";
13121
- R.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.`);
13122
+ De.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.`);
13122
13123
  } catch {}
13123
13124
  if (typeof window < "u") {
13124
13125
  let t = window.location.pathname, n = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "8.0.73",
3
+ "version": "8.0.76",
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",