tjtanjin / react-chatbotify

A modern React library for creating flexible and extensible chatbots.
https://react-chatbotify.com
MIT License
203 stars 111 forks source link

[Bug] rcb-toggle-voice event does not work #121

Closed zikpefu closed 1 month ago

zikpefu commented 1 month ago

Bug Description I'm trying to test the rcb-toggle-voice event and I am not getting any of the console logs to trigger.

Steps To Reproduce

This is the code that I used to test the voice listener:

const MyChatBot = () => {

  const settings = {
    general: {
      embedded: true
    },
    chatHistory: {
      storageKey: "test"
    },
    event: {
      // opt-in to rcb user submit text event
      rcbToggleVoice: true,
    },
    voice: { disabled: false }
  };

  React.useEffect(() => {
    const test = (event) => {
      console.log('test worked');
    };

    window.addEventListener("rcb-toggle-voice", test);
    return () => {
      window.removeEventListener("rcb-toggle-voice", test);
    };
  }, []);

  // example flow
  const flow = {
    start: {
      message: "Hello there! Try saying hello to me!",
      path: "end"
    },
    end: {
      message: "Keep trying!",
      path: "start"
    }
  };

  return (
    <ChatBot settings={settings} flow={flow} />
  );
};

render(<MyChatBot />);

Steps to reproduce the bug behavior:

  1. Go to the Chatbotify interactive editor
  2. Paste the code above
  3. Open the browser console
  4. Record your voice and observe no event triggers

Expected behavior Log of "test worked" will show

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

tjtanjin commented 1 month ago

Hey @zikpefu, thank you for raising this up. Embarrassingly, this bug was caused by a typo where instead of rcb-toggle-voice, I wrote rcb-voice-toggle 😅

The good news is we know the source of the bug and it is trivial to fix: https://github.com/tjtanjin/react-chatbotify/blob/main/src/constants/RcbEvent.ts

The not-so-good news is I'm overseas right now and can only tend to this when I get back, which is the middle of next week 🥹

If you're in urgent need for this, you can clone the repository, apply the fix yourself and run npm pack to build a fixed version. Otherwise, you can wait for the patch next week 😊

tjtanjin commented 1 month ago

Hey @zikpefu, this is now resolved in v2.0.0-beta.13 😊

zikpefu commented 1 month ago

Thank you!

On Wed, Sep 25, 2024, 1:54 PM Tan Jin @.***> wrote:

Closed #121 https://github.com/tjtanjin/react-chatbotify/issues/121 as completed.

— Reply to this email directly, view it on GitHub https://github.com/tjtanjin/react-chatbotify/issues/121#event-14403362804, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIFCLOZWJGG55FXZPJTP243ZYL2DRAVCNFSM6AAAAABOS2ELNGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGQYDGMZWGI4DANA . You are receiving this because you were mentioned.Message ID: @.***>