| 38-telegram-bridge |
01 |
api |
| telegram |
| grammy |
| long-polling |
| bot |
| chat |
| relay |
|
| phase |
provides |
| 36-voice-pipeline |
nexus-settings.ts with telegramToken schema field |
|
|
| grammY bot lifecycle (start/stop/isRunning) via telegramService factory |
| Text message relay |
| Telegram user message -> agent reply with [AgentName] prefix |
|
| In-memory session map chatId:agentId -> conversationId |
| POST /api/telegram/token endpoint (validate token via getMe, save, restart bot) |
| GET /api/telegram/status endpoint |
| Conditional auto-start of bot in app.ts when telegramToken is configured |
|
| 38-02 (voice pipeline integration uses same telegramService) |
| 38-03 (onboarding step that calls POST /telegram/token) |
|
| added |
patterns |
|
|
| telegramService(db) factory returns { start, stop, isRunning } — stateful module-level bot ref |
| Route receives service instance as second param |
| telegramRoutes(db, svc) |
|
| deleteWebhook() called before bot.start() to clear any stale webhook registration |
| bot.start() not awaited (never-resolving long-poll promise) |
|
|
| created |
modified |
| server/src/services/telegram.ts |
| server/src/routes/telegram.ts |
|
| server/src/app.ts |
| server/package.json |
| pnpm-lock.yaml |
|
|
| telegramRoutes accepts service instance as second param (not module singleton) — enables testability and restart from token route |
| bot variable assigned before handlers registered — allows bot.on() calls to reference the outer ref cleanly |
| nexusSettingsService re-exported from telegram.ts removed — routes import directly from nexus-settings.ts to avoid circular potential |
|
| Service factory receives db, returns lifecycle object { start, stop, isRunning } — matches voicePipelineService pattern |
| Long-polling: deleteWebhook first, then bot.start() fire-and-forget with catch logger |
|
| TGRAM-01 |
| TGRAM-02 |
| TGRAM-05 |
| TGRAM-06 |
|
15min |
2026-04-04 |