Build your own podcast digest agent
Every morning I get one email with the new episodes of the podcasts I follow, each boiled down to a few paragraphs. Every point has a timestamp, and clicking it plays the episode from that moment. It's one agent and one tool on Blue Leaf, and this post has everything you need to build your own: the code, the prompt and the setup steps.
It's meant as a starting point. Change the prompt to cover what you care about, swap the email service, restyle the email: it's all yours once it's in your account.
How it works
graph LR
S[Schedule, daily] --> A[Digest agent]
A -->|new| T[podcast_digest tool]
T -->|RSS| F[Podcast feeds]
T -->|audio URL| R[Whisper on Replicate]
A -->|one per show| B[Same agent, summarize mode]
B -->|transcript, save_summary| T
A -->|send| T
T -->|email| E[Resend]
- A schedule wakes the agent once a day.
- The tool reads each show's RSS feed. For every show with a new episode, it asks Replicate to transcribe the audio with Whisper. A one-hour episode takes about a minute.
- The agent hands each episode to a copy of itself in "summarize" mode. That copy reads one transcript, writes the summary and saves it. One transcript per run keeps each model call small, so a long list of shows never overflows the model's context.
- The tool puts the summaries into one email and sends it. Only then does it mark those episodes as done, so a failed run is picked up the next day.
Podcast feeds are free, and most don't include transcripts, which is why the audio goes through Whisper. At the time of writing that costs a few cents per hour of audio on Replicate. The rest of the cost is your model's tokens for reading the transcripts.
What you need
- A Replicate account and API token (replicate.com, under API tokens).
- A Resend account and API key (resend.com). The free plan is enough. Until you verify a domain of your own, Resend only sends to the address you signed up with, which is all a personal digest needs.
- An API key for the model your agent will run on, from Anthropic, OpenAI, OpenRouter or any OpenAI-compatible provider.
Step 1: Add your secrets
On the Secrets page, add:
| Name | Value |
|---|---|
REPLICATE_API_TOKEN |
your Replicate token |
RESEND_API_KEY |
your Resend key |
ANTHROPIC_API_KEY |
your model key (use whatever name fits your provider) |
Tools read secrets by name, and agents reference them by name, so no key is ever pasted into code or a prompt.
Step 2: Create the agent
On the Agents page, create an agent called Podcast Digest. Paste this as its prompt, and rewrite the "About me" section to match your interests:
# Podcast Digest
You send a daily email digest of the podcasts I follow. The shows are in `/workspace/podcasts/podcasts.json`. You work through the `podcast_digest` tool, called with `Run_tool`.
## About me
<!-- Edit this section: it decides what the summaries focus on. -->
I'm interested in technology, AI and business. Cover those topics in detail: the specific claims, numbers, companies and people. Skip politics; if an episode is mostly politics, give it one or two sentences.
## Daily run (any message that doesn't start with "Summarize:")
1. Call `podcast_digest` with `{"action":"new"}`. It returns `shows` (each has a new episode being transcribed), `errors` and `agent_id` (your own id).
2. If `shows` is empty, reply "No new episodes" plus any errors, and stop.
3. For each show, one at a time, call `Invoke_Agent` with `agentId` set to `agent_id` and the prompt `Summarize: <show name>`, using the name exactly as returned.
4. Call `podcast_digest` with `{"action":"send"}`. This step is required: it emails the digest and marks the episodes as sent.
5. Reply with a short report: episodes sent, shows that failed, feed errors.
If a show fails, move on. It will be picked up again on the next run.
## Summarize mode (message starts with "Summarize:")
1. Call `podcast_digest` with `{"action":"transcript","show":"<show name>"}`. If it says the episode is still transcribing, call it once more.
2. Write the summary as the HTML fragment below.
3. Call `podcast_digest` with `{"action":"save_summary","show":"<show name>","html":"<your HTML>"}`. This step is required.
4. Reply with one line: the show name and "saved", or the error.
Leave out ads and sponsor reads. Return HTML with inline styles only, no markdown:
<div style="margin:24px 0;padding:20px;border:1px solid #e5e7eb;border-radius:8px">
<div style="font-size:13px;color:#6b7280;text-transform:uppercase">SHOW NAME</div>
<h2 style="margin:4px 0 12px;font-size:19px">EPISODE TITLE</h2>
<p style="margin:0 0 12px">TWO OR THREE SENTENCE OVERVIEW</p>
<ul style="margin:0;padding-left:20px">
<li style="margin-bottom:8px">[MM:SS] A KEY POINT, WITH SPECIFICS</li>
</ul>
</div>
Write 3–6 key points. Start each with the time from the transcript where it's discussed, in square brackets, e.g. [12:30].
## Changing the show list
When I ask to add or remove a show, edit `/workspace/podcasts/podcasts.json` with `Execute_Code`. Each show is `{"name": "...", "rss": "...", "last_guid": null}`. To find a show's RSS feed, look it up with the iTunes Search API (itunes.apple.com/search, with media set to podcast and term set to the show name) and use the `feedUrl` of the matching result.
For its settings, use your provider and model. This example uses Claude:
{
"provider": "claude",
"model": "claude-sonnet-4-6",
"apiKey": "ANTHROPIC_API_KEY",
"mcpServers": {
"blle": { "type": "url", "url": "https://api.blle.co/mcp" }
}
}
The mcpServers entry gives the agent your tools. It needs no API key: an agent running on Blue Leaf reaches your own MCP server as you. For an OpenAI-compatible provider, set "provider": "openai-compatible", add its baseURL, and use that provider's model id and key name.
Step 3: Install the tool
The tool holds the code that doesn't need a model: reading feeds, starting and collecting transcriptions, putting the email together and remembering what was sent. Tools on Blue Leaf are TypeScript that runs in a sandbox, and you create them through the Create_Tool tool.
The easiest way is to open a chat with your new agent and send it: "Create a tool named podcast_digest with the description 'Daily podcast digest: new, transcript, save_summary, send, status' and exactly this code:", followed by the code below. If you've set up an admin agent, you can ask it instead; it can also create the Podcast Digest agent and the schedule for you. Claude Desktop or Claude Code connected to Blue Leaf's MCP server works the same way.
// podcast_digest — a daily podcast digest pipeline.
// Episodes come from each show's RSS feed, transcripts from Whisper on
// Replicate, summaries from your agent, and the email goes out through Resend.
//
// Secrets: REPLICATE_API_TOKEN, RESEND_API_KEY
// Data: /workspace/podcasts/podcasts.json (your email + the shows you follow)
const DIR = "/workspace/podcasts";
const CONFIG = `${DIR}/podcasts.json`;
const PENDING = `${DIR}/pending.json`;
const PLAYER = "/workspace/public/podcasts/player.html"; // optional, see the article
const EPISODES = "/workspace/public/podcasts/episodes";
const WHISPER = "c6433aab18b7318bbae316495f1a097fc067deef7d59dc2f33e45077ae5956c7"; // vaibhavs10/incredibly-fast-whisper
let fs;
const readJson = async (p, dflt) => ((await fs.exists(p)) ? JSON.parse(await fs.read(p)) : dflt);
const writeJson = (p, v) => fs.write(p, JSON.stringify(v, null, 2));
const replicate = () => ({ Authorization: `Bearer ${Deno.env.get("REPLICATE_API_TOKEN")}`, "Content-Type": "application/json" });
// Swap this out to send through a different email service.
async function sendEmail({ from, to, subject, html }) {
const res = await fetch("https://api.resend.com/emails", {
method: "POST",
headers: { Authorization: `Bearer ${Deno.env.get("RESEND_API_KEY")}`, "Content-Type": "application/json" },
body: JSON.stringify({ from, to, subject, html }),
});
if (!res.ok) throw new Error(`Resend HTTP ${res.status}: ${await res.text()}`);
}
const tag = (xml, name) => {
const m = xml.match(new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`, "i"));
return m ? m[1].replace(/^<!\[CDATA\[|\]\]>$/g, "").trim() : null;
};
async function latestEpisode(rss) {
const res = await fetch(rss, { headers: { "User-Agent": "Mozilla/5.0 podcast-digest" }, signal: AbortSignal.timeout(20000) });
if (!res.ok) throw new Error(`feed HTTP ${res.status}`);
const item = (await res.text()).split(/<item[\s>]/i)[1];
if (!item) throw new Error("feed has no episodes");
const audio = item.match(/<enclosure[^>]*url="([^"]+)"/i)?.[1]?.replace(/&/g, "&");
const title = tag(item, "title");
return { guid: tag(item, "guid") || audio || title, title, audio, link: tag(item, "link"), published: tag(item, "pubDate") };
}
async function startTranscription(audio) {
const res = await fetch("https://api.replicate.com/v1/predictions", {
method: "POST",
headers: replicate(),
body: JSON.stringify({ version: WHISPER, input: { audio, task: "transcribe", language: "english", timestamp: "chunk", batch_size: 24 } }),
});
const p = await res.json();
if (!res.ok) throw new Error(`Replicate HTTP ${res.status}: ${p.detail ?? JSON.stringify(p)}`);
return p.id;
}
const clock = (s) => {
s = Math.floor(s);
const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), x = String(s % 60).padStart(2, "0");
return h ? `${h}:${String(m).padStart(2, "0")}:${x}` : `${m}:${x}`;
};
export async function run(context) {
fs = context.fs;
const action = context.action || "status";
const config = await readJson(CONFIG, { shows: [] });
const pending = await readJson(PENDING, { episodes: {} });
const find = (show) => {
const key = Object.keys(pending.episodes).find((k) => k.toLowerCase() === String(show || "").toLowerCase());
if (!key) throw new Error(`No pending episode for "${show}". Pending: ${Object.keys(pending.episodes).join(", ") || "none"}`);
return pending.episodes[key];
};
// Check every feed; start transcribing each show's new latest episode.
if (action === "new") {
const cutoff = Date.now() - (config.max_age_days ?? 7) * 864e5;
const errors = [];
await Promise.all(config.shows.map(async (s) => {
try {
const ep = await latestEpisode(s.rss);
if (ep.guid === s.last_guid) return;
if (ep.published && Date.parse(ep.published) < cutoff) return;
if (!ep.audio) throw new Error("latest episode has no audio file");
if (pending.episodes[s.name]?.guid === ep.guid) return; // already started
pending.episodes[s.name] = { ...ep, show: s.name, prediction: await startTranscription(ep.audio), summary: null };
} catch (e) {
errors.push(`${s.name}: ${e.message}`);
}
}));
await writeJson(PENDING, pending);
// agent_id lets the calling agent hand each show to itself as a sub-agent.
return { shows: Object.keys(pending.episodes), errors, agent_id: context.caller?.agentId ?? null };
}
// One episode's transcript, a paragraph per minute, each led by [mm:ss].
if (action === "transcript") {
const ep = find(context.show);
const t0 = Date.now();
let p;
for (;;) {
p = await (await fetch(`https://api.replicate.com/v1/predictions/${ep.prediction}`, { headers: replicate() })).json();
if (["succeeded", "failed", "canceled"].includes(p.status) || Date.now() - t0 > 45000) break;
await new Promise((r) => setTimeout(r, 5000));
}
// Some podcast hosts refuse Replicate's downloader: fetch the audio here,
// upload it to Replicate, and transcribe that copy instead.
if (p.status === "failed" && /403|Forbidden/i.test(String(p.error)) && !ep.uploaded) {
const audio = await fetch(ep.audio, { headers: { "User-Agent": "Mozilla/5.0 podcast-digest" } });
if (!audio.ok) throw new Error(`audio download HTTP ${audio.status}`);
const form = new FormData();
form.append("content", await audio.blob(), "episode.mp3");
const up = await fetch("https://api.replicate.com/v1/files", { method: "POST", headers: { Authorization: replicate().Authorization }, body: form });
const file = await up.json();
if (!up.ok) throw new Error(`Replicate upload HTTP ${up.status}: ${JSON.stringify(file)}`);
ep.prediction = await startTranscription(file.urls.get);
ep.uploaded = true;
await writeJson(PENDING, pending);
return { show: ep.show, status: "processing", message: "re-uploaded the audio; try again in a minute" };
}
if (p.status === "failed" || p.status === "canceled") return { show: ep.show, status: p.status, error: p.error ?? p.status };
if (p.status !== "succeeded") return { show: ep.show, status: p.status, message: "still transcribing; try again in a minute" };
const paras = [];
let cur = null;
for (const c of p.output?.chunks ?? []) {
const start = c.timestamp?.[0] ?? 0;
if (!cur || start - cur.start >= 60) paras.push((cur = { start, text: [] }));
cur.text.push(c.text.trim());
}
return {
show: ep.show, title: ep.title, published: ep.published, link: ep.link,
transcript: paras.map((x) => `[${clock(x.start)}] ${x.text.join(" ")}`).join("\n"),
};
}
if (action === "save_summary") {
if (!context.html) throw new Error("html is required");
find(context.show).summary = context.html;
await writeJson(PENDING, pending);
return { saved: true };
}
// Email every saved summary in one digest, then mark those episodes sent.
if (action === "send") {
const done = Object.values(pending.episodes).filter((e) => e.summary);
if (!done.length) return { sent: false, reason: "no summaries saved" };
if (!config.email) throw new Error(`Set "email" in ${CONFIG}`);
// With the player page installed, each [mm:ss] becomes a link that plays
// the episode from that moment.
const player = (await fs.exists(PLAYER)) ? (await fs.stat(PLAYER)).url : null;
if (player) {
for (const e of done) {
const digest = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(e.guid));
const key = [...new Uint8Array(digest)].slice(0, 5).map((b) => b.toString(16).padStart(2, "0")).join("");
await fs.write(`${EPISODES}/${key}.json`, JSON.stringify({ show: e.show, title: e.title, audio: e.audio, link: e.link, published: e.published }));
e.summary = e.summary.replace(/\[(\d{1,2}(?::\d{2}){1,2})\]/g, (_, ts) => {
const secs = ts.split(":").reduce((a, n) => a * 60 + Number(n), 0);
return `<a href="${player}?e=${key}&t=${secs}" style="font-weight:600;text-decoration:none;white-space:nowrap">▶ ${ts}</a>`;
});
}
}
const date = new Date().toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric" });
const html = `<div style="max-width:640px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;line-height:1.6">
<h1 style="font-size:22px;margin:0 0 4px">Your podcast digest</h1>
<div style="color:#6b7280;font-size:14px">${date} · ${done.length} episode${done.length > 1 ? "s" : ""}</div>
${done.map((e) => e.summary).join("\n")}</div>`;
await sendEmail({ from: config.from || "Podcast Digest <[email protected]>", to: config.email, subject: `Podcast digest — ${date}`, html });
for (const e of done) {
const s = config.shows.find((x) => x.name === e.show);
if (s) s.last_guid = e.guid;
delete pending.episodes[e.show];
}
await writeJson(CONFIG, config);
await writeJson(PENDING, pending);
return { sent: true, episodes: done.map((e) => e.show), unsummarized: Object.keys(pending.episodes) };
}
return { pending: Object.values(pending.episodes).map((e) => ({ show: e.show, title: e.title, summarized: !!e.summary })) };
}
Things you might change:
sendEmailis the only part tied to Resend. Replace its body to send through another service.max_age_daysin your config skips episodes older than that, so a show that's gone quiet doesn't send you a months-old episode on the first run.languageinstartTranscriptionis set to English. Whisper handles many languages; change it or remove it to let Whisper detect the language.- The email's look is the
htmltemplate inside thesendaction.
Step 4: Add your shows
Create /workspace/podcasts/podcasts.json. You can ask your agent to do it ("follow Hard Fork, The Daily and Acquired, and send the digest to [email protected]"). It finds each show's RSS feed and writes the file. Or write it yourself:
{
"email": "[email protected]",
"from": "Podcast Digest <[email protected]>",
"max_age_days": 7,
"shows": [
{ "name": "Hard Fork", "rss": "https://feeds.simplecast.com/l2i9YnTd", "last_guid": null },
{ "name": "The Daily", "rss": "https://feeds.simplecast.com/54nAGcIl", "last_guid": null }
]
}
last_guid is how the tool remembers the last episode it sent; leave it null for a new show. To use your own domain in from, verify the domain in Resend first.
Step 5: Optional, the timestamp player
Each summary point starts with the time it comes up, like [12:30]. If you add a small player page, the tool turns those times into links that play the episode from that point. Save this file as /workspace/public/podcasts/player.html. You can ask your agent to save it, or upload it on the Files page. The colours are variables at the top.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<title>Podcast player</title>
<style>
/* Change these to restyle the page. */
:root {
--bg: #ffffff; --surface: #f8f9fa; --border: #dee2e6; --text: #212529; --muted: #6c757d;
--accent: #2563eb; --on-accent: #ffffff; --link: #1d4ed8; --header: #111827; --header-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
:root { --bg: #212529; --surface: #343a40; --border: #495057; --text: #dee2e6; --muted: #adb5bd; --link: #93c5fd; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
header { background: var(--header); color: var(--header-text); padding: 14px 16px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
main { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.show { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
h1 { font-size: 22px; line-height: 1.3; margin: 4px 0 4px; }
.date { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.start { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; border: 0; border-radius: 10px;
background: var(--accent); color: var(--on-accent); font: 600 17px/1 inherit; padding: 16px; cursor: pointer; }
.start:focus-visible, .ctl button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
audio { width: 100%; margin-top: 16px; }
.ctl { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ctl button { flex: 1; min-width: 64px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
border-radius: 8px; padding: 10px 8px; font: 500 15px/1 inherit; cursor: pointer; font-variant-numeric: tabular-nums; }
a { color: var(--link); }
.foot { margin-top: 20px; font-size: 14px; }
.err { color: var(--muted); }
</style>
</head>
<body>
<header>Podcast digest</header>
<main id="app"><p class="err">Loading…</p></main>
<script>
(async () => {
const app = document.getElementById("app");
const q = new URLSearchParams(location.search);
const key = (q.get("e") || "").replace(/[^a-f0-9]/g, "");
const t = Math.max(0, parseInt(q.get("t") || "0", 10) || 0);
const fmt = (s) => { s = Math.floor(s); const h = Math.floor(s / 3600), m = Math.floor(s % 3600 / 60), x = String(s % 60).padStart(2, "0"); return h ? `${h}:${String(m).padStart(2, "0")}:${x}` : `${m}:${x}`; };
const esc = (s) => String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]));
let ep;
try {
const r = await fetch(`episodes/${key}.json`);
if (!r.ok) throw new Error();
ep = await r.json();
} catch {
app.innerHTML = '<p class="err">This episode link has expired or is invalid.</p>';
return;
}
document.title = `${ep.title} — ${ep.show}`;
const date = ep.published ? new Date(ep.published).toLocaleDateString(undefined, { month: "long", day: "numeric", year: "numeric" }) : "";
app.innerHTML = `
<div class="show">${esc(ep.show)}</div>
<h1>${esc(ep.title)}</h1>
<div class="date">${esc(date)}</div>
<div class="card">
<button class="start" id="start">▶ Play from ${fmt(t)}</button>
<audio id="au" controls preload="metadata" src="${esc(ep.audio)}#t=${t}"></audio>
<div class="ctl">
<button data-skip="-15">−15s</button>
<button data-skip="30">+30s</button>
<button id="rate">1×</button>
</div>
</div>
${ep.link ? `<p class="foot"><a href="${esc(ep.link)}" rel="noopener">Episode page</a></p>` : ""}`;
const au = document.getElementById("au");
const start = document.getElementById("start");
let seeked = false;
const seek = () => { if (!seeked && au.duration) { au.currentTime = Math.min(t, au.duration - 1); seeked = true; } };
au.addEventListener("loadedmetadata", seek);
start.addEventListener("click", async () => {
seek();
try { await au.play(); } catch {}
seek();
start.hidden = true;
});
au.addEventListener("play", () => { start.hidden = true; });
document.querySelectorAll("[data-skip]").forEach((b) => b.addEventListener("click", () => { au.currentTime = Math.max(0, au.currentTime + Number(b.dataset.skip)); }));
const rates = [1, 1.25, 1.5, 2];
document.getElementById("rate").addEventListener("click", (ev) => {
au.playbackRate = rates[(rates.indexOf(au.playbackRate) + 1) % rates.length];
ev.currentTarget.innerHTML = `${au.playbackRate}×`;
});
})();
</script>
</body>
</html>
Files under /workspace/public can be opened by anyone with the link. The player stores only each episode's title and public audio address, never the transcript or your summary.
Step 6: Test it, then schedule it
In a chat with the agent, send "Run the daily digest." It reports which shows it summarized, and the email arrives a few minutes later. On the first run every show with an episode in the last week counts as new, so expect a long first email.
When you're happy with it, add a schedule on the Schedules page: pick the agent, use the prompt Run the daily digest., and a cron time such as 0 6 * * * (6:00 every day, Central time).
Making it yours
All of the behaviour lives in two places you control:
- The prompt decides what gets summarized and how. Ask for more detail on some topics, a short TL;DR at the top, or a different structure.
- The tool decides where episodes come from and where the digest goes. Point
sendEmailsomewhere else, change the email template, or havesendsave the digest as a file in your workspace.
You can ask the agent to make these changes for you. Its prompt and settings are files in /workspace/agents/, and every saved version is kept, so it's easy to go back.
For the details of agent settings, tools, schedules and secrets, see the platform docs. They're also one Markdown file at https://www.blle.co/docs.md, kept current: give that URL to your agent when you ask it to change something, and it will work from the latest reference.