I am creating a chatbot using messenger in python but I don’t know how to get the geolocation from the facebook user (latitude, longitude). I saw that I had to use graph API but the field status does not seem to work. Would you have a query example? Thanks in advance!
Question posted in Facebook API
The official documentation for the Facebook APIs can be found here.
The official documentation for the Facebook APIs can be found here.
2
Answers
You can use the location quick reply:
https://developers.facebook.com/docs/messenger-platform/send-messages/quick-replies#location
[Update with the current status about how to solve this]
Location Quick reply have been deprecated and removed since end of june 2019.
They’re supposed to announce a new way of achieving the same behavior but nothing so far 6 months later.
Facebook recommends asking for user’s address in a textual form.
This means that if you use an API consumming GPS coordinates you now must use an address to GPS conversion service.
You could think that using a webview with a “get geolocation” button would do the trick but this feature is blocked on all desktop browsers. If the iframe content isn’t on the same domain you cannot get geolocation data. Still it works on mobile (as it’s not just a simple iframe but a full webview).
Basically, at the time of this writting, you have no much way to achieve the same as the “get position” quick reply behavior.
The only solution is to ask the user’s address in a textual way and convert it to GPS coordinates (if you need them).