Mini Apps
A web page that opens inside the chat and knows who opened it.
How they open
- the menu button set to
web_app— the bot’s main app — and Open on the bot’s profile; - an inline button or a reply-keyboard button with
web_app; - a link:
crdc.xyz/<bot>?startapp=<param>.
Cordice opens only addresses the bot itself set — in the menu button, a message’s buttons or the chat’s keyboard.
initData
Arrives in the URL fragment as tgWebAppData, with tgWebAppVersion, tgWebAppPlatform and tgWebAppThemeParams (the colours of the person’s current Cordice theme).
Fields: query_id (in a chat with the bot), user (JSON, id as a string), chat_type, chat_instance, start_param, auth_date, hash. Check the signature on your server — see tokens and signatures.
The bridge
Include telegram-web-app.js as you would for Telegram. Supported: ready, expand and close; the theme and its changes; the viewport; the Main, Secondary, Back and Settings buttons; popups; opening links; sendData; the header colour; closing confirmation; haptic feedback.
On phones the app runs in a WebView with the same bridge (tgWebAppPlatform is android or ios).
Sending something back
From a keyboard button, sendData arrives as message.web_app_data. From anywhere else, answer with answerWebAppQuery and an InlineQueryResultArticle: the message appears in the chat from the person, “via @your_bot”.
What a Mini App does not get
An app is somebody else’s website. It is not given the camera, the microphone or the location; the clipboard is read only after the person allows it; a request for the phone number is declined.