I am trying to raise a browser event from chatbot ...
# 💻developers
h
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
Hey, do your app support Browser load?
P
Website load?
h
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
Do you want something like this
Did I understand right?
h
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