scheduled-agent-report
Run an agent prompt on a cron schedule and surface its output in the app (daily digests, weekly reports)
Plane: data_pattern · Requires: capability data_access
Steps:
1. useAutomations — create({ name, prompt, schedule: '0 8 1-5', target_agents, output_config }) — 5-field Unix cron via EventBridge; output types: silent | email | webhook | file.
2. useAgent — Write the automation prompt to end with a structured collection write (same discipline as reason-write-read) so the app can render results.
3. useCollection — Read the report collection reactively; each run appends a new doc.
Examples
import { useAutomations, useCollection } from '@flowstack/sdk';
export function DailyDigest() {
const { automations, create, pause, resume } = useAutomations();
const digest = automations.find(a => a.name === 'daily-digest');
const { documents: reports } = useCollection('daily_reports', {
sort: { run_at: -1 },
limit: 7,
});
return (
<>
{!digest && (
<button
onClick={() =>
create({
name: 'daily-digest',
prompt:
'Summarize yesterday\'s rows in the transactions collection and insert ' +
'one doc into daily_reports: {summary, total, run_at (ISO)}.',
schedule: '0 8 * * *',
output_config: { type: 'silent' },
})
}
>
Enable daily digest
</button>
)}
{digest && (
<button onClick={() => (digest.status === 'paused' ? resume(digest.id) : pause(digest.id))}>
{digest.status === 'paused' ? 'Resume' : 'Pause'}
</button>
)}
{reports.map(r => <article key={r._id}>{r.summary}</article>)}
</>
);
}
See also
reason-write-read · useAutomations · useCollection · casino_create_automation
Source: sync-recipes.mjs ← https://sage-api.flowstack.fun/recipes.json · Also available in llms-full.txt and registry.json.