@flowengage/react-chatbot 1.8.10 → 1.8.12

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.
@@ -3429,8 +3429,8 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
3429
3429
  let t = Yn(e);
3430
3430
  b((e) => {
3431
3431
  if (!e.length) return t;
3432
- let n = e[e.length - 1], r = t[0];
3433
- return n && r && n.sender === r.sender && n.message === r.message ? e : [...e, ...t];
3432
+ let n = new Set(e.map((e) => `${e.sender}\0${e.message}`)), r = t.filter((e) => !n.has(`${e.sender}\0${e.message}`));
3433
+ return r.length ? [...e, ...r] : e;
3434
3434
  });
3435
3435
  };
3436
3436
  try {
@@ -29470,8 +29470,20 @@ function ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29470
29470
  isMuted: te.current
29471
29471
  };
29472
29472
  }
29473
- })), o = await PE.startSession({
29473
+ })), o = typeof window < "u" ? window.location.href : "", c, l = null;
29474
+ if (u && !u.consumed) {
29475
+ let e = typeof document < "u" ? Array.from(document.querySelectorAll("h1,h2,h3,h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell")).map((e) => ({
29476
+ tag: e.tagName,
29477
+ text: e.textContent.trim().slice(0, 100),
29478
+ id: e.id || null
29479
+ })).filter((e) => e.text.length > 0).slice(0, 25) : [];
29480
+ l = FD.buildResumePrompt(u, e, o);
29481
+ let t = e[0]?.text || "";
29482
+ c = { agent: { firstMessage: t ? `I'm now on the ${t} page. Let me walk you through it.` : "I've navigated to the new page. Let me continue our conversation." } };
29483
+ }
29484
+ let f = await PE.startSession({
29474
29485
  agentId: r,
29486
+ ...c ? { overrides: c } : {},
29475
29487
  clientTools: t,
29476
29488
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
29477
29489
  onModeChange: ({ mode: t }) => {
@@ -29480,7 +29492,9 @@ function ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29480
29492
  onMessage: (t) => {
29481
29493
  if (e) return;
29482
29494
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
29483
- r && (n === "user" && (C.current = r), s.current = [...s.current, {
29495
+ if (!r) return;
29496
+ let i = s.current, a = i.length > 0 ? i[i.length - 1] : null;
29497
+ a && a.sender === n && a.message === r || (n === "user" && (C.current = r), s.current = [...i, {
29484
29498
  sender: n,
29485
29499
  message: r,
29486
29500
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
@@ -29496,7 +29510,7 @@ function ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29496
29510
  try {
29497
29511
  S.current?.setMicMuted?.(!0);
29498
29512
  } catch {}
29499
- y(!0), h("error"), oe("chat");
29513
+ y(!0), h("error"), oe("minimized");
29500
29514
  }
29501
29515
  },
29502
29516
  onDisconnect: () => {
@@ -29509,35 +29523,28 @@ function ik({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29509
29523
  try {
29510
29524
  S.current?.setMicMuted?.(!0);
29511
29525
  } catch {}
29512
- y(!0), oe("chat");
29526
+ y(!0), oe("minimized");
29513
29527
  }
29514
29528
  }
29515
29529
  });
29516
29530
  if (e) {
29517
- o.endSession().catch(() => {});
29531
+ f.endSession().catch(() => {});
29518
29532
  return;
29519
29533
  }
29520
- n = o, S.current = o, h("listening");
29534
+ n = f, S.current = f, h("listening");
29521
29535
  try {
29522
- let e = typeof window < "u" ? window.location.href : "";
29523
- if (u && !u.consumed) {
29524
- let t = typeof document < "u" ? Array.from(document.querySelectorAll("h1,h2,h3,h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell")).map((e) => ({
29525
- tag: e.tagName,
29526
- text: e.textContent.trim().slice(0, 100),
29527
- id: e.id || null
29528
- })).filter((e) => e.text.length > 0).slice(0, 25) : [], n = FD.buildResumePrompt(u, t, e);
29529
- o.sendContextualUpdate(n), FD.clear();
29530
- } else {
29531
- let n = "[]";
29536
+ if (l) f.sendContextualUpdate(l), FD.clear();
29537
+ else {
29538
+ let e = "[]";
29532
29539
  try {
29533
- n = await t.flowengage_list_forms();
29540
+ e = await t.flowengage_list_forms();
29534
29541
  } catch {}
29535
- let r = typeof document < "u" ? Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, nav, footer, header")).map((e) => ({
29542
+ let n = typeof document < "u" ? Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, nav, footer, header")).map((e) => ({
29536
29543
  tag: e.tagName,
29537
29544
  text: e.textContent.trim(),
29538
29545
  id: e.id || null
29539
29546
  })).filter((e) => e.text.length > 0 && e.text.length < 200).slice(0, 25) : [];
29540
- o.sendContextualUpdate(`Page: ${e}. SiteId: ${i || "unknown"}. Sections on this page: ${JSON.stringify(r)}. IMPORTANT: Call flowengage_highlight with section_text from the list above as you explain each section. Forms: ${n}. Navigation: flowengage_navigate — use for cross-page navigation. End call: flowengage_end_session.`);
29547
+ f.sendContextualUpdate(`Page: ${o}. SiteId: ${i || "unknown"}. Sections on this page: ${JSON.stringify(n)}. IMPORTANT: Call flowengage_highlight with section_text from the list above as you explain each section. Forms: ${e}. Navigation: flowengage_navigate — use for cross-page navigation. End call: flowengage_end_session.`);
29541
29548
  }
29542
29549
  } catch {}
29543
29550
  } catch (n) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "1.8.10",
3
+ "version": "1.8.12",
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",