/telegram-skills:tg-miniapp-launch-authfrom telegram-skills
Guides choosing a Telegram Mini App launch path (keyboard, inline, menu, main app, direct link, join request) and validating initData via HMAC or Ed25519, including auth_date, signature, origin protection, and test links.
Ships in telegram-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Checked against the official docs on 2026-10-30: Bot API 10.3 (August 24, 2026), Mini Apps page with Recent changes up to 10.1, telegram-web-app.js?64. The Bot API 10.4 and 10.5 changelogs change nothing here (checked 2026-12-02). The Mini Apps page doesn't describe origin protection (see below); the changelog does.
No bot, client or device was used to write this skill. These checks wait for a live Mini App:
initData string with signature from a live bot in 2026. The repository's tests use synthetic vectors, so they prove this code matches the algorithm below, and only a live string proves Telegram still signs that way. We found no public vector for Telegram's Ed25519 key without a real person's data, so that key is untested here.mode=fullscreen in links.| Path | Set up | initData | How the app answers |
|---|---|---|---|
| Inline keyboard button | InlineKeyboardButton.web_app, private chats only | user, query_id | answerWebAppQuery sends a message on the user's behalf and closes the app |
| Menu button | BotFather /setmenubutton, or setChatMenuButton with MenuButtonWebApp for one chat | same as inline keyboard button | same as inline button |
| Main Mini App | BotFather, then t.me/<bot>?startapp[=value][&mode=compact] | user, chat_type, chat_instance, start_param | own server |
| Direct link | Named app in BotFather, then t.me/<bot>/<app>?startapp=value&mode=compact | same as main app; no access to the chat | own server; to send a message, send the user back to inline mode |
| Rich message button | RichMessageButton.web_app (10.3), private chats only | same as inline keyboard button | same as inline button |
| Join request (10.1) | Guard bot: sendChatJoinRequestWebApp on chat_join_request | user, chat, chat_join_request_query_id | answerChatJoinRequestQuery with approve, decline or queue |
| Keyboard button | KeyboardButton.web_app, private chats only | empty | sendData, up to 4096 bytes: the bot gets a web_app_data service message and the app closes |
| Inline mode | InlineQueryResultsButton.web_app in answerInlineQuery | empty per WebAppInitData | switchInlineQuery sends the user back to pick a result |
Take the first row that fits. Choose a path with a verifiable user whenever the server needs identity: keyboard and inline mode launches carry none.
The attachment menu is available only to major advertisers on the Telegram Ad Platform; other bots can use it only on the test server. requestChat (9.6) with savePreparedKeyboardButton lets an open app ask the user to pick a chat.
start_paramstartapp takes up to 64 characters, A-Z, a-z, 0-9, _ and -; use base64url for binary data. The value arrives in initData.start_param and in the GET parameter tgWebAppStartParam.
start_param.WebAppInitData table says start_param is returned only for the attachment menu. The main app and direct link sections of the same page say it is passed there too. Follow those sections.The main app and direct links open at full height by default; mode=compact opens them at half height. mode=fullscreen appears only in the MTProto links page, so treat it as unconfirmed for the Bot API docs.
Telegram.WebApp.initData is the only input to validate. initDataUnsafe is a convenience for rendering and proves nothing.
initData string unchanged, for example Authorization: tma <initData> (a tma.js convention).initDataUnsafe.hash by HMAC with the bot token, then auth_date. A server without the token verifies signature instead, see below.user from the validated fields and stores id in a 64-bit type: it has up to 52 significant bits.secret_key = HMAC_SHA256(key="WebAppData", msg=bot_token), then hash = hex(HMAC_SHA256(key=secret_key, msg=data_check_string)). The check string is all received fields except hash, URL-decoded, sorted by key, as key=value, joined with \n. Compare in constant time.
signature stays in this string. The docs say "all received fields" and don't name it. tma.js excludes only hash (validation.ts:94). On 2026-10-30 a string that tma.js publishes as signed by Telegram (created 2024-12-07) matched only with signature kept. That string names a real person, so it stays out of this repository. Keep the exclusion list to hash alone.
scripts/init_data.py does this with the standard library and no network. It rejects repeated keys, because a duplicated field could mean one thing to the check and another to your code. max_age=0 skips the age check, and now overrides the clock in tests. JSON fields such as user stay strings for you to parse:
from init_data import InitDataError, validate
try:
fields = validate(raw_init_data, bot_token, max_age=3600)
except InitDataError as error:
return reject(401, error.code) # malformed, missing_hash, invalid_hash, invalid_auth_date, expired
user = json.loads(fields['user'])
auth_dateThe docs make the check optional and name no limit. tma.js defaults to 86400 seconds. Pick your own limit by the value of the action.
initData is issued once, when the app opens, and carries no nonce. An app left open past your limit starts getting expired, so plan a reopen prompt or issue your own short session after the first validation.
Share initData and bot_id; the third party verifies signature, an Ed25519 signature in base64url, with Telegram's public key.
<bot_id>:WebAppData\n, then fields except hash and signature, sorted, key=value, joined with \n.e7bf03a2fa4602af4580703d88dda5bb59f32ed8b02a56c187fe7d34caed242d40055058a4ee38156a06562e52eece92a771bcd8346a8c4615cb7376eddf72ec= padding, and strict base64 decoders reject it. third_party_payload restores it.third_party_payload only prepares (message, signature) and the check stays with your verifier.auth_date as well.import time
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from init_data import third_party_payload, parse_init_data
message, signature = third_party_payload(raw_init_data, bot_id)
Ed25519PublicKey.from_public_bytes(bytes.fromhex(PRODUCTION_KEY)).verify(signature, message)
auth_date = int(parse_init_data(raw_init_data)['auth_date'])
if time.time() - auth_date > MAX_AGE_SECONDS:
raise PermissionError('initData is too old')
MAX_AGE_SECONDS is your freshness policy.
Telegram.WebApp.version is the Bot API version of the user's client. Calling a method above it fails: in telegram-web-app.js requestFullscreen logs to the console and throws WebAppMethodUnsupported.
const app = Telegram.WebApp;
if (app.isVersionAtLeast('8.0')) app.requestFullscreen();
isVersionAtLeast proves the method exists, not that it will work: see the iOS report in ../tg-miniapp-ui/client-pitfalls.md.
Since July 20, 2026 Mini App methods can't be called from origins other than the original Mini App domain. It is on by default for all Mini Apps (changelog, Bot API 10.2).
Telegram.WebApp method, openInvoice included, from a page on the Mini App domain.The Mini Apps page lists Telegram.WebApp.Serverless, where the platform validates initData before running a bot's endpoint. Its docs name no access terms or prices, and a practitioner report describes a closed test, so this skill assumes your own server.
Test server login, inspectors per platform and the mock for a plain browser: references/testing-debug.md.
telegram-web-app.js: https://telegram.org/js/telegram-web-app.js?64signature handling, read and not vendored: commit a841aba28517c138af7debf4ad557fcf0c1f92fd, packages/init-data/src/validation.ts (SHA-256 1592acd7e04283cfb9a6103b0d48b5816f1e617ca0bd1e862277d534a65c1472), MIT in packages/init-data/LICENSE (SHA-256 c44881466bac14b6b7e30e35073940d15081efbadcf37f7e70993015cf0c0ef7), fixture string in packages/init-data/test/fixtures.ts (SHA-256 77825e04c296754da8d9667dfe072403725c442eb52f34dcdc48bbadbfa6189e) · padding note https://github.com/Telegram-Mini-Apps/tma.js/blob/master/apps/docs/platform/init-data.mdWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub serejaris/telegram-skills --plugin telegram-skills15 skills in this plugin
/tg-bot-opsUse when running a Telegram bot in production: webhook or long polling, allowed_updates, webhook secret token, bot settings from code (setMySettings, getMe, privacy mode, callback_query_mode), botinvite links, 429 and retry_after, file retries, broadcast limits and paid broadcasts, lost updates on shutdown, a poison update after new Bot API types, t.me outage and fallback domains, local Bot API server./tg-capability-mapUse before promising a Telegram feature or designing around one: what a bot can do in Bot API, what lives only in the client or MTProto (scheduled posts, channel stats, poll stats, channel stories, folders, boosts, welcome messages, communities), and what never to promise from a bot./tg-classic-messagesUse when sending or editing ordinary Telegram bot messages: sendMessage text, MarkdownV2/HTML escaping and entities, quotes, date_time, custom emoji, link previews, photos and documents with captions, albums, upload size limits, protect_content, copy, forward, delete. Also use to choose between a classic message and a rich message./tg-markdown-to-richUse when converting an existing Markdown file or stdin into a Telegram Rich Message (InputRichMessage.markdown) for sendRichMessage, including file_id, URL, and multipart upload media bindings. Triggers: "send markdown to Telegram", "convert doc to rich message", "telegram rich message from file"./tg-miniapp-uiUse when building or debugging the interface of a Telegram Mini App: theme colors and dark mode, safe areas and notches, fullscreen, keyboard and viewport height, MainButton and SecondaryButton, BackButton, haptic feedback, performance on weak Android, or a layout bug that shows up only on a real iPhone, Android or Desktop client./tg-operator-cardsUse when turning the facts of one bot event — a payment, an order, an enrollment, a moderation decision — into a card for the person who runs the bot, in an admin chat or a private chat with the owner: a review card awaiting a decision or a receipt, read in two seconds on a phone.Other plugins' skills for the same job