Get users current location from Facebook messenger Chatbot api

12,751

Solution 1

The only way to get the location is when the user sends it: https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies

More information: How to send location from Facebook messenger platform?

Solution 2

Pretty sure there is no automatic geo-location support in the FB messenger API but:

  1. On mobile you can have them submit their location using the location icon, this works pretty well (gives you their lat and long)
  2. On both desktop and mobile you can ask them to input their location, then use that information to get their coordinates
Share:
12,751
Charan Goud
Author by

Charan Goud

Updated on June 04, 2022

Comments

  • Charan Goud
    Charan Goud almost 2 years

    I am working on fb messenger bot and I want to access user's current location without them sending it as an attachment.I tried to get user's current location from fb graph API but it seems like to return the user's location from their profile. I need something like real time geo coordinates.

    Thanks in Advance!

    • Lejdi Prifti
      Lejdi Prifti almost 8 years
      You can't. The user has to send it
  • Metablocks Corp
    Metablocks Corp almost 8 years
    Unfortunately you don't have access to Javascript in the FB Bot API
  • andyrandy
    andyrandy almost 8 years
    then it´s not possible at all in an automatic way (without user interaction)
  • Metablocks Corp
    Metablocks Corp almost 8 years
    Correct. There is no Javascript access and you can't get users IP address and the API won't give you the location.
  • Jarrod McGuire
    Jarrod McGuire almost 6 years
    So does mean everytime you want a location you need to ask for it via the quick reply, or does a permission get set that allows it for a period of time?