https://discord.gg/botpress logo
React App not receiving "on" Events
# 🤝help
I need a way to send and receive custom events and
window.botpress
is undefined
so this video

https://youtu.be/4je2_HMCXU0?si=ZqBR7lb9H5lRvxqT▾

and the share => Configure => React instructions are outdatedm since getClient is no longer present in
@botpress/webchat
https://cdn.discordapp.com/attachments/1382335122748997662/1382338536665124954/Screenshot_2025-06-11_at_14.38.16.png?ex=684aca95&is=68497915&hm=4912218865e1153146353162c2062e526727055bece030d846376c7c50ef7f57&
is there devs who could assist? I am at the hackathon rn, need it working asap 😛
to demo AI assistant to my company
so none of the events console logs are being called. "on" is defined when it is being called
@eager-forest-85623 could you take a look pls?
p
Are you using the correct version of React as mentioned at the beginning of the video?
g
do you mean the @botchat/webchat version? I used the latest one. React version is irrelevant, the issue is on the botpress lib side from what I see React: 18.2.0 https://cdn.discordapp.com/attachments/1382335122748997662/1382355807303241829/Screenshot_2025-06-11_at_15.47.24.png?ex=684adaab&is=6849892b&hm=c2f1a2ccbde7cfab206531bc8ce69ca4f0b3c43125ce66709c6e9703fbc00d69&
I wrapped registartion in useEffect just in case, fyi, still they are not triggered
Copy code
React.useEffect(() => {
    console.log("Webchat onMessage2", onMessage);

    onMessage("message", (message) => {
      console.log("Webchat opened", message);
    });
    onMessage("messageSent", (message) => {
      console.log("Webchat opened", message);
    });
    onMessage("webchatVisibility", (message) => {
      console.log("webchatVisibility", message);
    });
  }, [onMessage]);
p
Ben has faced similar issues when the versions were not exactly as stated in the video. Can you validate they are the same?
g
He said "we want the React 18 to be able to work with bot press React components"
The bot itself works fine, just on() function is not triggered
@helpful-butcher-6630 @plain-lifeguard-16679 hey guys, saw you behind 3.0.0 botpress/webchat release there is an issue that readme is outdated in the latest version there are no getClient() function I found useWebchat() hook but it's on() function is not being called I am reverting to older version in the meatime fyi
m
I have the same issue, how do I revert to an older version? @gorgeous-pencil-71524
g
Older version doesn't support receiving messages neither, I couldn't make it work But you can just do nom install and specify older version of the dependancy
m
is this still broken?
@prehistoric-airplane-85682
b
Can someone please update the docs on this
m
@plain-lifeguard-16679 @prehistoric-airplane-85682 any info?
e
Hi everyone, here to provide some clarity on this—the issue stems from the
useWebchat
hook and the
<Webchat>
component creating two seperate instances of the Webchat client, which weren't communicating properly. As per our front-end team, the
useWebchat
hook wasn't designed to be used with the batteries-included
<Webchat>
component—I've [updated the docs](https://botpress.com/docs/webchat/react-library/hooks/use-webchat-client) accordingly.. If you build Webchat manually from the rest of the component library, the
on
functions should work just fine.
3 Views