gem.bot/howto

Receive updates: webhooks or getUpdates

What it is

Every event for your bot, from a message to a payment, arrives as an update. You get updates one of two ways, never both: your code pulls them with getUpdates (long polling), or Telegram posts each one to your HTTPS address (a webhook). Undelivered updates wait at most 24 hours.

How to do it

  1. Polling: call getUpdates in a loop with a positive timeout, passing offset = last update_id + 1 to confirm handled updates.
  2. Webhook: call setWebhook with your HTTPS url and a secret_token; reject requests without a matching X-Telegram-Bot-Api-Secret-Token header.
  3. Filter with allowed_updates; set max_connections (1–100, default 40) to your server's capacity.
  4. Answer webhook requests with HTTP 2XX, or Telegram retries and eventually gives up.
  5. Check delivery with getWebhookInfo: pending_update_count, last_error_message.
  6. Back to polling: deleteWebhook (drop_pending_updates clears the queue).

Watch out

With Gem

Gem doesn't host your bot's code or take its webhooks, and a creator's own bot isn't available yet. Projects run on @gembot, which Gem holds: Stars payments for offers, join requests, channel posts and answers in groups.

Sources

Open in Telegram