Read this once so the rest of the guide is unambiguous. These terms are platform-independent and used throughout the Bot API.
Overview
An MPChat bot integration is built from a small, fixed set of concepts. Knowing them prevents most early mistakes (wrong ID type, consumed updates, token leaks).
Identity and addressing
Bot token — the credential that authenticates your bot. It is part of the URL path, not a header. Leaking it equals account takeover; store it server-side only.
chat_id — the unique identifier of a conversation (private, group, or channel). It is a JavaScript safe integer or its decimal string. In private chats it usually equals the user id.
user_id / message_id — same integer-or-decimal-string rule as chat_id.
Events and messages
Update — an event object delivered by
getUpdatesor webhook. It carriesupdate_id,message, and so on. Filter withallowed_updates.Message — the message object inside an Update, or the return value of a send method. Carries
message_id,chat,from,text,date.
Receiving modes
Polling — actively pull updates with
getUpdates. Best for local development. Returns409while a webhook is enabled.Webhook — register an HTTPS URL with
setWebhookto receive pushes. Recommended for production; supports an optionalsecret_token.
MiniApp
A MiniApp is a web app embedded in MPChat. The frontend reads a signed initData string; your backend verifies it with HMAC. The parsed initDataUnsafe object is for UI only and must never be used for authorization.
Data flow at a glance
Inbound: user message → Update → getUpdates / webhook handler.
Outbound: parse chat_id → sendMessage (optional
reply_markup.web_app).
Related
IDs can exceed 32 bits. Store them as BIGINT or a string and watch JSON parsing precision.
