.agents/skills/upstash-workflow/references/examples.md
Two real workflows already in the codebase that follow this skill's pattern verbatim. Skim them when you want to see the pattern applied to concrete entities.
Use case: Generate AI-powered welcome placeholders for users.
Structure:
process-users — entry point, checks eligible userspaginate-users — paginates through active usersgenerate-user — generates placeholders for ONE userKey features:
paidOnly flag to scope to subscribed usersdryRun mode for statisticsCHUNK_SIZE=20)Layer 3 shape:
export const { POST } = serve<GenerateUserPlaceholderPayload>(async (context) => {
const { userId } = context.requestPayload ?? {};
const workflow = new WelcomePlaceholderWorkflow(db, userId);
const placeholders = await context.run('generate', () => workflow.generate());
return { success: true, userId, placeholdersCount: placeholders.length };
});
Files:
/api/workflows/welcome-placeholder/process-users/route.ts/api/workflows/welcome-placeholder/paginate-users/route.ts/api/workflows/welcome-placeholder/generate-user/route.ts/server/workflows/welcomePlaceholder/index.tsUse case: Generate welcome messages and open questions for AI agents.
Structure:
process-agents — entry point, checks eligible agentspaginate-agents — paginates through active agentsgenerate-agent — generates welcome data for ONE agentKey features:
paidOnly flag for subscribed users' agents onlydryRun mode for statisticsCHUNK_SIZE=20)Layer 3 shape:
export const { POST } = serve<GenerateAgentWelcomePayload>(async (context) => {
const { agentId } = context.requestPayload ?? {};
const workflow = new AgentWelcomeWorkflow(db, agentId);
const data = await context.run('generate', () => workflow.generate());
return { success: true, agentId, data };
});
Files:
/api/workflows/agent-welcome/process-agents/route.ts/api/workflows/agent-welcome/paginate-agents/route.ts/api/workflows/agent-welcome/generate-agent/route.ts/server/workflows/agentWelcome/index.tsBoth workflows are the same pattern — they only differ in:
Everything else — the 3-layer split, dry-run handling, fan-out, filter-existing, flowControl tuning — is identical. That's the whole point: once you internalize the pattern, adding a new workflow is mostly entity-substitution.