Files
obsidian-sympozium/06-Komunikacja/Kanały - Telegram Slack Discord WhatsApp.md
2026-03-25 00:05:57 +01:00

3.4 KiB

Kanały - Telegram, Slack, Discord, WhatsApp

#sympozium #komunikacja #channels

Architektura

Każdy kanał to dedykowany Kubernetes Deployment - osobny pod, osobny lifecycle, osobne credentials.

┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐
│  Telegram    │  │   Slack      │  │  Discord     │  │  WhatsApp    │
│  Deployment  │  │  Deployment  │  │  Deployment  │  │  Deployment  │
│              │  │  Socket Mode │  │              │  │  + PVC       │
└──────┬───────┘  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘
       │                 │                 │                 │
       └────────────────┴─────────────────┴────────────────┘
                                │
                        NATS JetStream
                                │
                        Channel Router
                                │
                        AgentRun Controller

Przepływ wiadomości

Użytkownik → Telegram
    ↓
Channel Pod: telegram/main.go
    ↓
NATS: channel.message.received
  payload: {
    instanceName: "my-agent",
    channelType: "telegram",
    senderID: "123456",
    chatID: "789",
    text: "Sprawdź stan klastra"
  }
    ↓
Channel Router:
  1. Lookup SympoziumInstance
  2. Access control check (allowedSenders, deniedSenders)
  3. Tworzy AgentRun CR z task = text wiadomości
    ↓
AgentRun → Job → Agent → wynik
    ↓
NATS: channel.message.send
    ↓
Channel Pod → Telegram → Użytkownik

Kanały

Kanał Obraz Specyfika
Telegram channel-telegram Bot API
Slack channel-slack Socket Mode + Events API
Discord channel-discord Bot API
WhatsApp channel-whatsapp QR pairing + PVC dla persistence

WhatsApp - specjalny przypadek

  • Wymaga PVC dla credential persistence (QR link przetrwa restart)
  • Strategy: Recreate (nie RollingUpdate, bo RWO PVC)
  • ConfigRef opcjonalny (auth via QR, nie secret)

Konfiguracja

# W SympoziumInstance
spec:
  channels:
    - type: telegram
      configRef:
        secret: telegram-bot-token
      accessControl:
        allowedSenders: ["user123"]
        deniedSenders: ["spammer456"]
        allowedChats: ["group789"]
        denyMessage: "You are not authorized."

Reconciliation

SympoziumInstanceReconciler.reconcileChannels():

  1. Dla każdego kanału w spec:
    • Waliduje istnienie secretu
    • Tworzy/aktualizuje Deployment
    • Raportuje status (Connected/Disconnected/Error)
  2. Deployment tworzony z:
    • Image: channel-<type>:<tag>
    • Env: INSTANCE_NAME, EVENT_BUS_URL, OTEL_*
    • EnvFrom: secret z credentials kanału

Access Control

Wielowarstwowy:

  1. allowedSenders - whitelist (jeśli set, TYLKO ci nadawcy)
  2. deniedSenders - blacklist (nadpisuje whitelist)
  3. allowedChats - whitelist chat/group IDs
  4. denyMessage - wiadomość dla odrzuconych (lub cichy drop)

Powiązane: SympoziumInstance | NATS JetStream - Event Bus | Przepływ danych i IPC