Location Button (Messenger) - Making sending your location easy :)

(Kellsey Shaw) #1

NOTE: As of October 29, 2019, Facebook has removed Location Quick Replies from their platform. The technique in the announcement below will no longer work.

Now that we support receiving location values, you no doubt will want to know how to give the user a button to send that location to you.

You can use our Wehbook service to create a custom request to Messenger to provide the user with a message and the location button and here’s how.

Your URL should be:

https://graph.facebook.com/v2.6/me/messages?access_token=InsertYourPageToken

You’ll just need to pop your page token on the end there where indicated.

The Method should be POST.

The Content Type should be Raw Body.

You then need to paste the following in the body:

{
  "recipient":{
    "id":"{{bot_new_message.user_id}}"
  },
  "message":{
    "text":"Please share your location:",
    "quick_replies":[
      {
        "content_type":"location",
      }
    ]
  }}

You will need to add a Header to the request and enter the following:

You should end up with something that looks like this :slight_smile:

If you have renamed your trigger, you will need to update the output {{bot_new_message.user_id}} with the userid output from your bot trigger.

If you want to change the message, you need to edit the content between the quotes on the right side of "text":"Please share your location:"

Known Issues: Messenger does not support sending location in the Web version and the support for the Windows 10 app seems to be hit and miss at best.

3 Likes
How do I know which Card's shortcut is clicked
Help with custom request
(Art Arov) #2

Cool. How to make a button like this in a Telegram

1 Like
(Kellsey Shaw) #3

Hi Art,

Telegram does have an option to set a keyboard button as a location request. You could take a look at their documentation to see if it’s something that you can implement :thumbsup:

(Chimere) #4

So i have this this.

reply_markup=ReplyKeyboardMarkup(
    		keyboard=[
    		[keyoardButton(text='Whats your location?')], 
    		request_location = True, one_time_keyboard=True])

Where and how do i put it in the Flowxo Workflows for Data Outputs or Filters to get results?
I have to deliver a Telegram location button ASAP.

(Kellsey Shaw) #5

Hi there,

That code snippet is for use with a particular library/sdk.

You’ll need to use plain JSON to send your request in the raw body of a webhook request in Flow XO

(Kellsey Shaw) #6

We now have a working example that you can look at

1 Like
(Oliver Schmidt) #8

Hello!

I tried it with your guidline but it does not work…

I want to trigger the flow with a simple user message…for example “location”.
Then I use the Wehbook service, as described, and finally I want to save the user’s location to my google sheet.
Actually, I get an error in my sheet: {“error”:{“message”:"(#100) Parameter recipient[id]: Invalid id: “{{bot_new_message.user_id}}”",“type”:“OAuthException”,“code”:100,“fbtrace_id”:“FLIykDGhntv”}}

What are my mistakes?

(John Jackson) #9

Could you try deleting {{bot_ new_message.user_id}} from the body section, then in the same place, type {{ and then select the User ID from the trigger outputs?

The problem seems to be that the user ID is not being inserted, it’s going across as {{bot_ new_message.user_id}} which must not be correct.

(Oliver Schmidt) #10

Thanks John!

I managed to get the button for sharing location and I can send the location to the bot. But it does not work with my excel…Therefore, I have also another flow, which should trigger with a new file (but it doesnt trigger at all)

My objective is having a bot, who asks the user two questions and collect the location of the user, and evertyhing will be visible in one google sheet with the answers and the coordinates in the same row.

Is it possible? How the flow(s) look like?

(Rob) #12

Hi Kellsey,

Thank you for your advice on setting up the Location Button. This worked perfectly. I’m looking at a delivery application where the user may not be where the delivery needs to go. In this instance I would like to produce a map but sourced from a user text input address. Can you do this from within Facebook ?
I’m also interested to know if we can integrate Facebooks new live location feature into FlowXO ?

Many Thanks

(Anish Duggal) #13

Hello @kellseyshaw , @perisicrob

Could I also get the same advice mentioned above cannot seem to get location working. I keep getting the below error.

{
“error”: {
“message”: “Unsupported post request. Object with ID ‘me’ does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api”,
“type”: “GraphMethodException”,
“code”: 100,
“fbtrace_id”: “BdW2r0JFzLK”
}
}

Thanks

(Anish Duggal) #14

All is good. I got it to work so far.

(Khashayar) #15

We definitely need that ‘Ask for Location’ method. Without it, the location button is pretty much useless.

1 Like
(Kārlis Janisels) #16

Hi, I tried the code but I got stuck. Nothing is happening, bot does not give any response. Here is code:
{
“recipient”:{
“id”:"{{set_location.user_id}}"
},
“message”:{
“text”:“Please share your location:”,
“quick_replies”:[
{
“content_type”:“location”,
}
]
}
}

What am I missing?

(Sarah Palombo) #17

Hi @Karlis_Janisels :slight_smile:

Are you using the HTTP request as Kellsey explains above or an easier way is to use the Make a custom Request?

If you click Options in your Flow, you can go to Interactions what does the details show there? Is there an error show for this action.

A common issue is not setting the content-type: application/Json

If you’re struggling reach out to support@flowxo.com and share your flow I’m sure we can help get this working :+1:

Sarah

(Steven Booth) #18

@sarahpalombo @johnjackson Hello! Small change I’d suggest to the original example, below.

Hope this is helpful, keep up the great work team :smile:

Also just to note that with Flow XO’s ‘custom request’ bot action, you can use just the following code too:

 {
    "text":"Please share your location:",
    "quick_replies":[
      {
        "content_type":"location"
      }
    ]
  }

And this is a great tool for checking your JSON is fully validated, with liniting on each line - https://jsonformatter.curiousconcept.com/

1 Like
Location Quick Reply error message
(Khashayar) #19

Hey,

I might be missing something but what’s the point of asking for co-ordinates when there’s no way to record them as attribute?

If there is a way to do that, could someone point me towards the right direction?

Since “ask for location” isn’t next in line, is there a way to implement this for now?

(Karen Barker) #20

Hey Khashayar,

Currently receiving location is done as a New File trigger. When the user sends their location, the latitude and longitude are received and stored in the metadata of the flow trigger. You could then set attributes for each of these from the metadata and then you can use them globally across flows.

1 Like
(Anish Duggal) #22

After receiving the long and lat coordinates. How would one go about resolving to the city level?

(Khashayar) #23

I’m using the Google Maps API for that

1 Like