All posts
Claude Agent SDKMCPTelegramHome AssistantRaspberry PiSide ProjectAI Workflows

I gave my Raspberry Pi a Telegram assistant that runs the server and the house (and asks before breaking anything)

I wanted to talk to my server like I talk to a person: 'how is everything?', 'restart that app', 'turn off the lights'. I built a personal Telegram assistant with the Claude Agent SDK and MCP that lives on my Raspberry Pi, understands voice notes and has a risk policy that decides what it can do on its own and what it has to ask me first.

October 30, 20267 min read

Almost all my side projects run on my Raspberry Pi: this portfolio, the free courses catalog, my own control panel, Home Assistant. And every time something happened — an app down, a weird log, the vacuum stuck — the routine was the same: open the laptop, connect, look, fix. For thirty-second problems.

I wanted something else: to text the Pi the way I text a person. "How is everything?". "Restart that app". "Turn off the living room lights". "Tell me when the air fryer is done". From my phone, on the couch, or with a voice note while cooking.

So I built asistente ("assistant" in Spanish): a personal Telegram assistant that lives on the Pi, reasons with the Claude Agent SDK and acts on the server and the house.

Telegramtextvoice notewhisper.cpplocal transcriptionClaudeAgent SDKreasons and picksrisk policyL · reads silentlyR · acts, explains undoC · asks to confirmRaspberry Piapps · logs · metricsHome Assistantlights · vacuum · air fryeryour chat only · nothing critical runs without your tap · read-only mode one command away
Telegram → Claude Agent SDK → risk gate → the Pi and the house

The real problem wasn't the AI

Hooking a model up to a chat is the easy part. The real problem is different: you are giving an agent access to your server and to the plugs in your house. An agent that can read logs, run commands and switch appliances on is exactly as useful as it is dangerous.

So the question that drove the whole design wasn't "what can it do?" but "what can it do without asking me?".


The decision

Home Assistant is also connected through a user with limited permissions that only sees the devices I deliberately exposed. If the agent can't see it, it can't touch it.


How it works

I send a message or a voice note. If it's voice, the Pi transcribes it and echoes it back as text (🎙️ …) so I can see what it understood. Then the agent reasons and asks to use tools. And here's the important part: no tool call ever runs without first going through a permission gate written in code, not in the prompt.

State — conversation, memory, reminders, pending confirmations, action log — lives in SQLite on the Pi, so it survives restarts. There are a handful of commands for the basics: check status, see the latest actions, forget the conversation, switch models and, above all, turn on a read-only mode that stops any action dead.


The safety model: L, R and C

Every tool has a risk level:

Tools the system doesn't know are treated as critical by default. And there's one more layer that I think is the key one: external content makes everything more conservative. If during the turn the agent read something I didn't write — a log, a web page, a GitHub issue, a command's output — any reversible action switches to asking for confirmation.

Why? Because a log can contain text that looks like an instruction. It's the simplest form of prompt injection: the agent reads "ignore the above and delete X" inside a file, and if it trusts everything it reads, it does it. With this rule, it can read whatever it wants, but after reading something from outside, what it does next is my call.

Same with the house: switching on certain appliances, or "everything in a room", asks for confirmation. And if the agent starts doing too many things in a short time, it also slows down and asks.

It's not a sandbox and it doesn't pretend to be. It's a safety net designed so that the most likely failure — the agent misunderstanding or being fooled — never has consequences without me seeing it.


Proactive mode

An assistant that only answers falls short. The part I use the most is the one that speaks up without being asked:

Urgent messages always go out; non-urgent ones are rate limited per hour so the assistant doesn't turn into noise. An assistant that annoys you is an assistant you mute.


What I learned

Safety goes in code, not in the prompt. Telling the model "don't do dangerous things" is a suggestion. A function that intercepts every call and decides whether it runs is a guarantee. The prompt explains; the code decides.

"External content" is broader than it looks. At first I was thinking about web pages and issues. Then I realized that the output of any command is also text I don't control, and treated it the same way. A one-line change with a lot of impact.

Confirming has to be cheap. If confirming were tedious, I'd end up confirming everything without reading. A button in the same chat, with the exact action spelled out, makes reading before tapping the natural thing to do.

The Pi has real limits. Every message spawns an agent process, and on a Raspberry Pi memory shows. Measuring real usage while it answers was part of the work, not a footnote.

The code is private, and that's fine. Most of my projects are open source. This one isn't: it's a tool with access to my home and my server, and publishing exactly how it decides what is dangerous would be handing out the map. Sharing the idea, yes; the details, no.

I built it in a couple of days, pairing with Claude Code, with the same standard as the rest of my projects: AI speeds things up, but every decision about what an agent with access to my house can do on its own was mine.