postIntegrationsTelegramWebhook method

Future<void> postIntegrationsTelegramWebhook()

Telegram Bot API webhook

The update webhook for the Telegram bot. It does two jobs: /start <code> or /connect <code> binds the chat it was sent from to an org, idempotently; anything else is treated as a possible agent trigger. What counts as a trigger differs by chat type, and it is easy to get wrong: in a private chat every message is a trigger, while in a group the message must mention the bot or use the /hanzo command. Non-triggers and non-message updates are acknowledged and dropped. Authentication is the secret token Telegram echoes on every update, compared in constant time. A message in a chat that has never been bound is dropped, which is why the bind command exists. The caller here is the PLATFORM, not a Hanzo tenant, so there is no bearer and no principal. The signature check IS the authentication, and it fails closed. The tenant is never read from the payload either: it is resolved from the verified platform identifier through the connection map, so an event from a workspace nobody connected does nothing. Refusals are written with their own status rather than being flattened to a 500, so a rejected signature reads as 401 and a malformed body as 400. The answer is acknowledged immediately and the work happens afterwards, because every one of these platforms times out a slow webhook. Duplicate deliveries are absorbed durably, so a platform retry of an event that already ran never runs it a second time or bills for it twice. When the agent pool is full nothing at all is recorded and the delivery is refused as retriable, so the message is re-delivered later rather than being lost or half-processed.

Implementation

Future<void> postIntegrationsTelegramWebhook() async {
  final response = await postIntegrationsTelegramWebhookWithHttpInfo();
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
}