Receiving updates
Long polling or a webhook — one or the other, as in Telegram.
What arrives
| Update | When |
|---|---|
message | someone writes to the bot or in a group it is in; includes web_app_data from a keyboard Mini App |
edited_message | a message the bot saw is edited |
callback_query | someone presses an inline button with callback_data |
Messages carry the full from, via_bot, reply_to_message (one level deep) and entities with bot_command, which is how libraries find commands. Bots do not see other bots’ messages. Updates are queued in message order.
getUpdates
offset, limit, timeout (up to 10 seconds) and allowed_updates. Only what has already been handed out is confirmed by a higher offset, so nothing is lost; a negative offset returns the last N. A waiting request wakes the moment something arrives. With a webhook set, getUpdates answers 409.
Webhooks
https://on port 443, 80, 88 or 8443, at a public address.- One update per request; any 2xx counts as delivered.
- Each bot has its own delivery queue, so a slow bot does not hold up others. On failure we wait 2n seconds (at most 60); an update that fails five times is dropped.
getWebhookInforeportspending_update_count,last_error_dateandlast_error_message.
Undelivered updates are kept for a day, and at most 10 000 per bot.
Answering a button
Call answerCallbackQuery within ten seconds: text shows as a small notice, show_alert as a dialog, url opens after the person confirms. A query can be answered once, within a minute.