Clients
Clients
Instruction
Variables
The service has a minimalistic setup. You need to set up a connection to Kafka, Telegram and specify the desired webhook.
# List os telegram tokens. Json format
ENV_TELEGRAM_TOKENS: ["1111111111:XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
# URL where the webhook will work
APP_WEBHOOK_PREFIX: tgc-webhook
# your application's base url (domain)
APP_BASE_URL: https://example.com/
# Result: webhook on "https://example.com/tgc-webhook"
docker pull rocshers/telegram-kafka-connector
Docker compose
docker-compose.yaml
version: '3.8'
services:
app:
image: rocshers/telegram-kafka-connector:latest
environment:
- ENV_TELEGRAM_TOKENS=["1111111111:XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
- APP_PREFIX=tgc-webhook
- APP_BASE_URL=https://example.com/
# WebHook url -> https://example.com/tgc-webhook
Architecture
What’s happening? Nothing complicated. The service’s only task is to subscribe to updates, receive them, and send them to Kafka, where other consumers can then read the data.
graph TD Telegram[Telegram] Nginx[Nginx] Kafka[("Kafka")] Telegram ==> |Receiving new events| Nginx TKC1[tkc #1] TKC2[tkc #2] Nginx --> TKC1 Nginx --> TKC2 TKC1 -->|Saving| Kafka TKC2 -->|Saving| Kafka Kafka --> AnyConsumer1[Consumer #1] Kafka --> |Get new events| AnyConsumer2[Consumer #2] Kafka --> AnyConsumer3[Consumer #3]
Process
What’s happening? Nothing complicated. The service’s only task is to subscribe to updates, receive them, and send them to Kafka, where other consumers can then read the data.
sequenceDiagram participant AnyConsumer participant Kafka participant TGC participant Telegram TGC->>+Telegram: setWebhook(tgc.example.com/webhook). Telegram->>-TGC: 200 OK Note over Telegram,TGC: We set new WebHook Telegram->>TGC: POST with Updates[] TGC->>Kafka: Pushing new Updates[] Telegram->>TGC: POST with Updates[] TGC->>Kafka: Pushing new Updates[] Note over Telegram,TGC: Telegram sends us updates AnyConsumer-->>Kafka: Get Updates[]