@flowengage/react-chatbot 5.0.13 → 5.0.15

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.
@@ -2900,7 +2900,31 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
2900
2900
  let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
2901
2901
  a.ondataavailable = (e) => {
2902
2902
  e.data && e.data.size > 0 && St.current.push(e.data);
2903
- }, bt.current = a, Ct.current = Date.now(), a.start(1e3);
2903
+ }, bt.current = a, Ct.current = Date.now(), a.start(1e3), setTimeout(() => {
2904
+ try {
2905
+ if (!window.speechSynthesis) return;
2906
+ let e = new SpeechSynthesisUtterance("This call is being recorded.");
2907
+ if (e.rate = .95, e.pitch = 1, e.volume = 1, window.MediaStreamTrackGenerator || window.AudioContext) try {
2908
+ let t = n.createMediaStreamDestination();
2909
+ e.onstart = () => {
2910
+ try {
2911
+ let i = document.createElement("audio");
2912
+ i.style.display = "none", i.srcObject = t.stream, document.body.appendChild(i), i.play().catch(() => {});
2913
+ let a = n.createMediaStreamSource(t.stream);
2914
+ a.connect(r), e.onend = () => {
2915
+ try {
2916
+ a.disconnect();
2917
+ } catch {}
2918
+ try {
2919
+ i.remove();
2920
+ } catch {}
2921
+ };
2922
+ } catch {}
2923
+ };
2924
+ } catch {}
2925
+ window.speechSynthesis.speak(e);
2926
+ } catch {}
2927
+ }, 200);
2904
2928
  }
2905
2929
  } catch {}
2906
2930
  }
@@ -30012,15 +30036,20 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30012
30036
  }, g = (d.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), _ = "";
30013
30037
  f && f.includes("|") && (_ = f.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
30014
30038
  let y = _ || g || "this page";
30015
- m ? c ? (h.overrides = { agent: { firstMessage: `I've navigated you to the ${y} page. Starting the tour now —` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${y}" (${d})`)) : o ? h.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } } : p || (h.overrides = { agent: { firstMessage: `Hi! I see you are currently on the ${y} page. Are you looking for something specific here?` } }, console.log(`[FlowEngage] 🏠 Page-context override: "${y}" for ${d}`)) : o && (h.overrides = { agent: { firstMessage: "" } });
30016
- let x = await pD.startSession({
30039
+ m ? c ? (h.overrides = { agent: { firstMessage: `I've navigated you to the ${y} page. Let me walk you through what's here.` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${y}" (${d})`)) : o ? h.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } } : p || (h.overrides = { agent: { firstMessage: `Hi! I see you are currently on the ${y} page. Are you looking for something specific here?` } }, console.log(`[FlowEngage] 🏠 Page-context override: "${y}" for ${d}`)) : o && (h.overrides = { agent: { firstMessage: "" } });
30040
+ let x = !1, S = c ? `NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a ? je(a) : null)?.transcript || ""}\n\n` : null, T = await pD.startSession({
30017
30041
  ...h,
30018
30042
  onConnect: ({ conversationId: e }) => {
30019
30043
  ie.current = e, ae.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
30020
30044
  },
30021
30045
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
30022
30046
  onModeChange: ({ mode: t }) => {
30023
- e || v(t === "speaking" ? "speaking" : "listening");
30047
+ if (!e && (v(t === "speaking" ? "speaking" : "listening"), t === "listening" && S && !x)) {
30048
+ x = !0;
30049
+ try {
30050
+ C.current?.sendUserMessage?.("continue with the tour");
30051
+ } catch {}
30052
+ }
30024
30053
  },
30025
30054
  onMessage: (t) => {
30026
30055
  if (e) return;
@@ -30068,17 +30097,17 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30068
30097
  }
30069
30098
  });
30070
30099
  if (e) {
30071
- x.endSession().catch(() => {});
30100
+ T.endSession().catch(() => {});
30072
30101
  return;
30073
30102
  }
30074
- i = x, C.current = x, v("listening");
30103
+ i = T, C.current = T, v("listening");
30075
30104
  try {
30076
30105
  let e = typeof window < "u" ? window.location.href : "", r = "[]";
30077
30106
  try {
30078
30107
  r = await t.list_page_forms();
30079
30108
  } catch {}
30080
- let i = c ? `NAVIGATION RESUME — You just navigated the visitor to the ${y} page. Your first message has already been spoken. Your VERY NEXT action MUST be to call flowengage_highlight for the first content section on this page — do this immediately, do NOT wait for the visitor to speak, do NOT ask if they want to continue. After highlighting, speak one sentence about that section. Then call flowengage_highlight for the next section and speak about it. Continue section by section until you have covered the key content. Prior conversation context:\n${n.transcript}\n\n` : o ? `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` : "";
30081
- x.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
30109
+ let i = o && !c ? `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` : "";
30110
+ T.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
30082
30111
  } catch {}
30083
30112
  } catch (r) {
30084
30113
  e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (v("error"), E.current = "chat", window.setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "5.0.13",
3
+ "version": "5.0.15",
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",