Issues and feedback about Sounds in AI Chatbot

Thanks for the update, @Petar_Dietrich!

Do I get it right that the issue you’ve reported initially has beed resolved too?

Hi @Max,

Well, I jumped the gun. Apologies. The Open Window sound on Firefox is still not working (tested with and without the JS code installed in the configurator). However, the JS code does successfully block the sounds on mobile devices (e.g., iPhones) and tablets (e.g., iPads).

For now, my final (cleaned-up) JS code is provided below. Our team is OK with this. Since nobody else is reporting sound issues (except for Apple devices), I’ll leave it up to you how to “clean up” this post. Didn’t mean to hack it. :slight_smile:

I believe the community still needs assistance with the sounds not playing at all (or playing delayed) on iPhones and iPads.

Thanks for your patience and help!


Final JS Code:

/* ---------------------------------------------------------
   DEVICE-BASED SOUND BLOCKER (Clean & Stable Version)
--------------------------------------------------------- */

const WIDGET_ID = 'YOUR_WIDGET_ID';

const ALLOWED_DEVICES = {
  desktop: true, // set to 'false' to disable sounds
  tablet: true, // set to 'false' to disable sounds
  mobile: true, // set to 'false' to disable sounds

const DESKTOP_BREAKPOINT = 1024;
const TABLET_BREAKPOINT = 768;

/* ---------------------------------------------------------
   DEVICE DETECTION
--------------------------------------------------------- */

const isIpad = navigator.userAgent.includes("iPad") ||
  (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);

let deviceType = "mobile";
if (isIpad) {
  deviceType = "tablet";
} else if (window.innerWidth >= DESKTOP_BREAKPOINT) {
  deviceType = "desktop";
} else if (window.innerWidth >= TABLET_BREAKPOINT) {
  deviceType = "tablet";
}

/* ---------------------------------------------------------
   RUN BLOCKER IF SOUNDS SHOULD BE DISABLED
--------------------------------------------------------- */

if (!ALLOWED_DEVICES[deviceType]) {

  const muteAll = () => {
    document.querySelectorAll("audio, video").forEach(el => {
      el.muted = true;
      el.volume = 0;
      el.pause?.();
    });
  };

  /* HTMLMediaElement override */
  (function () {
    HTMLMediaElement.prototype.play = function () {
      this.muted = true;
      this.volume = 0;
      this.pause?.();
      return Promise.resolve();
    };
  })();

  /* new Audio() override */
  (function () {
    const OriginalAudio = window.Audio;
    window.Audio = function (...args) {
      const audio = new OriginalAudio(...args);
      audio.muted = true;
      audio.volume = 0;
      audio.pause?.();
      return audio;
    };
  })();

  /* WebAudio override */
  (function () {
    const Original = window.AudioContext || window.webkitAudioContext;
    if (!Original) return;

    function MutedContext(...args) {
      const ctx = new Original(...args);
      ctx.resume = () => Promise.resolve();

      const origSource = ctx.createBufferSource.bind(ctx);
      ctx.createBufferSource = function () {
        const source = origSource();
        const origStart = source.start.bind(source);
        source.start = function (...sArgs) {
          try {
            const gain = ctx.createGain();
            gain.gain.value = 0;
            source.connect(gain);
            gain.connect(ctx.destination);
          } catch (e) {}
          return origStart(...sArgs);
        };
        return source;
      };
      return ctx;
    }

    window.AudioContext = MutedContext;
    window.webkitAudioContext = MutedContext;
  })();

  /* Execute muting */
  muteAll();
  [50, 200, 600, 1500, 4000].forEach(t => setTimeout(muteAll, t));

  /* Catch dynamically added audio elements */
  new MutationObserver(muteAll).observe(document.documentElement, {
    childList: true,
    subtree: true
  });

  /* iOS visibility fix */
  document.addEventListener("visibilitychange", () => {
    if (document.visibilityState === "visible") muteAll();
  });
}

Got it, thanks!

Our devs are still investigating an issue with the delayed sounds on mobile. I’ll share an update here as soon as I have any news :slightly_smiling_face:

Thanks, @Max.

Update: The Open Window sound issue on Firefox has been fixed (100% certainty).

Root Cause: Our sound drivers (installed via Intel updater) were corrupted and, for some reason, collided only with Firefox.

Solution: We deleted/re-installed the sound drivers using Windows’ default update process.

Looking forward to Elfsight’s Apple devices sound fix issue :slight_smile:

Cheerio!

Quick update from the dev team: we’ve found a possible solution, but we need to test it thoroughly to ensure it’s stable.

I’ll keep you posted and share any new information as soon as I have it :slightly_smiling_face:

Hi there,

Thank you for waiting!

Great news! We’ve fixed the issue with Sound notifications - AI Chatbot: Issue with Sound notifications fixed

Thank you, @Max!

Your customer support team reached out to me offline to announce the good news as well. I can confirm the sound issue on both mobile and tablet devices is now fixed.

You guys rock. Thank you!