I was wondering how I could get a user's location from a Facebook messenger chatbot. What I want to accomplish is the following: the chatbot will say something like "Please send me your location", and then the user would tap the "Share Location" on the Facebook messenger app. I have figured out how to get a textual message that the user sends, but not the location. Thanks in advance!
Location can be obtained as well as text. More precisely, as the photo.
You need take message.attachments.payload.coordinates
. Also you can check message.attachments.type
.
example:
{
"object": "page",
"entry": [{
"id": "1719442148306048",
"time": 1466780344978,
"messaging": [{
"sender": {"id": "123456789"},
"recipient": {"id": "987654321"},
"timestamp": 1466780344847,
"message": {
"mid": "mid.12345698875:c80066d69b6cee1779",
"seq": 65,
"attachments": [{
"title": "Dmitry's Location",
"url": "Link to bing.com through facebook redirect"
"type": "location",
"payload": {"coordinates": {"lat": 55, "long": 37}}
}]
}
}]
}]
}