3.4 KiB
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 |
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():
- Dla każdego kanału w spec:
- Waliduje istnienie secretu
- Tworzy/aktualizuje Deployment
- Raportuje status (Connected/Disconnected/Error)
- Deployment tworzony z:
- Image:
channel-<type>:<tag> - Env: INSTANCE_NAME, EVENT_BUS_URL, OTEL_*
- EnvFrom: secret z credentials kanału
- Image:
Access Control
Wielowarstwowy:
allowedSenders- whitelist (jeśli set, TYLKO ci nadawcy)deniedSenders- blacklist (nadpisuje whitelist)allowedChats- whitelist chat/group IDsdenyMessage- wiadomość dla odrzuconych (lub cichy drop)
Powiązane: SympoziumInstance | NATS JetStream - Event Bus | Przepływ danych i IPC