How can I fetch the user's GPS coordinates automatically from my RASA X Chatbot?

I am adding a feature in my RASA X Chatbot and the feature needs the user’s location. So, how can I fetch the user’s GPS coordinates automatically?

Please help.

Hi @gadia-aayush. There are a few options you can use - you could try using additional libraries like geopy or ip2geotools. Alternatively you could use Google Geolocation API.

Overall, that would be a custom action (or part of custom action) where you get the user’s location, set coordinates as slots and use them in some subsequent actions.

@Juste, Thanks for your reply !
Actually, I am using MapmyIndia API to find the address from the GPS coordinates, the problem is how shall I get the user’s GPS coordinates?

How shall I enable such feature in my RASA so that my RASA Bot can fetch user’s location either by providing me the IP Address of the User or by initiating an action which fetch the user’s location just like HTML Geolocation API which prompts a notification.

Looking forward to your reply.

@gadia-aayush So if you can get user’s address, you should be able to get the coordinates very easily with externally available APIs (again, Google is one of the options). Overall, to get the coordinates, you have to use some kind of API or python library.

The way this can then by handled by Rasa is that the part of fetching the coordinates if defined as a custom action (this is where you tell your assistant to run the custom actions to fetch the details). Then you have to decide at what point you need your assistant to know the coordinates and design the example conversations based on that. If you need it from the very beginning of the conversation, the custom action should be included at the beginning of your stories, if it has to come after a certain turn in a conversation it should be included at a different specific point.

hi @Juste, I’m using google geolocation API. However, it’s getting the server’s location instead of user’s location. Do you know how to fix it?? Thanks!

Hey Ayush! I am also using mapmyindia api, how did you resolve this problem of getting user’s gps coordinates?

Hi @Priyambada89 !!! Well, our team is working on integrating the chatbot in an Android App and then fetching the GPS co-ordinates of the user while, in the case of integrating the chatbot on a website and fetching the user co-ordinates I had found 2 useful links shared below-

  1. freeCodeCamp Challenge Guide: Get Geolocation Data to Find A User's GPS Coordinates - Guide - The freeCodeCamp Forum

  2. chatbot - Device location in dialogflow (api.ai) webhook request - Stack Overflow

Basically, in case of a chatbot integrated in a website, what you have to do is take the advantage of the browser’s capability where the browser requests the user for allowing the user to share their location (example shown below) and using that you can get the GPS coordinates otherwise if you simply use any modules then they will fetch the location where the website is hosted not of the user.

I hope the shared resources are useful to you.
Thanks

Hey @gadia-aayush I am working in a similar project where I need to integrate the chatbot with an android app and then fetch user’s GPS coordinates. How did you handle the following task mentioned by you in your previous comments on this post-

How shall I enable such feature in my RASA so that my RASA Bot can fetch user’s location either by providing me the IP Address of the User or by initiating an action which fetch the user’s location just like HTML Geolocation API which prompts a notification.

I am also using mapmyindia API

Is it possible to connect this handheld GPS to RASA X Chatbot?

Please check the link, hope you will be able to solve the requirement Getting location and this one too Chatbot-Widget/script.js at d7fe30e126cb9ba4093fbf937deface283c7bdaa · JiteshGaikwad/Chatbot-Widget · GitHub

I have no idea how to help you with this problem. Personally, I don’t use this GPS option. You can try the Which GPS Navigators platform, it’s a pretty good platform, and most likely, it has this option. I do not know if I can help you so far. I have not met a platform that will have such an option. The main thing is not to give up. I am sure that you will find a venue with such features. When I chose my platform for GPS, I was tracking other search parameters, such as identifying police patrols, etc. I hope I was able to help someone with my comment