bitarch.dev
AI Architecture

Zero-Prompt Telegram AI Bot With Your Flat-Rate CLI Plan

How I ditched expensive API keys and flaky browser proxies to build a "Reactive Wake-Up" personal AI assistant.

Dhruba Baishya
Dhruba Baishya
Software Engineer
Jul 14, 2026
8 min read

A couple of months ago, I wanted to build personal AI automations. Like many developers, I started by exploring open-source coding agents—specifically OpenClaw. It was great, but I quickly hit a roadblock: the cost.

Running autonomous agents on usage-based developer APIs gets expensive fast. A single complex task could eat up dollars in tokens, making continuous background automation financially impractical.

I looked for alternatives. I already pay for flat-rate consumer Pro subscriptions (like Claude Pro and Gemini Advanced), so I thought, why not bridge that into a headless CLI agent? It turns out, doing this is highly unstable. Attempting to hook these tools into consumer plans usually relies on hacky browser proxies that break whenever the UI updates, or requires running clunky desktop GUI apps instead of a clean terminal server.

I was stuck between paying high API fees or maintaining fragile hacks. Then, I realized there was a much better way: a "Reactive Wake-Up" architecture.

The Hidden Danger: Account Suspensions

Beyond just the fragility of browser proxies, there is a much more severe risk. Users who attempt to use unauthorized open-source agents (like OpenClaw) to automatically spoof consumer Gemini Advanced subscriptions or other flat-rate plans have faced devastating consequences.

Google's systems actively flag these automated heartbeat requests as Terms of Service violations. Developers attempting this were getting their entire Google accounts suspended—losing access to their Gmail, Drive, and Photos permanently.

This is why the "Reactive Wake-Up" architecture is a safer route. Because it runs natively inside the officially sanctioned Antigravity CLI environment, there is no unauthorized spoofing, no TOS violations, and no risk of account bans.

The "Reactive Wake-Up" Architecture (Zero-Prompt)

Instead of trying to forcefully bridge consumer APIs to headless servers, I realized I already had a headless, flat-rate AI agent running on my machine: my CLI.

I call this a "zero-prompt" architecture because it operates autonomously. As the developer, you don't have to manually type any prompts into the CLI terminal to manage the bot. The incoming Telegram text natively becomes the prompt via a background lifecycle hook. The CLI intercepts it and routes it directly to the active LLM context without any manual human input.

I built a zero-prompt Telegram Bot architecture that natively hooks into my active Antigravity Pro CLI session. Because I'm already paying for a flat-rate CLI AI subscription, this approach completely bypasses API costs and lets me use the CLI's built-in agent.

The architecture is simple and relies on how the CLI manages background tasks:

  1. A lightweight Node.js background poller runs in the CLI terminal, listening for Telegram messages.
  2. When a message arrives, the poller prints the message payload and immediately exits.
  3. This unexpected exit serves as a wake-up signal to the CLI agent, which automatically reads the output to see what happened.
  4. The CLI agent natively processes the user's request, leveraging all its context, tools, and flat-rate LLM access.
  5. Finally, the agent runs a separate script to send the reply back to Telegram and restarts the poller.

This means my personal AI assistant operates with zero extra API costs, zero hacky browser proxies, and has full native access to my local machine and workspace context.

How the Poller Wakes the Agent

The core trick is a tiny ephemeral script. It uses standard polling to check for messages, but it is explicitly designed to die the moment it receives one.

// poller.js
const TelegramBot = require('node-telegram-bot-api');
const token = process.env.TELEGRAM_BOT_TOKEN;
const bot = new TelegramBot(token, { polling: true });

console.log("Listening for Telegram messages...");

bot.on('message', (msg) => {
  const chatId = msg.chat.id;
  const text = msg.text || '[Non-text message]';

  // Print payload and exit cleanly
  console.log(JSON.stringify({ chatId, text }));
  process.exit(0);
});

Because this runs as a managed background task in Antigravity, the CLI agent is notified the moment process.exit(0) fires. It reads the stdout, sees the JSON payload, and begins formulating a response using the built-in LLM—no usage-based billing required.

Why This Beats Existing Solutions

If you search around, you will find other developers attempting to hook Telegram into their AI CLIs using massive third-party tools (like the Antigravity Telegram Suite or Remoat).

The problem? These tools rely on hacky workarounds. Because they operate externally, they have to use MutationObservers or complex terminal integrations to virtually "click" or execute the Accept commands in your CLI's UI on your behalf. They are fragile and prone to breaking whenever the tool updates its interface.

Our architecture is different because it leverages the CLI's native background task manager. By using a simple 10-line script that intentionally exits, we bypass all that fragile UI-clicking. We tap directly into the exact lifecycle hook the agent is already programmed to monitor, creating a much more resilient bot.

Closing the Loop

Once the CLI agent has done the heavy lifting—whether that involves searching my local files, drafting code, or answering a question—it writes the response to a temporary file.

It then executes a dispatcher script (send-reply.js) to deliver the message back to Telegram, before quietly restarting the poller to wait for my next command.

The result? A powerful, context-aware Telegram bot that costs me exactly $0 in API fees, avoids fragile workarounds, and perfectly utilizes the development tools I already pay for.

Portability & npx skills

The best part about this architecture is that the skill orchestrating it is entirely portable.

Because we structured it using the standard `SKILL.md` format (with a YAML frontmatter block for metadata), it is natively compatible with the official npx skills package maintained by Vercel Labs. You can literally drop this skill into a public GitHub repository, and any developer using Claude Code, Cursor, or Windsurf can install it directly into their AI's harness using a simple command like npx skills add BaishyaDh/skills --skill telegram-agent-builder.

The AI (whether it is Claude or Antigravity) will read the markdown prompt and intelligently adapt the instructions to launch the background poller using whatever terminal tools it has available.

A Crucial Warning: Permissions

There is one major gotcha when running a bot natively through an AI CLI: Permissions.

By default, AI coding assistants require explicit human approval before running terminal commands or modifying files. If you ask your Telegram bot a question and the AI tries to run the send-reply.js script to answer you, but lacks permission, the session will get stuck. The bot will appear completely broken and unresponsive on Telegram while it sits endlessly in your CLI waiting for you to click "Approve".

During the initial phases of using this architecture, you must carefully monitor the CLI. When prompted, you need to explicitly select the "Allow anytime" or "Always allow for this directory" options for the poller and reply scripts. Once you grant the agent autonomous permission to run its core loop, the bot will run seamlessly in the background. However, for security reasons, always be extremely careful and selective—only grant perpetual "run anytime" permissions to the specific, trusted scripts required for the bot, and maintain manual oversight for everything else.

The Skill

The full source code for the telegram-agent-builder skill is available in my public registry. You can read the raw instruction template on GitHub.

To install and run the bot builder directly into your AI CLI (whether it's Claude Code, AutoGPT, or Antigravity), simply run the following command in your terminal:

npx skills add BaishyaDh/skills --skill telegram-agent-builder

Read More from the Author

NX Monorepos: One Repo, CI That Keeps Up

How NX's dependency graph makes CI smarter — running only what changed, catching downstream breakage automatically, and keeping hook times short as the repo grows.

The Technical Debt of AI Speed

AI helps us ship faster than ever, but it's also creating a new kind of technical debt. Here is how to manage the speed without losing quality.