blackdark
Automation

Your 24/7 AI agent on a €30 TV box: Claude + Termux + Telegram bot (step by step)

How to turn an Android TV box (or an old phone) into an AI agent that runs 24/7: Termux and Termux:Boot from F-Droid, wake lock, the Claude API and a private Telegram bot that only answers you. With the prompt, the code and its limits.

By Updated on 6 min read
Jump straight to the prompt

Honest warning: UNOFFICIAL setup, not tested by us

Neither Anthropic nor Google supports running an agent on a TV box with Termux. We haven't tested it end to end on a specific box: this guide combines pieces that do exist and work on their own (Termux, Termux:Boot, wake lock, the Claude API and Telegram bots). Every Chinese box is its own world and some step may differ on yours. Take it slow and use a box you don't mind tinkering with.

A €30 Android TV box (or an old phone from your drawer) can act as an "always-on 24/7 computer" for an AI agent. The box only runs things; Claude does the thinking in the cloud. You talk to it through a private Telegram bot that only answers you, even when your laptop is off.

How it works

  1. You message the bot

    From Telegram, on your phone, wherever you are.

  2. The box picks up the message

    Termux checks Telegram every few seconds (long polling, no open ports).

  3. Claude thinks in the cloud

    The box sends the task to the Claude API and gets the answer back.

  4. You get the answer

    The bot sends it back on Telegram. Only to your chat_id.

What it's good for (and what it isn't)

YesNo
Summarizing texts, drafting, answering questionsAnything heavy: it has 2 GB of RAM
Scheduled reminders every morningAnything that needs a real browser
Small scripts you run again and againReplacing a Mac Mini: it's way slower

What you need

  • An Android TV box you own: an X96Q, H96 or similar, 4-core ARM chip, 2 GB of RAM and Android 7 or later (9+ is better). Around €25-35. Not your ISP's set-top box: it's usually locked, it belongs to them and tinkering with it may breach your contract.
  • Wi-Fi or a cable, and a USB keyboard/mouse (or the remote app on your phone) for the first steps.
  • An account on the Claude Console (platform.claude.com) with credit. The API is pay-as-you-go; it's not the Pro subscription.
  • Telegram on your phone.

Step 0: the prompt (photo + Claude)

Take a photo of the box (and of the label underneath, if it shows a model) and paste it into claude.ai with this prompt. Claude will guide you, adapted to your box:

Prompt · Turn my TV box into a 24/7 agent
This is my Android TV box (photo attached). I want to turn it into a server that runs an AI agent 24/7, even when my laptop is off. Plan:
1) Identify the model, the chip (ARM architecture, 32 or 64 bits) and the likely Android version. If you're not sure, tell me how to check it from Settings or with "uname -m" and "getprop ro.build.version.release".
2) Guide me step by step to install Termux and Termux:Boot from F-Droid (not Google Play) on THIS device, with whatever Android settings are needed (unknown sources, turning off battery optimization for Termux).
3) Make sure Android doesn't kill the process: termux-wake-lock and auto-start with Termux:Boot.
4) Write me a Telegram bot in Python with NO external dependencies (standard library only) that:
 - uses long polling (no open ports),
 - ONLY replies to my chat_id (read from an environment variable) and ignores everyone else,
 - sends my messages to the Claude API and returns the answer to me,
 - reads the keys from environment variables. NEVER ask me to paste my keys into this chat.
5) Tell me how to test it and how to check the logs if it fails.
Go step by step: give me one step, wait for me to say "done" or send the error, and continue.

Below you have the same path written out, in case you'd rather do it by hand.

Step 1: Termux and Termux:Boot from F-Droid

  1. On the box, open the browser and download F-Droid from f-droid.org. Allow installing apps from "unknown sources" when asked.
  2. From F-Droid install Termux and Termux:Boot. Both from the same place: Termux:Boot only runs scripts if it's signed with the same key as Termux, and each store signs with a different key.
  3. Open Termux:Boot once (just open it). That way Android lets it start at boot.
  4. Android Settings → Apps → Termux → Battery → Unrestricted / don't optimize.

Step 2: set up Linux inside Termux

Open Termux and type:

pkg update && pkg upgrade -y
pkg install -y python
uname -m          # aarch64 = 64-bit ARM (the usual)

Step 3: the Telegram bot

  1. In Telegram, talk to @BotFather → /newbot → give it a name. It gives you a token: don't share it.
  2. Your chat_id: send anything to your new bot and open https://api.telegram.org/bot<TU_TOKEN>/getUpdates in the browser (replace <TU_TOKEN> with your token). Look for "chat":{"id":123456789: that number is your chat_id.

Step 4: the keys, out of the code and out of the chat

Create a key in the Claude Console → API keys. Then, in Termux:

nano ~/.agente.env

Paste this with your values:

export ANTHROPIC_API_KEY="sk-ant-..."
export TELEGRAM_TOKEN="123456:ABC..."
export CHAT_ID="123456789"
export MODELO="put-the-model-id-here"

Copy the model ID from the official model list (a Haiku is the cheapest for small tasks). Save (Ctrl+O, Enter, Ctrl+X) and protect the file:

chmod 600 ~/.agente.env

Set a spending limit

In the Claude Console, under Limits, set a monthly spending cap. That way, even if something goes wrong, you won't get a nasty surprise.

Step 5: the agent (dependency-free Python)

nano ~/agente.py
import json, os, time, urllib.request

TG = f"https://api.telegram.org/bot{os.environ['TELEGRAM_TOKEN']}"
YO = int(os.environ["CHAT_ID"])
KEY, MODELO = os.environ["ANTHROPIC_API_KEY"], os.environ["MODELO"]

def post(url, data, headers=None):
    req = urllib.request.Request(url, json.dumps(data).encode(), {"Content-Type": "application/json", **(headers or {})})
    with urllib.request.urlopen(req, timeout=120) as r:
        return json.load(r)

def claude(texto):
    r = post("https://api.anthropic.com/v1/messages",
             {"model": MODELO, "max_tokens": 1500,
              "system": "You are my assistant. Clear, short answers, in English.",
              "messages": [{"role": "user", "content": texto}]},
             {"x-api-key": KEY, "anthropic-version": "2023-06-01"})
    return "".join(b.get("text", "") for b in r.get("content", [])) or "(no answer)"

offset = 0
while True:
    try:
        upd = post(f"{TG}/getUpdates", {"offset": offset, "timeout": 50})
        for u in upd.get("result", []):
            offset = u["update_id"] + 1
            msg = u.get("message") or {}
            if msg.get("chat", {}).get("id") != YO or "text" not in msg:
                continue  # only replies to you
            post(f"{TG}/sendMessage", {"chat_id": YO, "text": "Got it. Working on it."})
            post(f"{TG}/sendMessage", {"chat_id": YO, "text": claude(msg["text"])[:4000]})
    except Exception as e:
        print("error:", e)
        time.sleep(10)

Test it:

source ~/.agente.env && python ~/agente.py

Message your bot from Telegram. If it replies, it works. Ctrl+C to stop it.

Step 6: keep it awake and auto-start it

mkdir -p ~/.termux/boot
nano ~/.termux/boot/agente.sh
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
. ~/.agente.env
nohup python ~/agente.py >> ~/agente.log 2>&1 &
chmod +x ~/.termux/boot/agente.sh

Restart the box. Without opening anything, message the bot: it should reply. If it doesn't, check the log with cat ~/agente.log. termux-wake-lock leaves a persistent Termux notification: that's normal, it's what stops Android from closing it.

Task ideas to get started

  • "Summarize this text I'm pasting."
  • "Draft 3 versions of this message for a client."
  • "Write me a script for a reel about X."
  • Reminders: install cronie (pkg install cronie) and schedule a script that runs every morning and sends you the result through the bot.

Limits and security (read this)

  • Unofficial and not tested end to end by us. If a step fails on your box, paste the error into Claude.
  • Claude Code (the terminal tool) isn't officially supported on Termux either; that's why this guide uses the API directly.
  • Cost: every message spends API tokens. Spending limit set = peace of mind.
  • Keys: only in ~/.agente.env, on the box. Never in the chat with Claude, never in screenshots, never on GitHub.
  • Privacy: what you send the bot goes through Telegram and the Anthropic API. Don't send it sensitive data.
  • If you sell or give away the box: delete Termux (or factory reset) and revoke the API key and the bot token.

Checklist

  • A TV box you own (or an old phone) with Android 7 or later.
  • Termux and Termux:Boot installed from F-Droid, and Termux:Boot opened once.
  • Termux with battery optimization off.
  • Bot created with @BotFather and your chat_id noted down.
  • Keys in ~/.agente.env with chmod 600 and a spending limit set.
  • The bot replies after restarting the box.

FAQ

No. Neither Anthropic nor Google supports running an agent on a TV box with Termux, and we haven't tested it end to end on a specific box. Every box is different: if a step fails, paste the error into Claude.

The box, around €25-35. Termux, Termux:Boot and Telegram are free. The Claude API is pay-as-you-go (per token) and separate from the Pro subscription. With short messages and a small model the cost is low, but set a limit in the console.

Yes, same as the box: Android 7 or later and plugged into power. Turn off battery optimization for Termux.

No. It's usually locked, it belongs to your provider and tinkering with it may breach your contract. Use a TV box you own.

Claude Code on Termux isn't officially supported. This guide uses the API directly with a dependency-free Python script so it doesn't rely on that.

The bot ignores anyone who isn't your chat_id and opens no ports. The keys live only in a file on the box with 600 permissions. What you send goes through Telegram and the Anthropic API, so don't send it sensitive data.

Keep digging into the same topic.

Share
Newsletter

Get the next guides in your inbox

AI and marketing ideas and resources, no filler. What works and how to apply it.

Ideas and resources, no spam. Unsubscribe anytime.

Finding this guide useful?

Subscribe