Getting location

Can someone tell me the best solution on getting user’s location from website running in

Would be best doing it from website asking for permission on getting location.

We have done this by getting the location by react-geolocator but are stuck on how to get the information to the running action server

I haven’t done it myself by first thoughts are maybe the google location/maps API or some javascript package you can run in your chat widget/etc and get the location details and then send to your action server doing lookups based on it, etc.

I’m not the best at it but that is how I would probably approach it.

Have you done this finally? Or anyone else maybe?

I found an example at tutorial-rasa-google-assistant/ at master · RasaHQ/tutorial-rasa-google-assistant · GitHub but it seems like this would fetch the location of the Rasa server, not the client, since the action code would run on the server. Has anyone found a good way to get the client’s location when using the embedded web client?

1 Like

hey @sterpapi, I had done in my chatbot widget you can check the code here:

1 Like

@JiteshGaikwad thanks! So this code could just be run as the first thing when the user launches the chatbot?

I’m assuming that if I wanted to use Google’s geolocation API I could just swap that in for navigator.geolocation.getCurrentPosition.

Yes, but you need to send a custom payload from your Rasa Bot which will prompt user for the location access.

Sample Code:

I hope this helps :blush: