Skip to content
Discussion options

You must be logged in to vote

tgbot-cpp implements only the bot backend; the Web App itself is a separate HTTPS page using the Telegram Web App JavaScript API.

For the simplest sendData flow, attach a WebAppInfo to a reply-keyboard button:

auto app = std::make_shared<TgBot::WebAppInfo>();
app->url = "https://example.com/app";

auto button = std::make_shared<TgBot::KeyboardButton>();
button->text = "Open app";
button->webApp = app;

In JavaScript call Telegram.WebApp.sendData(...). The bot receives a normal message with message->webAppData; check it in onAnyMessage and read message->webAppData->data.

An InlineKeyboardButton::webApp uses the inline Web App query flow instead: send the query ID from the Web App to your ba…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by reo7sp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants