Crowork Book a free audit

Telegram as your ops layer

How to run real operations on Telegram: bots with memory, approval flows with inline buttons, Mini Apps, group automation and always-on agents on Fly.io.

Most teams use Telegram for one thing, group chat, which is a small part of what the platform can do. Telegram has a mature Bot API, a less-known MTProto client library, inline keyboards that can drive multi-step approval flows, and a Mini App runtime that serves full React UIs inside the chat window. Add a process that stays alive on a cheap Fly.io machine, and Telegram becomes an operations interface as well as a messaging app.

This post covers the patterns behind the Telegram automation we build for clients: bots with persistent memory, inline keyboard approval flows, group automation and signal scraping, and lightweight internal tools built as Telegram Mini Apps. Where a pattern needs code, we show the code.

Why Telegram specifically

Slack and Teams are great for organisations with existing SSO. But if your team already lives in Telegram, or your users do, there is no friction to onboard and no seat licence to buy, and the API surface is excellent. The Bot API is stable and well documented, and its rate limits are generous. MTProto gives you programmatic access to any conversation your account is part of, including reading history without being added as a bot. That combination is hard to match elsewhere.

The deeper reason is persistence. A Telegram bot running on Fly.io at the smallest instance tier (256 MB RAM) costs roughly two dollars a month and never sleeps. It holds state in memory, fires on webhooks in under 100ms, and can write to SQLite on an attached volume for anything that needs to survive a restart. That is a complete, always-on automation runtime.

Bot API vs MTProto: pick the right tool

The two interfaces solve different problems.

  • Bot API is the right default. You register a bot with BotFather, get a token, and call sendMessage / answerCallbackQuery over HTTPS. The bot appears in chats with a distinct badge. Use it for anything user-facing.
  • MTProto (via Telethon, GramJS, or Pyrogram) lets a real user account send messages, read channels it is a member of, and pull message history without a bot token. Use it for monitoring, scraping group signals, or automating actions a human account needs to perform.

A common pattern: one MTProto client watches a set of groups for keywords or new posts, and a Bot API bot delivers the digested signal to an ops channel with inline action buttons. We built a client's CRM inside Telegram on MTProto and Fly.io.

Inline keyboards as approval flows

This is the highest-value pattern and the one most teams miss. Telegram's InlineKeyboardMarkup lets you attach buttons to any message. Each button carries a callback_data string. When a user taps it, the bot receives a callback_query event it can act on at once.

A concrete example: an agent detects an anomaly in a data pipeline and sends:

// Bot sends this to the ops channel
{
  text: "Pipeline failed on step 3 of 7 (transform).\nLast 50 rows lost. Retry from checkpoint?",
  reply_markup: {
    inline_keyboard: [[
      { text: "Retry from checkpoint", callback_data: "pipeline:retry:step3" },
      { text: "Abort and alert",        callback_data: "pipeline:abort" }
    ]]
  }
}

When the engineer taps "Retry from checkpoint", the bot receives the callback, fires the retry job and edits the original message to show the outcome. The whole approval loop, from alert to decision, action and confirmation, happens inside Telegram on the phone, with no dashboard to open and no context switch.

The same pattern works for any approval gate: invoice sign-off, deployment confirmation, content moderation, customer escalation. In the AI employee we built for Telegram groups, every CRM change waits for a manager to approve it in the chat. The key architectural point is that the callback data encodes enough context to act without a database roundtrip. Pack the job ID, the action and any parameters into the string. Keep it under 64 bytes (Telegram's limit) and you rarely need to look anything up.

Group and conference automation

A bot added to a group receives every message unless configured otherwise. That makes groups a useful surface for lightweight automation: auto-tagging support tickets, routing questions to the right sub-group, summarising long threads on demand, or firing a webhook when a specific phrase appears.

One pattern that works well for distributed teams: a bot listens for /standup in a group, collects replies for 15 minutes, formats them and posts a structured summary to a dedicated channel. No standup app, no separate tool and no integration to maintain: it runs entirely in a 120-line TypeScript file. After an event, our Conference CRM reads the chats from the conference's dates and builds a follow-up list from them.

Group scraping for market signal

Large public Telegram groups, such as industry channels, trading rooms and community channels around your product category, carry fast signal that RSS and Twitter don't surface. An MTProto client can join those groups and stream messages into a local database. A simple keyword filter combined with a scoring model can surface relevant posts in under a second.

A practical implementation: the MTProto client writes raw messages to a SQLite table. A separate process runs on a 30-second tick, scores new rows by keyword weight plus recency, and pushes the top three items to an ops channel through the Bot API. The ops channel has an inline button per item: "Save" writes to a notes store and "Dismiss" deletes the row. Within a week you have labelled data on what matters to your team, without a manual tagging session.

One operational note: MTProto clients need to stay authenticated. Phone number verification happens once, and after that the session string persists. Store it in an environment variable on Fly.io, never in your repo.

Telegram Mini Apps as internal dashboards

Telegram Mini Apps are the most underused feature in the ecosystem. A Mini App is a React (or any JS framework) web app hosted anywhere and launched inside Telegram from a button in any bot message. It gets a verified user identity from the Telegram SDK, so you know who opened it without building auth. The SDK passes an initData string you verify server-side with an HMAC against your bot token, and that is your entire authentication layer.

A concrete use: a CRM lookup tool for a sales team. The bot posts a lead notification with a "View profile" button that opens a Mini App. The Mini App calls an internal API with the verified user ID, pulls the lead's full record and renders a mobile card: contact history, deal stage, last activity and a one-tap "Assign to me" action. There is no separate mobile app, no login screen and no App Store submission. Deploying a Mini App means publishing a static site and adding its URL to a bot's menu button.

// Server-side: verify initData before trusting user identity
import { createHmac } from "crypto";

function verifyInitData(initData, botToken) {
  const params = new URLSearchParams(initData);
  const hash   = params.get("hash");
  params.delete("hash");
  const dataStr  = [...params.entries()]
    .sort(([a], [b]) => a.localeCompare(b))
    .map(([k, v]) => `${k}=${v}`)
    .join("\n");
  const secretKey = createHmac("sha256", "WebAppData").update(botToken).digest();
  const expected  = createHmac("sha256", secretKey).update(dataStr).digest("hex");
  return expected === hash;
}

This runs in about 0.1ms. Put it in a middleware in front of every endpoint the Mini App calls: one function, no dependencies beyond Node's built-in crypto, and a verified identity on every request.

Reliable memory on Fly.io

Fly.io machines can restart, and any state held only in process memory is gone when they do. The right pattern for a Telegram ops bot is a single SQLite file on a Fly volume. Volume storage persists across restarts and deploys. SQLite handles hundreds of concurrent writes per second on a single file, more than any Telegram bot will generate, and needs no infrastructure: no connection pool, no external service and no credentials to rotate.

Persistent memory lets the bot build up context over time: which alerts were dismissed, which leads were claimed, which standup entries were already summarised. That context makes the bot far more useful than a stateless one, with no extra architecture.

For bots that drive AI agents, the same volume holds the agent's memory store. The agent recalls earlier conversations, decisions and user preferences across sessions, which is what separates a useful AI assistant from one that forgets everything at every restart.

What this looks like end to end

Take a small operations team managing a content moderation queue. The stack they run on Telegram:

  • An MTProto client streams flagged content from monitored channels into a SQLite queue.
  • A Bot API bot pulls from the queue on a 60-second tick and sends the next item to the moderation group with Approve / Reject / Escalate buttons.
  • Tapping a button fires a callback, updates the queue row, calls the downstream action API and edits the original message to show who acted and when.
  • A "Stats" button in the bot menu opens a Mini App showing throughput, backlog size and per-reviewer metrics, with verified identity and no login.

The whole system runs on two Fly.io machines (one for the MTProto client, one for the Bot API service and the Mini App backend), costs under ten dollars a month and handles the team's full queue with no other tooling. It was built and shipped in under a week. The operational complexity lives in the code, not in the infrastructure.

The part most teams skip

The gap between "we have a Telegram bot" and "Telegram is our ops layer" is almost always memory and approval flows. A bot that forgets everything and can only send messages is barely more useful than a cron job that posts to Slack. Add persistent state and inline keyboards, and you have an operations tool that handles real workflows. Add a Mini App, and you have an internal product with no distribution friction.

None of this needs a large team or a long timeline. The primitives are mature, the running cost is low, and the surface your team already uses, Telegram on their phones, is already there.

Read next: Why your AI's memory stores your questions as facts (and how to stop it)

Questions about running operations on Telegram

How much does it cost to run a Telegram bot on Fly.io?

A Telegram bot on Fly.io at the smallest instance tier, with 256 MB of RAM, costs roughly two dollars a month and never sleeps. It holds state in memory, answers webhooks in under 100ms and writes to SQLite on an attached volume for anything that must survive a restart. A fuller setup on two machines, with a Mini App backend, can still cost under ten dollars a month.

What is the difference between the Telegram Bot API and MTProto?

The Telegram Bot API runs a bot account: you register it with BotFather, get a token and call methods such as sendMessage over HTTPS, and it shows in chats with a bot badge. MTProto, through Telethon, GramJS or Pyrogram, lets a real user account read the channels it belongs to and pull message history. Use the Bot API for anything user-facing and MTProto for monitoring.

Can Telegram handle approvals for a business process?

Yes. Telegram's inline keyboards attach buttons to any message, and each tap sends the bot a callback it can act on at once. An alert can carry Retry and Abort buttons, a moderation item can carry Approve, Reject and Escalate, and the bot edits the message to show who acted and when. Keep each button's callback data under Telegram's 64-byte limit.

Want Telegram running your operations?

We build Telegram bots, Mini Apps, agent integrations and Fly.io deployments. Tell us what your ops flow looks like, and we'll start with a free audit.