https://discord.gg/botpress logo
#💻developers
Title
# 💻developers
h

helpful-king-89909

10/20/2023, 7:34 PM
I am trying to raise a browser event from chatbot to parent UI application. I am using following code in a execute code action in botpress var event = new CustomEvent('OnFromBot', { detail: 'Example of an event' }) // Dispatch/Trigger/Fire the event window.document.dispatchEvent(event) but this event is not raise and chatbot says error has occured. What is right way of raising events from chatbot to parent document object. I have already added event listener parent UI document object.
I realized that the javascript runs on botpress server not my browser. is there a way that botpress sends some hidden event or metadata back to my chatbot UI that I can catch and interpret on my browser side?
n

narrow-agent-91470

10/20/2023, 10:56 PM
Hey, do your app support Browser load?
P
Website load?
h

helpful-king-89909

10/21/2023, 3:22 AM
not sure what you mean? can you explain more please?
I found a way to achieve what I was trying to do. Hopefully this helps others. I can use custom trigger to send a message back to my javascript client side. there i can capture it type TRIGGER, then respond in my local javascript as needed. This worked for me
n

narrow-agent-91470

10/23/2023, 10:29 PM
Do you want something like this
Did I understand right?
h

helpful-king-89909

11/14/2023, 6:33 PM
sorry for delayed response. this is interesting...I resolved my issue using "send custom event". I can catch these on browser side and react to it