Reputation: 41
I have a common server and backend (written in Python) for several Telegram bots, each bot has access to a mini-application. When opening this web application, a backend request must be executed, and database entries corresponding to a specific bot must be selected - this data will be displayed in the web application. The problem is that it is not entirely clear how it can be determined which bot is opening the mini-application. The only way seems to be to make a request to the backend via the bot id. But according to the Telegram Mini Apps documentation, it is impossible to get information about the bot through the object window.Telegram.WebApp
. So, the question is: is there any other possible way to get information about the bot, including its ID, from the Telegram mini-application? Or is this possible only when executing the getMe method via the Telegram Bot API on the server? And if so, is it possible to somehow transfer information from the server to the mini-application when it is opened from the bot (that is, without making requests to the server from the mini-application)?
In search of a solution, I studied the documentation on Telegram Mini Apps and Telegram Bot API, and also searched on stackoverflow and github, but did not find anything that would help to find the answer to the question.
Upvotes: 4
Views: 1657
Reputation: 624
It seems we should pass some info (id, username, internal db id, etc..) about bot launching mini app in mini app url query params so that app code can access it. Actually we can use this method to pass any information we want from bot code to mini app code during launch.
I personally tested 2 approaches to launch mini app from bot reply - from inline button(can use custom query params in mini app url) and direct link, where startapp
url query param should be used.
Upvotes: 1