Proxying
Connecting bots using the proxying method.
Proxying
The Telegram Bot API has two operating schemes:
webhook — when a user writes to the bot, the Telegram server automatically sends an HTTPS request to your bot's address
getUpdates (long polling) — your bot independently requests updates from the Telegram server
To make connecting to the platform simple and fast, we developed a special proxying server that sits between the Telegram server and your bot.
If the bot works via Webhook
You can connect the bot manually (without entering the token) — to do this, when adding the bot, select the corresponding option and follow the instructions. You will need to replace your webhook with ours.
If the bot works via getUpdate
You can connect a bot that works via the getUpdate method in two ways: via the API (see the section "Connecting a bot via the API") or by replacing the api.telegram.org address.
Bots of this type independently request updates from Telegram using HTTPS requests via the getUpdate method. To connect the bot to analytics, you need to change the api.telegram.org address to the address provided by the system when connecting.
After changing the address, our platform will proxy all requests to the api.telegram.org address and collect statistics for you. This address can be used not only for getUpdate requests but also for all other types of requests (sending messages, files, etc.) — all requests are proxied to Telegram's servers unchanged.
How to change the connection address in your bot
Changing the api.telegram.org address is supported by the Telegram Bot API, and most libraries provide a way to change this address.
Important. The examples use the address "https://tgrasp.co" — you can only use this address if a bot token was specified in the Dashboard. Otherwise, use only the address you received in the Dashboard during the bot setup step.
If you set a token for the bot in the Dashboard, the system will give you the address "https://tgrasp.co", otherwise the address will be "https://botcode.tgrasp.co"
Instructions for various libraries
Python
PHP
JavaScript
Go
Java
Common errors
All errors related to bot operation appear in the bot errors section in the Dashboard.
403,404
Make sure you're using the correct connection address. Compare it with the address the system gave you. The tgrasp.co address can only be used if a token was provided.
If you're using tgrasp.co, make sure the bot ID (which the token starts with) matches the one you provided to graspil. The current bot ID in graspil is displayed under the connection address field.
409
Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
This error occurs when Telegram's servers detect two simultaneous getUpdates requests. Make sure you only have one data-receiving thread running
502
502 Bad Gateway
Make sure you're sending a request with the correct structure. Sometimes there are issues on Telegram's servers, and they may respond with this error.
No connection to the server
Specify the correct region for your bot. You should choose the region where your bot's server is physically located.
Use the address provided by the system.
Last updated