'Don't get a response from from Telegram Web App for bots

I create inline keyboard with web_app field, and it open Web app. But how get data from it? window.Telegram.WebApp.sendData('data') - this method in web app does not throw an error, but in listeners on server don't get anything, even method getUpdates doesn't see anything.



Solution 1:[1]

According to sendData function description:

This method is only available for Web Apps launched via a Keyboard button

See https://core.telegram.org/bots/webapps#initializing-web-apps for more.

So you need to bind your web app url to keyboard button not inline keyboard button.

Don't sure, but if you really want to use inline keyboard to call your web app you need to implement custom requests in web app page to send data to your backend.

Solution 2:[2]

This method is only available for Web Apps launched via a Keyboard button.

However, you can make a workaround by sending in a background a usual http request to your backend with a specified method (according to your apps logics) and a user id.

Solution 3:[3]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 xcHades
Solution 2 Sergey T
Solution 3 Jakhongir Abdukhamidov