INDEX
#08
SYSTEM INDEX08
TIMELINE2026 - Present
ENGINEERING ROLESolo Architect

TG-Echo

Telegram Personal Auto-Messenger & SOTA MTProto Agent

ARTIFACT SPECIFICATION // 08
TG-Echo
Node.jsGramJS (MTProto)OpenAI-Compatible LLMsSecurity FirewallHTML Stream Parser
ENDPOINT: https://github.com/bilalshemsu1/TG-Echo
01 // THE PROBLEM

Standard Telegram automation relies on the Telegram Bot API or webhooks, which require separate bot handles, public server IPs, port forwarding, and cannot act directly on personal 1:1 user direct messages.

02 // LOCAL CONSTRAINTS

Must operate 100% locally via MTProto user session with zero webhooks, maintain multi-turn conversational context without fact pollution, and enforce rigid financial keyword security.

03 // ENGINEERED SOLUTION

Engineered an intelligent state-of-the-art auto-reply agent for 1:1 private messages using personal Telegram account MTProto (GramJS). Dynamically unifies Telegram Cloud history with session streams (8-15 turns), simulates natural human typing delays, converts Markdown to native Telegram HTML, and enforces a strict gatekeeper firewall blocking sensitive financial and credential keywords (e.g. CBE, Telebirr, passwords).

SYSTEMS DESIGN TOPOLOGY // VISUAL ARCHITECTURE

Addis Entrance Hub: Dual-Channel Delivery Topology

High-concurrency web and Telegram MTProto microservices over MySQL transactional persistence

Client Inbound
Web + Telegram
01
Ingress Gateway
Nginx / cPanel SSL
02
Core Service
Custom PHP & Fastify
03
AI Gateway Layer
Multi-Model Proxy
04
MySQL Persistence
Normalized Schema
05
REQUEST LIFECYCLE & EXECUTION PATH

Student requests from low-bandwidth mobile devices ingress through either the web interface or lightweight Fastify Telegram bot. Requests route through custom PHP controllers, querying an in-house AI Gateway for instant tutoring explanations and persisting test session attempts into normalized MySQL tables.

SYSTEM REACH6,000+ Active Students
RESILIENCE STRATEGYGraceful Offline Fallback & Telegram Channel Redundancy
[ARCHITECTURAL DECISIONS & ENGINEERING TRADEOFFS]
Local MTProto Userbot Engine (GramJS)

Connected directly through user String Session via GramJS, eliminating Telegram Bot API limitations, webhook setups, and external port forwarding.

Unified Context Engine (8-15 Chronological Turns)

Dynamically merges Telegram Cloud message history with in-memory session streams to assemble context-dense payloads for OpenAI-compatible LLMs.

Sensitive Keyword Firewall & Gatekeeper

Intercepts incoming messages against a security firewall, immediately halting automated dispatch and alerting the user on sensitive terms (cbe, telebirr, private keys).

Human Typing Simulation & HTML Delivery

Calculates realistic typing delays based on response length and converts LLM markdown output into native Telegram HTML tags (<b>, <code>, <pre>) with multi-bubble splitting.

[DEPLOYMENT MATRIX & STACK]
Node.jsGramJS (MTProto)OpenAI-Compatible LLMsSecurity FirewallHTML Stream Parser