Skip to content

Commit 41d0d7e

Browse files
docs: add workflow migration guides and skill (#1584)
* docs: add workflow migration guides and migration skill Create migration guides for AWS Step Functions, Inngest, and Temporal under docs/content/docs/getting-started/. Each guide provides side-by-side code comparisons and a realistic order-processing saga example. Add skills/migrating-to-vercel-workflow/ with SKILL.md, reference docs for each source platform (aws-step-functions, inngest, temporal), shared patterns, resume routing, runtime targets, and 5 eval scenarios. Update create-webhook API reference with webhook resume choice clarifications. Update getting-started meta.json to include migration guide navigation entries. * In PR #1584 (migration-guides branch), make two changes to the migration guides: 1. Move migration guides to a top-level "Migration Guides" nav section: - Create docs/content/docs/migration-guides/ directory - Move the 3 migrating-from-*.mdx files from getting-started/ into migration-guides/ - Create migration-guides/meta.json with title "Migration Guides" listing temporal, inngest, aws-step-functions - Add "migration-guides" between "errors" and "api-reference" in docs/content/docs/meta.json - Remove the 3 migration entries from getting-started/meta.json 2. Replace all "Vercel Workflow" language with "Workflow SDK" across docs and skills: - In all 3 MDX migration guides: replace "Vercel Workflow" with "the Workflow SDK" or "Workflow SDK" in frontmatter, headings, table headers, and body text - Replace "shipping on Vercel" with neutral phrasing, "Vercel-managed execution" with "managed execution", "Vercel's infrastructure" with neutral phrasing - Replace Vercel-specific pricing paragraphs with generic "Efficient resource usage" bullet - Replace "Deploy to Vercel first..." checklist items with neutral deployment guidance - Keep vercel-world prerequisite links (real package name) - Rename skills/migrating-to-vercel-workflow/ to skills/migrating-to-workflow-sdk/ - Update all skill SKILL.md, evals/, and references/ files to replace "Vercel Workflow" with "Workflow SDK" - Update runtime-targets.md section headers from "Non-Vercel" to "Self-hosted" * fix type checks --------- Co-authored-by: Karthik Kalyanaraman <karthik.kalyanaraman@vercel.com>
1 parent 851a530 commit 41d0d7e

20 files changed

Lines changed: 2968 additions & 18 deletions

docs/content/docs/api-reference/workflow/create-webhook.mdx

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,25 @@ The returned `Webhook` object has:
5555

5656
- `url`: The HTTP endpoint URL that external systems can call
5757
- `token`: The unique token identifying this webhook
58-
- Implements `AsyncIterable<RequestWithResponse>` for handling multiple requests
58+
- Implements `AsyncIterable<T>` for handling multiple requests, where `T` is `Request` (default) or `RequestWithResponse` (manual mode)
5959

60-
The `RequestWithResponse` type extends the standard `Request` interface with a `respondWith(response: Response)` method for sending custom responses back to the caller.
60+
When using `createWebhook({ respondWith: 'manual' })`, the resolved request type is `RequestWithResponse`, which extends the standard `Request` interface with a `respondWith(response: Response): Promise<void>` method for sending custom responses back to the caller.
61+
62+
<Callout type="info">
63+
Use the simplest option that satisfies the prompt:
64+
65+
- `createWebhook()` — generated callback URL, and the default `202 Accepted` response is fine
66+
- `createWebhook({ respondWith: 'manual' })` — generated callback URL, but you must send a custom body, status, or headers
67+
- `createHook()` + `resumeHook()` — the app resumes from server-side code with a deterministic business token instead of a generated callback URL
68+
</Callout>
69+
70+
<details>
71+
<summary>Common wrong turns</summary>
72+
73+
- Do not use `respondWith: 'manual'` just because the flow has a callback URL.
74+
- Do not use `RequestWithResponse` unless you chose manual mode.
75+
- Do not invent a custom callback route when `webhook.url` is the intended callback surface.
76+
</details>
6177

6278
## Examples
6379

@@ -84,27 +100,29 @@ export async function basicWebhookWorkflow() {
84100
}
85101
```
86102

87-
### Responding to Webhook Requests
103+
### Responding to Webhook Requests (Manual Mode)
104+
105+
Use this section only when the caller requires a non-default HTTP response. If `202 Accepted` is acceptable, use `createWebhook()` without `respondWith: "manual"`.
88106

89-
Use the `respondWith()` method to send custom HTTP responses. Note that `respondWith()` must be called from within a step function:
107+
Pass `{ respondWith: "manual" }` to get a `RequestWithResponse` object with a `respondWith()` method. Note that `respondWith()` must be called from within a step function:
90108

91109
```typescript lineNumbers
92110
import { createWebhook, type RequestWithResponse } from "workflow"
93111

94-
async function sendResponse(request: RequestWithResponse) { // [!code highlight]
95-
"use step"; // [!code highlight]
96-
await request.respondWith( // [!code highlight]
97-
new Response(JSON.stringify({ success: true, message: "Received!" }), { // [!code highlight]
98-
status: 200, // [!code highlight]
99-
headers: { "Content-Type": "application/json" } // [!code highlight]
100-
}) // [!code highlight]
101-
); // [!code highlight]
102-
} // [!code highlight]
112+
async function sendResponse(request: RequestWithResponse): Promise<void> {
113+
"use step";
114+
await request.respondWith(
115+
new Response(JSON.stringify({ success: true, message: "Received!" }), {
116+
status: 200,
117+
headers: { "Content-Type": "application/json" }
118+
})
119+
);
120+
}
103121

104122
export async function respondingWebhookWorkflow() {
105123
"use workflow";
106124

107-
using webhook = createWebhook();
125+
using webhook = createWebhook({ respondWith: "manual" });
108126
console.log("Webhook URL:", webhook.url);
109127

110128
const request = await webhook;
@@ -117,7 +135,7 @@ export async function respondingWebhookWorkflow() {
117135
await processData(data);
118136
}
119137

120-
async function processData(data: any) {
138+
async function processData(data: any): Promise<void> {
121139
"use step";
122140
// Process the webhook data
123141
console.log("Processing:", data);
@@ -165,6 +183,7 @@ export async function eventCollectorWorkflow() {
165183

166184
## Related Functions
167185

168-
- [`createHook()`](/docs/api-reference/workflow/create-hook) - Lower-level hook primitive for arbitrary payloads
169-
- [`defineHook()`](/docs/api-reference/workflow/define-hook) - Type-safe hook helper
170-
- [`resumeWebhook()`](/docs/api-reference/workflow-api/resume-webhook) - Resume a webhook from an API route
186+
- [`createHook()`](/docs/api-reference/workflow/create-hook) — Use when the app resumes from server-side code with a deterministic business token.
187+
- [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) — Pairs with `createHook()` for deterministic server-side resume.
188+
- [`defineHook()`](/docs/api-reference/workflow/define-hook) — Type-safe hook helper.
189+
- [`resumeWebhook()`](/docs/api-reference/workflow-api/resume-webhook) — Low-level runtime API. Most integrations should call `webhook.url` directly instead of adding a custom callback route.

docs/content/docs/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"testing",
1111
"deploying",
1212
"errors",
13+
"migration-guides",
1314
"api-reference"
1415
]
1516
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Migration Guides
3+
description: Move your existing durable workflow system to the Workflow SDK with side-by-side code comparisons and realistic migration examples.
4+
type: overview
5+
summary: Migrate from Temporal, Inngest, or AWS Step Functions to the Workflow SDK.
6+
related:
7+
- /docs/foundations/workflows-and-steps
8+
- /docs/getting-started
9+
---
10+
11+
Migrate your existing orchestration system to the Workflow SDK. Each guide includes concept mappings, side-by-side code comparisons, and a full end-to-end migration example.
12+
13+
<Cards>
14+
<Card href="/docs/migration-guides/migrating-from-temporal" title="Migrating from Temporal">
15+
Replace Activities, Workers, Signals, and Child Workflows with Workflows, Steps, Hooks, and start()/getRun().
16+
</Card>
17+
<Card href="/docs/migration-guides/migrating-from-inngest" title="Migrating from Inngest">
18+
Replace createFunction, step.run(), step.sleep(), step.waitForEvent(), and step.invoke() with Workflows, Steps, and Hooks.
19+
</Card>
20+
<Card href="/docs/migration-guides/migrating-from-aws-step-functions" title="Migrating from AWS Step Functions">
21+
Replace JSON state definitions, Task/Choice/Wait/Parallel states, and .waitForTaskToken callbacks with idiomatic TypeScript.
22+
</Card>
23+
</Cards>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"title": "Migration Guides",
3+
"pages": [
4+
"migrating-from-temporal",
5+
"migrating-from-inngest",
6+
"migrating-from-aws-step-functions"
7+
]
8+
}

0 commit comments

Comments
 (0)