Skip to content

Telegram: receive updates by polling (getUpdates) for servers without a public HTTPS address #1873

Open

Description

@CrushBy

Description

The Telegram module receives messages only through a webhook: when an account of the Telegram messenger is created, it registers webServerUrl() + '/exec/webHookTelegram?botid=<account>' with Telegram, which then calls that address for every update. The web server must therefore be reachable from Telegram over HTTPS.

A server without such an address (an installation behind a firewall, a developer machine) cannot receive at all: the registration fails and the account is not created, or, with skipSetWebHookTelegram[Account] implemented, the account is created but can only send. Telegram's own alternative for this case, getUpdates (long polling), has no action in the module, and once a webhook is registered Telegram refuses getUpdates until the webhook is deleted. An application that needs polling has to reimplement the update handling of webHookTelegram[JSONFILE] itself.

Fix

An account of the Telegram messenger gets a receiving mode: webhook (as now) or polling. In the polling mode no webhook is registered (a registered one is deleted), and a new action receiveUpdatesTelegram[Account] requests the updates since the last processed one with getUpdates and handles each of them exactly as the webhook action does (chat creation, message storage), so that the scheduler can run it. The messengers documentation describes both modes.

Reason

Many installations have no address reachable from the Internet, and today a Telegram bot on them cannot receive messages at all.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions