Custom Trigger Giving Cannot send data until the w...
# 🤝help
b
Hi, We are testing triggers. We did have success in "Conversation Started" trigger to initiate the message. We also would like to trigger bot flow when user clicks on the button with following function. I have published the bot. const triggerBot = () => { window.botpressWebChat.sendPayload({ type: 'trigger', payload: {} }); }; In browser we are getting the error message as attached. Any suggestion on how to fix this?

https://cdn.discordapp.com/attachments/1136907535966814249/1136907536285577256/Screen_Shot_2023-08-04_at_3.21.40_PM.png

https://cdn.discordapp.com/attachments/1136907535966814249/1136907536554008586/Screen_Shot_2023-08-04_at_3.22.48_PM.png

h
Are you checking if the webchat is ready?
Copy code
js
window.addEventListener("load", function () {
      window.botpressWebChat.onEvent(
        function (event) {
          if (event.type === 'LIFECYCLE.LOADED') {
            window.botpressWebChat.sendPayload({ type: 'trigger', payload: {} });
          }
        },
        ['LIFECYCLE.LOADED']
      )
});
If there is no payload consider
window.botpressWebChat.sendEvent({ type: "trigger" });
b
Thank you! It worked with just using sendEvent. Thanks Deyan
4 Views