Web bot - get location

(Peteredel) #1

Any suggestion or sample on how to get location from a web bot?

(Karen Barker) #2

Hi there, :wave:

A quick and easy way to get started on using locations would be to install our “Find Location” template.

Log into Flow XO -> Click the Flows tab -> Click Add New Flow and you’ll see all the templates here. :+1:

(Peteredel) #3

Karen,
The question is how to GET the location.
The example starts from moment the user has send its location.

(Karen Barker) #4

Ah I see…

Unfortunately it isn’t possible for the bot to get the users location itself. The user must send it to the bot for privacy reasons. Your first flow is where you request the user to send their location and the 2nd flow is waiting to receive the users location (template) and then continue with your flow. If you filter the 2nd flow on the file type then this will ensure that only location file types trigger this flow.

(Augusto Vera) #5

Karen I am lookin exactly what you describe about capturing the location the user sends within the first flow, and then triggering it to the second location template flow, then get back to the beggining of the first flow. I have the location flow working, and it is attached to the same telegram bot as the first flow that asks the user to send his location. But whenever I ask the location on a question in the first flow, I send my location but the location template flow appears not to be listening for the location file unless I detach the first flow and leave the location template flow alone.

(Daniel Beckett) #6

@Augusto_Vera

It sounds like you’re getting stuck inside ‘Ask a Question’ - if you try and send your location when answering a question it treats it as an answer rather than triggering the find location flow. The user needs to send their location whilst not answering a question.

1 Like
(Augusto Vera) #7

Ok, got it, nevertheless how do you guide the chatbot user to a point where you ask him or her the location without a question or prompt to do so and wait for his or her location answer?, A card or an options menu will require a question always. Kinda conundrum.

(Daniel Beckett) #8

Hi Augusto,

You can use a custom request to send the user a location request button.

For Telegram the following request should work:
{
“chat_id”: “{{bot_new_message.channel_id}}”,
“text”: “Hello World”,
“reply_markup”: {
“keyboard”: [
[{
“text”: “Send Location”,
“request_location”: true
}]
]
}
}

Metadata
Method SendMessage

On Facebook Messenger it would be a custom request using the following:
{
“text”:“Please share your location:”,
“quick_replies”:[
{
“content_type”:“location”
}
]
}

(Augusto Vera) #9

Thanks Daniel, I inserted a custom request after calling a label when the user selects “ENCUENTRA UN SEVEN”, it displays then a brief moment the SEND LOCATION button, only to dissapear and get back to the main menu. ¿how do I pause the flow in order to wait for the user to send their location? I tried with a question, but as you pointed out the answar gets trapped in the question so the location is not sent to the listening subflow in charge of finding the nearest locations. Maybe I can share the flows. The chatbot is located here:
https://m.me/718180008384257

1 Like
(Daniel Beckett) #10

You’ll need to stop the flow once the location button has been sent since the user needs to trigger the location flow. You can use a filter on the action to send the location button with the option enabled for “Also stop rest of flow if conditions are met”

If you need to send the user back to a specific point in your flow after that then you could make use of a combination of Attributes and Flow Labels. For example, set an attribute on your location flow for something like ‘GotLocation = True’ and then at the start of your main flow have a filtered GoTo Label Action for ‘GotLocation = True’

(Andrew Catchpole) #11

@Augusto_Vera
I found your post in the community and tried your flow.
Is you location routine still working? Did the flow fail?
I don’t think Facebook is sending the send location button. I tried manually sending location and your flow continued as expected.
Regards Andrew