Loading...
Loading...
Create, debug, or modify Vercel WDK workflows for data updates and social media posting in the web application. Use when adding new automated jobs, fixing workflow errors, or updating scheduling logic.
npx skill4agent add sgcarstrends/sgcarstrends workflow-managementapps/web/src/workflows/apps/web/src/workflows/
├── cars.ts # Car registration data workflow
├── coe.ts # COE bidding data workflow
├── deregistrations.ts # Deregistration data workflow
├── regenerate-post.ts # Blog post regeneration workflow
└── shared.ts # Shared workflow steps (social media, cache)import { fetch } from "workflow";
export async function carsWorkflow(payload: CarsWorkflowPayload) {
"use workflow";
// Enable WDK's durable fetch for AI SDK
globalThis.fetch = fetch;
// Step 1: Process data
const result = await processCarsData();
// Step 2: Revalidate cache
await revalidateCarsCache(month, year);
// Step 3: Generate blog post
const post = await generateCarsPost(data, month);
return { postId: post.postId };
}
async function processCarsData(): Promise<UpdaterResult> {
"use step";
// Processing logic - each step is durable and can retry
return await updateCars();
}apps/web/vercel.json{
"crons": [
{ "path": "/api/workflows/cars", "schedule": "0 10 * * *" },
{ "path": "/api/workflows/coe", "schedule": "0 10 * * *" },
{ "path": "/api/workflows/deregistrations", "schedule": "0 10 * * *" }
]
}start()import { start } from "workflow/api";
import { carsWorkflow } from "@web/workflows/cars";
export async function POST(request: Request) {
const payload = await request.json();
const run = await start(carsWorkflow, [payload]);
return Response.json({ message: "Workflow started", runId: run.runId });
}shared.tsexport async function publishToSocialMedia(title: string, link: string) {
"use step";
await socialMediaManager.publishToAll({ message: `📰 ${title}`, link });
}
export async function revalidatePostsCache() {
"use step";
revalidateTag("posts:list", "max");
}async function processData() {
"use step";
try {
const result = await updateData();
return result;
} catch (error) {
console.error("Step failed:", error);
throw error; // Re-throw for automatic retry
}
}apps/web/src/workflows/"use workflow""use step"apps/web/src/app/api/workflows/vercel.jsonDATABASE_URLUPSTASH_REDIS_REST_URLUPSTASH_REDIS_REST_TOKENpnpm -F @sgcarstrends/web test -- src/workflows# Start dev server
pnpm dev
# Trigger workflow via HTTP
curl -X POST http://localhost:3000/api/workflows/carsapps/web/src/app/api/workflows/apps/web/src/config/platforms.tsapps/web/vercel.jsonapps/web/CLAUDE.md"use step"globalThis.fetch = fetch