Repository navigation
Description
Summary
Trinity drives Telegram by webhook only. src/backend/adapters/transports/telegram_webhook.py calls setWebhook, handing Telegram a URL its servers then make inbound HTTPS requests to. Add the Bot API's outbound alternative — getUpdates long polling — so a Telegram binding keeps working on an instance with no publicly reachable address.
Verified: grep -rn "getUpdates" src/ docker/ returns zero hits. Webhook is the only transport implemented.
Why it matters
On a private-network install (Tailscale, or any instance behind a VPN with the public ports closed), the tailnet address is in 100.64.0.0/10 — carrier-grade NAT, not routable from Telegram's servers — so the webhook never arrives and the binding is dead.
The hardening guide has to tell operators this, and it currently reads as a Telegram limitation:
| Telegram, WhatsApp, VoIP | Work | Broken |
It is not. WhatsApp (Twilio) and VoIP genuinely have to call in. Telegram does not — the Bot API offers long polling, which is outbound and would survive a tailnet exactly as Slack's Socket Mode already does (src/backend/adapters/transports/slack_socket.py). Slack is the one integration in that table that survives a private network, and it survives for precisely this reason.
So Trinity has the pattern already; Telegram just never got it.
Acceptance Criteria
- A Telegram binding can run in polling mode, chosen per binding or per instance — a webhook install is unaffected and nothing silently switches
- Mode is explicit in Settings, and the UI says which one a binding is using and what each needs (polling: no public address; webhook: a reachable HTTPS URL)
- Switching to polling calls
deleteWebhookfirst — Telegram refusesgetUpdateswhile a webhook is registered, and the error is unhelpful - Polling runs under a leader lease like every other background loop (Invariant: every loop starts in EVERY uvicorn worker — see
docs/memory/architecture/background-services.md), so N workers do not each consume updates and drop messages for the others -
offsetis persisted across restarts, or a restart re-delivers or skips updates - Failure is visible: a polling loop that has stopped surfaces the same way a failed webhook registration does, rather than a bot that has quietly gone silent
- The hardening guide's Step 2 table stops calling this broken, and the note added there pointing at this issue is removed
Notes
- Long polling holds an open HTTP request to
api.telegram.orgfor up to the timeout, so the loop wants its own connection handling rather than the shared short-lived client. - Slack's Socket Mode transport is the closest existing shape to copy — outbound, long-lived, leader-gated.
- Scope is the transport only. Nothing about how a normalized message is handled afterwards should change;
ChannelAdapter(Invariant 9) already sits above this.
Found while rewriting the marketplace hardening guide (#2692): the guide could not honestly explain the Broken cell without naming it as our gap.
Refs #2692
Activity
docs(deploy): the tunnel and a private network compose — stop present…
fix(onboarding): plain-language first-run copy, one inline surface, a…