Skip to content

Telegram: Add PostgreSQL store and HA deployment mode #362

Description

@ptone

Summary

The Telegram integration (extras/scion-telegram/) currently only supports SQLite for state storage and runs exclusively as a go-plugin subprocess of the hub. Add PostgreSQL store support and a standalone service mode to enable HA deployment.

Current State

  • ✅ Fully functional as go-plugin subprocess (managed by hub)
  • ✅ Both long-polling and webhook inbound modes implemented
  • ✅ SQLite store for group links, user mappings, conversation contexts, notification preferences
  • ❌ No PostgreSQL store
  • ❌ No standalone server mode (only go-plugin subprocess)

Work Required

  • PostgreSQL store implementation (mirror the SQLite schema to Postgres, similar to Discord's store_postgres.go)
  • Standalone gRPC server entry point in main.go (allow running as separate service, not just go-plugin subprocess)
  • Self-managed plugin configuration support (hub connects to external Telegram service)
  • State migration tooling (SQLite → Postgres for existing deployments upgrading to HA)
  • Container deployment support (Dockerfile, Cloud Run / k8s config)
  • Consider advisory lock or equivalent for webhook mode coordination (only one instance should hold the webhook registration)

Context

  • Telegram supports both long-polling (outbound, works behind NAT) and webhook (requires public URL) modes
  • Long-polling mode: only one instance can poll at a time (409 conflicts) — needs coordination similar to Discord's advisory lock
  • Webhook mode: Telegram sends to a single URL, so a load balancer or single-instance constraint is needed
  • Discord's store_postgres.go can serve as a reference implementation
  • Part of broader chat integration admin UI initiative

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions