Skip to Content

src/telegram/echo.ts — Static echo handler

Phase 1 placeholder dispatcher. For every text event it replies received: <text>; other event kinds are acknowledged silently (the webhook still returns 200, so Telegram won’t redeliver).

Public surface

ExportShapePurpose
createEchoHandler(bot)(Telegraf) => (TelegramEvent) => Promise<void>Closure over the bot

Purpose

Proves the inbound pipeline end-to-end before the real MCP agent is wired in. The Phase 1 Definition of Done says “Send /start from your personal account to the bot → reply arrives within 2s”; this is the handler that makes that work.

What replaces this

  • Phase 3 inserts auth gating before this handler runs (pending users see an “approval pending” reply, blocked users get dropped).
  • Phase 6 replaces this handler entirely with the agent forwarder — events are no longer echoed; they’re surfaced to the connected Claude agent over the MCP transport.

Tests

Indirectly via test/unit/dispatch.test.ts — the dispatcher composes recordUser → echo, and the dispatcher tests verify the composition. No dedicated echo test exists because the module is a 2-line closure; coupling it to the dispatcher’s tests catches any breakage.