telegram-bot-api-getting-updates
SKILL.md
Telegram Bot API: Getting Updates
Purpose
Use this skill when building the event-ingestion layer for a Telegram bot.
Core API surface
getUpdatessetWebhookdeleteWebhookgetWebhookInfoallowed_updates- the
Updateobject and all of its branches
Update ingestion rules
- Choose exactly one delivery mode:
- long polling with
getUpdates - outgoing webhooks with
setWebhook
- long polling with
- Persist progress:
- store the last handled
update_id - call
getUpdateswithoffset = last_update_id + 1
- store the last handled
- Make handlers idempotent:
- duplicate deliveries happen
- retries and redeploys happen
- Route by update family first:
messageedited_messagechannel_postcallback_queryinline_querypoll_answermy_chat_memberchat_memberchat_join_requestbusiness_*message_reaction*purchased_paid_media
Long polling guidance
- Use long polling in development and small deployments.
- Use positive
timeoutvalues, not tight short-poll loops. - Recompute offset after every successful batch.
- Use
allowed_updatesto reduce load and simplify handler logic.
Webhook guidance
- Use HTTPS and a public endpoint.
- Set a
secret_tokenand validate theX-Telegram-Bot-Api-Secret-Tokenheader. - Inspect
getWebhookInfoduring incidents. - Consider
drop_pending_updateswhen intentionally resetting a deployment.
Handler design
- Normalize raw updates into internal event types.
- Separate transport errors from business-logic errors.
- Acknowledge or return quickly, then do slow work asynchronously when possible.
- Keep callback-query responses fast to avoid stuck client spinners.
Recovery patterns
- After downtime, process pending updates in order.
- When switching from webhook to polling, delete the webhook first.
- When switching to a local Bot API server, follow Telegram's
logOut/closeguidance.
Common mistakes
- Running polling while a webhook is still configured.
- Forgetting to persist offsets.
- Treating missing optional branches as errors.
- Ignoring new update families such as Business, paid media, or reactions.
Read next
03-messages-and-formatting06-inline-mode-and-callbacks20-localization-testing-and-local-bot-api
Weekly Installs
2
Repository
nzhulikov/teleg…t-skillsFirst Seen
11 days ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
codex2