Alfred, an assistant that lives in Telegram
I'm in school full time and running a business around it, so my day is split across a class timetable, client work, things I'm trying to learn and things I promised people. Alfred is the one place all of it lands. He is a Telegram bot, because Telegram is already open on my phone, and he is a single serverless function, because I wanted him always on without a server to look after.
Architecture
One Cloudflare Worker handles everything. It has no long-running process and holds nothing in memory between requests. State lives in D1, Cloudflare's SQLite database, and each request reads what it needs, acts, and writes back.
| Entry point | What arrives |
|---|---|
POST /telegram | Every message I send, and messages in the work group chats he sits in |
/instagram | Reels and posts sent to his own Instagram account by direct message |
POST /api | Tasks, reminders and status from a command-line tool, with a bearer token |
POST /api/file | A file from my computer, delivered to my phone (up to 50 MB) |
| Cron, every minute | Due reminders, the morning report, the weekly learning list |
The morning report
Each morning Alfred sends one message: the priority of the day, my schedule, what I'm learning this week, where the business stands and the open tasks. He never picks the priority. I set it the night before, and he repeats it back to me first thing.
The learning list is stored as a queue, not a calendar. Marking something done ticks off the next unfinished item, so working ahead moves everything forward and the report can say how far ahead or behind plan I am. Ticking by name uses fuzzy matching, so a message full of typos still finds the right items.
Everything feeds him
The part I use most is the least visible. Every coding session on my computer can write to Alfred through a small command-line tool. When a deadline or a follow-up comes up while I'm building something, it is added there and then, and it shows up in the next morning's report without me copying it anywhere.
alfred task "Send the revised proposal" --due 2026-11-20
alfred remind 2026-11-23T09:00 "Science fair registration closes Feb 19"
alfred status "Three pilots running. Next decision: which track to keep."
The inbox
I save a lot of reels and links with a half-formed thought attached, and then never look at them again. Now I send them to Alfred. The order of operations matters: he saves the item first, so nothing is lost if a later step fails, and only then does the slower work.
-- one row per saved item
CREATE TABLE inbox (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source TEXT NOT NULL, -- instagram | telegram | cli
url TEXT,
media_url TEXT, -- direct media link; expires
note TEXT, -- what I wrote with it
transcript TEXT, -- what is said in the video
project TEXT,
kind TEXT, -- ad idea | content idea | reference | to learn | tool
summary TEXT,
next_step TEXT,
done_at TEXT,
created_at TEXT NOT NULL
);
Two small details made it feel right. A link sent within two minutes of a thought is merged into the same item instead of creating two, because that is how people actually send things. And the filing step is given my list of projects and must answer in a fixed JSON schema, so the result is always a valid project, a kind from the list, a summary and a next step.
Keeping a small model honest
Most of what Alfred does is fixed code with no model involved: commands, reminders, the report layout. Open questions go to Llama 3.3 70B on Cloudflare's free daily allowance, and transcription goes to Whisper large v3 turbo. Running on a free model taught me more than a paid one would have.
- Examples get copied. If the prompt contains an example reminder, the model saves that example. Describing the format with placeholders fixed it.
- The model never acts directly. It returns a reply and a list of proposed actions as structured JSON. Code checks each one (is the date real, does the task exist, is it a duplicate) and only then writes to the database.
- Broken output has to be survivable. On messy input the model sometimes looped or returned invalid JSON, so the reply is salvaged where possible and repeated actions are removed.
// what the model is allowed to return
{
"reply": "Done. I'll remind you Monday at 9.",
"actions": [
{ "type": "reminder", "at": "2026-11-23T09:00", "text": "…" }
]
}
Next
Alfred is being rebuilt as a layer that connects everything I work in. Telegram stays as the phone channel. On the computer, the plan is a menu-bar app, so he is one click away while I work.