How to send a javascript function call using custom actions?

I have a simple javascript function defined in my HTML webpage that collects the user latitude and longitude.

How do I define a custom action such that it will trigger this JS function and collect the LAT-LONG coordinates that was generated in the function?

What is the architecture of your rasa setup? Does the front-end directly interact with rasa server or there is a middle ware which receives the requests and forwards to rasa server?

I’m making use of Rasa Webchat for frontend. It has the socketUrl to my rasa core.