All projects

Technical Report · Workflow Automation

Telegram Message Forwarder

Telethon-based Python service that listens to specified Telegram source channels and forwards new messages to a configured destination group in real time.

AUTHOR  Gaurav Verma CATEGORY  Workflow Automation SOURCE  https://github.com/gaurav-321/telegram_message_forwarder DATE  Mar 2024 STATUS  published
View Source Python API Automation Workflow Automation Telegram Telethon

Abstract

A Telethon-based Python service that subscribes to new-message events on configured Telegram source channels and forwards each eligible message to a destination group in real time. The one thing worth reporting on is the event-driven architecture: a persistent client connection reacts to incoming events rather than polling chat history.

1. What This Is

A focused routing utility. Source channels, target group, and Telegram API credentials are all configuration; the event handler performs the forwarding. The project intentionally keeps scope narrow — one service, one destination, one connection — so the same code can be repointed without touching event logic. It also serves as a concrete example of the difference between a bot-style HTTP workflow and a full Telegram client library such as Telethon.

2. How It Works

The service runs as a long-lived async process. Once the Telethon client authenticates, it registers a new-message handler scoped to the configured source channels. Every incoming event is verified against the source list and then forwarded to the target group using Telegram's native forwarding behavior.

# Stage Input Tool Output
01 Authenticate API credentials Telethon Connected client session
02 Subscribe Source channel IDs Telethon events Registered handler
03 Verify Incoming message event Event handler Confirmed source match
04 Forward Verified message Telethon forward Message in target group
05 Loop Async event loop Persistent connection

3. Constraints

  • Single destination

    All forwarded messages go to one configured group. There is no per-channel routing rule, so repurposing the service for multiple targets requires a separate instance.

  • No message filtering

    Every new message from a source channel is forwarded. There is no keyword, type, or sender-based filter, which can flood the target group in high-traffic channels.

  • No persistence or retry

    If the connection drops, in-flight messages are lost. There is no queue, replay, or acknowledgment mechanism to recover missed events.

  • Single client session

    One Telethon client means one authentication session. Scaling to many channels or destinations requires spawning additional processes or clients.

4. Next

  1. a. Add per-channel routing rules so different sources can map to different destination groups.
  2. b. Introduce a lightweight message filter (type, keyword, or sender-based) before forwarding to reduce noise.
  3. c. Add a simple health-check log line or endpoint so the service can be monitored in a long-running deployment.

— end of report —