upstash/workflow-js / skills
upstash-workflow-js
UnverifiedLightweight guidance for using the Upstash Workflow SDK to define, trigger, and manage workflows. Use this Skill whenever a user wants to create workflow endpoints, run steps, or interact with the Upstash Workflow client.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 2.2 KB |
| agents.md | markdown | 6.7 KB |
| basics/client.md | markdown | 4.1 KB |
| basics/context.md | markdown | 5.1 KB |
| basics/serve.md | markdown | 2.4 KB |
| features/flow-control.md | markdown | 3.9 KB |
| features/invoke.md | markdown | 2.6 KB |
| features/retries-failures-reliability.md | markdown | 6.3 KB |
| features/wait-for-event.md | markdown | 2.8 KB |
| features/webhooks.md | markdown | 2.5 KB |
| how-to/local-dev.md | markdown | 3.2 KB |
| how-to/middleware.md | markdown | 4.7 KB |
| how-to/migrations.md | markdown | 4.8 KB |
| how-to/realtime.md | markdown | 4.8 KB |
| rest-api.md | markdown | 6.6 KB |
| troubleshooting.md | markdown | 4.8 KB |
features/webhooks.md
View on GitHub## Webhooks
This skill teaches agents how to use webhooks inside Upstash Workflow to pause execution, wait for external callbacks, and resume reliably. It covers creation, waiting, validation, and multi-step usage.
---
### Key Concepts
• **Webhook URLs are unique per context.createWebhook() call**.
• **Workflow execution pauses** when calling `context.waitForWebhook()` until the webhook receives a request or times out.
• **Lookback protection** ensures the workflow still receives early webhook calls.
• **Workflows remain dormant** during the waiting period, avoiding compute cost.
• **Webhooks are ideal for third‑party APIs** that support callback URLs.
---
### Core Workflow: Create → Call External API → Wait → Resume
Below is a consolidated example showing:
• Creating a webhook
• Passing it to an external API
• Handling the callback
• Waiting for multiple updates
• Error/timeout handling
```ts
import { serve } from "@upstash/workflow/nextjs";
export const { POST } = serve(async (context) => {
// Create a unique webhook for this workflow
const webhook = await context.createWebhook("create webhook");
// Trigger an external service, sending it the callback URL
await context.call("trigger-external", {
url: "https://api.example.com/process",
method: "POST",
body: { webhookUrl: webhook.webhookUrl },
});
// Loop: wait for progress updates until service signals completion
let updates = [];
while (true) {
const res = await context.waitForWebhook(`wait update`, webhook, "5m");
if (res.timeout) break; // no progress received
const req = res.request;
const payload = await req.json();
updates.push(payload);
if (req.headers.get("x-task-finished") === "true") break;
}
return updates;
});
```
---
### Webhook Reliability: Lookback Protection
**Common pitfall:** external systems may call the webhook _before_ the workflow reaches `waitForWebhook()`.
Upstash automatically stores early webhook calls. The next `waitForWebhook()` will immediately resolve with the stored request.
This avoids race conditions and eliminates the need for manual buffering.
---
### When to Use Webhooks vs. Wait for Event
Use **webhooks** when:
• integrating with third‑party APIs
• the external system invokes a callback URL
• you need race‑condition‑safe behavior
Use **Wait for Event** when:
• you control the notifying system and can use the Workflow Client
• you don't need lookback semantics
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 470k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |