Skip to main content
Updates are the fundamental data packets that Telegram sends to your bot when something happens. Every message, callback query, inline query, and other event generates an update.

What is an Update?

An update is a JSON object from Telegram that contains information about an event. Each update has:
  • A unique update_id that increments sequentially
  • Exactly one of many possible update types (message, callback_query, etc.)

Update Types

Message Updates

The most common updates are messages:
Update types:
  • message - New message in a chat
  • edited_message - A message was edited
  • channel_post - New channel post
  • edited_channel_post - Channel post edited

Business Updates

For Telegram Business accounts:
Update types:
  • business_connection - Business account connected/disconnected
  • business_message - New message in business chat
  • edited_business_message - Business message edited
  • deleted_business_messages - Messages deleted from business chat

Callback Queries

When users click inline buttons:
Always call ctx.answerCallbackQuery() within 30 seconds or users see a loading indicator indefinitely.

Inline Queries

When users type @your_bot query in any chat:

Reactions

When users react to messages:
You must enable message_reaction in allowed_updates to receive reaction updates:

Chat Member Updates

Other Update Types

Receiving Updates

There are two ways to receive updates:

Long Polling (Default)

The bot repeatedly calls getUpdates to fetch new updates:
Advantages:
  • Easy to set up
  • Works anywhere (no public URL needed)
  • Good for development
Disadvantages:
  • Slightly higher latency
  • Keeps a persistent connection
  • Limited scalability for high-load bots

Webhooks

Telegram sends updates to your server via HTTP POST:
Advantages:
  • Lower latency
  • Better for high-load bots
  • Serverless-friendly
Disadvantages:
  • Requires public HTTPS URL
  • More complex setup
See the Webhooks guide for details.

Allowed Updates

By default, grammY requests most update types but excludes:
  • chat_member
  • message_reaction
  • message_reaction_count
Specify which updates to receive:
If you register handlers for update types not in allowed_updates, grammY will warn you:

All Available Update Types

Update Processing

Sequential Processing

By default, grammY processes updates sequentially:
This ensures:
  • Messages from the same user are processed in order
  • No race conditions with shared state
  • Predictable behavior

Concurrent Processing

For high-load bots, use @grammyjs/runner:
The runner:
  • Processes multiple updates simultaneously
  • Maintains order for updates from the same chat
  • Handles backpressure automatically
  • Provides graceful shutdown

Update Confirmation

Telegram needs confirmation that you received updates. This is handled automatically:

Long Polling

Webhooks

If you don’t confirm updates:
  • Long polling: getUpdates will return the same updates repeatedly
  • Webhooks: Telegram will retry sending the update

Dropping Pending Updates

When starting your bot, you can drop all pending updates:
This is useful:
  • During development when you don’t want old test messages
  • After bot downtime when old updates are no longer relevant
  • When changing the bot’s behavior significantly

Update ID Management

Each update has a sequential update_id:
grammY tracks the last processed update ID internally:
  • Ensures no updates are skipped
  • Resumes from the correct position after restart
  • Handles errors gracefully

Handling Updates Manually

Process updates without long polling:
This is useful for:
  • Testing
  • Custom update sources
  • Webhook implementations

Best Practices

Specify Allowed UpdatesOnly request the update types you need:
This reduces bandwidth and improves performance.
Handle Errors Gracefully
Use Webhooks for ProductionFor production bots with significant traffic, webhooks are more efficient than long polling.
Don’t Block the Update LoopLong-running operations should be handled asynchronously:

Update Flow

Debugging Updates

Log all incoming updates:
Or use the debug logger: