Open different flows of the bot with custom button...
# 🤝help
h
hello everyone, I have a react app with a menu and I want each menu button to open the bot in a different conversation flow. it's possible?
a
@bright-magazine-792 correct me if i'm wrong, but I think this would be easier done using multiple bots atm.
h
Thanks for answer. Actually, I'm trying to do that, sending a custom event for each bot from my react menu and handling it in each bot's own before_incoming_middleware hook. but I get this message in the browser console every time I click the button: "Cannot send data until the webchat is ready botpress"
maybe I'm not sending the event correctly or setting the condition correctly in the hook, because at least it gives me the warning
This is the handler that I pass to my button of my menu:
Copy code
const handler = () => {
    // @ts-ignore
    window.botpressWebChat.sendEvent({
      type: 'custom-event',
      channel: 'web',
    });
  };
And this is my before_incoming_middleware hook:
Copy code
console.log('HELLOOOOO')
    if (event && event.type === 'custom-event') {
      botpressWebChat.webchatOpen ? 'hide' : 'show'
      console.log('bye')
    }
@acceptable-gold-88171 help please 😢
a
window.addEventListener("message", function(event) { if (event.data.type === "LIFECYCLE.LOADED") { // do what you want here } })
Try that
but I don't think we support custom-events right now