3

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!

MrWhetherMan
  • 1,184
  • 2
  • 11
  • 27

1 Answers1

1

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}}
               }]
           }
       }]
   }]
}
Dmitry
  • 2,057
  • 1
  • 18
  • 34
  • What does payload mean? – Bidstrup Jun 26 '16 at 22:14
  • I was wondering if you could explain this more. I just got dropped a Facebook messaging app that was started by another person; this appears to solve what I am looking for but it's unlcear how to implement it. Any more info. thx -jt – timpone Aug 18 '16 at 20:59
  • Here is a more in-depth explanation: http://stackoverflow.com/questions/37277397/facebook-messenger-chatbot-how-do-i-collect-the-users-geo-location-that-they-sen – MrWhetherMan Aug 22 '16 at 03:55