Status: Authoritative Version: 1.0 Stack: Telegram-native · Event-driven · Cloudflare Workers
TeamMarySy Bot is a Telegram-native automation system.
- Telegram is the user interface.
- The bot does not recreate features Telegram already provides.
- The bot stores only the minimum state its own logic requires.
Principles: Telegram-first · Event-driven · Stateless execution between events · Minimal persistence · No member directory · No broadcast engine · No web dashboard · No unnecessary storage.
Telegram
│
▼
Cloudflare Worker
┌───────────────────────────┐
│ fetch() scheduled() │
└─────────┬─────────┬───────┘
└────┬─────┘
▼
route(event)
│
┌───────────┼───────────┐
▼ ▼ ▼
handleMessage handleCallback handleSchedule
│ │ │
└───────────┼───────────┘
▼
Business Modules
┌──────────┬──────────┬──────────┐
▼ ▼ ▼
Content Community Support
│
▼
Cloudflare KV
(minimal state)
│
▼
Telegram Bot API
│
▼
Telegram
scheduled() is a peer entry point to fetch(), not something downstream of
the business modules — the Cron Trigger is just another event source.
The bot accepts only Telegram updates and Cron events:
messagecallback_querychat_join_request- scheduled event (Cloudflare Cron)
No user database. Roles are:
- Owner — ID from config (
env.OWNER_ID). - Admin — IDs stored in KV (
config:admins). - Member — everyone else. No permanent record is kept.
Public: /start, /panel
Modules: /content, /community, /support
Commands only start workflows — they never execute complex multi-step logic directly.
Navigation uses Telegram inline keyboards exclusively. No dashboard, no website.
/panel
──────────────
📝 Content
👥 Community
🎫 Support
Target capabilities are create, publish, list, archive, and schedule. In version 1.0,
the Telegram create/list/archive workflow is intentionally stubbed; publishing and
scheduler plumbing are implemented. Publishing sends directly to the configured
Telegram channel. Content.publish() is the single function that
knows how to turn an item into a Telegram message — both manual publishing
and the scheduler call through it.
Handles chat_join_request events. Owner and configured admins get Approve/Reject inline
buttons; the bot calls approveChatJoinRequest() / declineChatJoinRequest().
Telegram already tracks pending requests — the bot does not duplicate that
storage.
Version 1.0 implements ticket creation and the underlying resolve operation. The Telegram commands for viewing and resolving tickets are planned but not yet wired. Tickets are stored in KV; retention and archival policy remain implementation choices.
Replaces the need for a broadcast engine. Runs on Cloudflare Cron Triggers and calls into the same business modules — it never bypasses them or talks to the Telegram API directly.
Jobs: publish scheduled content, send reminders, clean temporary state, remove expired tickets/failed jobs.
Stores only what the bot cannot obtain from Telegram:
| Key prefix | Purpose |
|---|---|
config:* |
Bot configuration, admin list |
content:* |
Drafts and scheduled posts (module state) |
ticket:* |
Active/resolved support tickets |
sched:* |
Pending scheduled jobs |
sched:failed:* |
Jobs that exhausted retries |
state:<chat>:<flow> |
Short-lived conversation state (TTL'd) |
counter:* |
Sequential IDs |
Not stored: user profiles, member directory, join request history, message history, chat history, unnecessary logs.
Telegram → Webhook → Cloudflare Worker → Verify Secret → Parse Update
→ Route → Command | Callback | Join Request | Scheduler
→ Business Module → KV (only if needed) → Telegram Bot API → Telegram
- Transport (
index.js,router.js) — webhook validation, parsing, routing. No business logic. - Application (
handlers/) — commands, callbacks, permissions, workflow execution. All business rules live here (in the modules it calls). - State (
kv/) — config, active content, active tickets, scheduled jobs, counters. Nothing more. - Delivery (
telegram.js) — all Telegram Bot API calls (sendMessage,editMessageText,answerCallbackQuery,approveChatJoinRequest,declineChatJoinRequest).
- Telegram is the UI.
- Commands are public entry points; callback queries continue workflows.
- Inline keyboards provide navigation.
- Join requests use Telegram's native
chat_join_request. - Scheduler performs time-based automation through the same modules.
- Workers KV stores only essential application state.
- No broadcast engine, no web dashboard, no permanent member database.
TeamMarySy Bot is a Telegram-native, event-driven automation engine running on Cloudflare Workers. Telegram provides the interface, Cloudflare Workers execute the logic, Workers KV stores only essential application state, and Cloudflare Cron Triggers provide scheduled automation. The bot relies on Telegram's native commands, inline keyboards, callback queries, and join-request events instead of recreating platform functionality, resulting in a lightweight, maintainable, and efficient architecture.
See diagrams/:
command-flow.mermaidcallback-flow.mermaidscheduler-flow.mermaid