Requesting Location in Telegram

(Kellsey Shaw) #1

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

Your URL should be:[Token]/sendMessage

You’ll just need to pop your bot token in the URL where indicated.

The Method should be POST.

The Content Type should be Raw Body.

You then need to paste the following in the body:

	"chat_id": "{{bot_new_message.channel_id}}",
	"text": "Hello World",
	"reply_markup": {
		"keyboard": [
				"text": "Send Location",
				"request_location": true

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

If you have renamed your trigger, you will need to update the output {{bot_new_message.channel_id}} with the channelid 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”:“Hello World”

Known Issues: Telegram does not support sending location in the Desktop App version

Location Button (Messenger) - Making sending your location easy :)
(Art Arov) #2

Thank you. Working. How “Instant View” at 3.14?

(Chimere) #3

Still getting a 400 with my location requests on Telegram.

Status Code

{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

  "ok": false,
  "error_code": 400,
  "description": "Bad Request: chat not found"

My inputs seems right

Webhook URL{SomeNumbers}:{RandomText}/sendMessage

HTTP Method

Content Type
Raw Body

	"chat_id": "{MyChatID-SomeRandomNumbersToo}",
	"text": "Can i get your location please. Click on the button below",
	"reply_markup": {
		"keyboard": [
				"text": "Send Location",
				"request_location": true

Content-Type: application/json
(Kellsey Shaw) #4

Hi Art,

Sorry, I’m not sure what you are referring to with Instant View?

(Kellsey Shaw) #5

Hi Chimere,

The chat ID doesn’t seem to be valid. The ID should be the channel ID that has been captured by the bot when the user has spoken to it.

(Hammmie21) #6

I seem to be having some issues with the response.

So according to the steps, the bot sends a text message and a button to ask for the user’s current location.

Issue #1: Before I can even press the button, the next message is already loaded. Ive added a filter to the next message, so it will only run if the responsecode is 200. With no succes. The next message is loaded directly.

Issue #2: This is the response I get:

Status Code
{“ok”:true,“result”:{“message_id”:112,“from”:{“id”:325077223,“first_name”:“SOSI”,“username”:“Berger_bot”},“chat”:{“id”:224870002,“first_name”:“Hamza”,“last_name”:“Jap-Tjong”,“type”:“private”},“date”:1480509387,“text”:“Om de dichtsbijzijnde hersteller te vinden, heb ik uw locatie nodig. Druk op de knop om deze eenmalig toe te zenden”}}
“ok”: true,
“result”: {
“message_id”: 112,
“from”: {
“id”: 325077223,
“first_name”: “SOSI”,
“username”: “Berger_bot”
“chat”: {
“id”: 224870002,
“first_name”: “Hamza”,
“last_name”: “Jap-Tjong”,
“type”: “private”
“date”: 1480509387,
“text”: “Om de dichtsbijzijnde hersteller te vinden, heb ik uw locatie nodig. Druk op de knop om deze eenmalig toe te zenden”

I don’t see any long/lat data

Did I do something wrong?


(Kellsey Shaw) #7

Hi Hamza,

The response to the webhook is only a server response and not a user message (clicking the button).

The user message will be a webhook sent to us from Telegram that needs to be captured using the Bot > New File trigger in a separate flow. Location data is handled using the New File trigger only.

Hopefully, this clears things up for you :slight_smile:

(Chimere) #8

Thanks Kellsey,
I got it working but now the button only stays for a brief second before disappearing not giving the user enough time to press it and get the location information prompt. It generally just carries on to the next flow without getting input from the user. Please help.


(Kellsey Shaw) #9

Hi Chimere,

The flow does not wait for the user to respond as it’s not a question to the user. You would need to set up another flow using the Bot > New File trigger to receive the location. :slight_smile:

(Chimere) #10

Hi Kellsey,
Still no bite, the application behaves the same way. I named my new Bot the same name as the webhook but they don’t seem to find each other theres some intuition missing somewhere and you guys have a lot of work to do. My client is vey angry and am considering using a programming library or learning the telegram api myself. My final word, help or forget it.

(Kellsey Shaw) #11

Hi Chimere,

You can install our Example, which is tested and working. You’ll need to add your bot token to the URL and you’ll need to make sure that you have a second flow using the Bot > New File trigger, which will receive the location once it’s sent

(Chimere) #12

Hey Kellsey,
I tried the example, it wasn’t so different from my implementation. It did trigger as expected in the logs and i was able to use the shortcut button. However, what i’d like it to do is make the flow trigger on the second question. My first question which is also an introduction has a shortcut button I was also able to make the two buttons appear on the first question but this isn’t required.

Thank you for everything. Am still reading your docs and follow your videos but you guys still need a clear and concise tutorial beyond the articles on medium.

(Kellsey Shaw) #13

Hi Chimere,

If you wanted two questions followed by the location button, you would just need to add two question tasks to your flow and then send the location button as per the below.

The idea of the videos and medium tutorials is to give users a good starting point. They aren’t meant to be a complete solution because with bots being so highly customisable, no two bots will be the same.

We welcome suggestions for content for the video’s etc, though, so if there a feature you’d like covered, feel free to let us know your suggestion and we’ll see if it’s something that we can cover in one of our web casts :thumbsup:

(Art Arov) #14

Tell me please. Such Webhook working?

Make Custom Requests
(Kellsey Shaw) #15

Hi Art,

Are you seeing an error in your logs?

(Art Arov) #16

No errors. Do not complete the work inline keyboard. Bot - Catch-all does not catch the button press.

(Art Arov) #17

As you can answerCallbackQuery?

(Kellsey Shaw) #18

Hi Art,

In Telegrams doc’s it states:

Unlike with custom reply keyboards, pressing buttons on inline keyboards doesn't result in messages sent to the chat. Instead, inline keyboards support buttons that work behind the scenes: callback buttons, URL buttons and switch to inline buttons.

These types of buttons don’t work with our flows sorry.

(Levon ) #19

Hello Kellsey,

can you pls explain the meaning \ use case of having Shortcuts in a Send Message, if you say the flow does not wait for the user to respond?


(Amir) #20

Hi there. So how can I use this location after the user has pressed “Share location” and save it in Google Sheets for instance. Thanks.