Reputation: 13
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.
Upvotes: 1
Views: 6583
Reputation: 33
I had similar issues
The issue earlier was diagnosed as an Http trigger. Which was wrong. The issue is that the button does not pass the correct url or may be is not passing it at all.
The button object triggers it correctly.
Buggy Code is this
reply_markup=inlineKeyboard.from_button(
KeyboardButton(
text="Click Here to get Started!",
web_app=WebAppInfo(url="*********************)
) ),
Working code is this.
reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton(text='Profile', web_app=WebAppInfo("***********))],
Hope this helps you guys. You can find me here. https://t.me/me_roving
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation: 91
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.
Upvotes: 4