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.
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.
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
- Telegram as the interface. It's already on my phone, it supports buttons, voice notes and files, and I didn't have to build an app. The bot only answers my chat: any other message is dropped and logged.
- Claude Agent SDK as the brain. I didn't want to hand-write an intent parser. The SDK gives me the agent loop — reason, pick a tool, look at the result, continue — and I focus on which tools exist and on who decides whether they get used.
- MCP as the hands. Each system exposes its capabilities as an MCP server: the Pi control panel (apps, logs, metrics, uptime), Home Assistant (lights, plugs, vacuum, air fryer, lists) and GitHub. The agent doesn't know how an app is restarted; it knows there is a tool for it.
- Everything local. Voice notes are transcribed on the Pi itself with whisper.cpp. The audio never leaves the house; the model only gets the text.
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:
- L — read. Runs silently. Checking the Pi's status, looking at metrics, searching the web, reading a file. Asking breaks nothing.
- R — reversible. Runs and tells you how to undo it. "I put the portfolio in maintenance mode; to go back, tell me 'take it out of maintenance'". If it does something, you know how to roll it back.
- C — critical. Doesn't run. You get a message with Confirm / Cancel buttons, and if you don't tap anything within a few minutes, it expires. Anything irreversible, or anything that touches something delicate, always goes through your finger.
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:
- Reminders. "Remind me in 20 minutes to take the laundry out" and 20 minutes later the reminder arrives.
- Daily summary. Every morning: how the Pi is doing, which apps went down in the last 24 hours, the vacuum and its consumables, today's reminders and whether the backup went fine. Generated without a model, from real data.
- App outages. If an app fails two checks in a row, a 🔴 arrives and the agent starts a diagnosis on its own: it looks at logs and metrics and, if a restart would fix it, proposes one… with buttons, because it read logs. When it's back, a 🟢 arrives with how long it was down.
- Home notices. The air fryer is done, the vacuum got stuck, the filter is running low.
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.