diff --git a/src/content/docs/workflows/index.mdx b/src/content/docs/workflows/index.mdx index 4c0a22bc4bc2c6..eb9ed1ccc0491c 100644 --- a/src/content/docs/workflows/index.mdx +++ b/src/content/docs/workflows/index.mdx @@ -10,7 +10,7 @@ head: content: Overview --- -import { CardGrid, Description, Feature, LinkTitleCard, Plan, RelatedProduct } from "~/components" +import { CardGrid, Description, Feature, LinkTitleCard, Plan, RelatedProduct, Tabs, TabItem, LinkButton } from "~/components" @@ -20,9 +20,57 @@ Build durable multi-step applications on Cloudflare Workers with Workflows. -Workflows is a durable execution engine built on Cloudflare Workers. Workflows allow you to build multi-step applications that can automatically retry, persist state and run for minutes, hours, days, or weeks. Workflows introduces a programming model that makes it easier to build reliable, long-running tasks, observe as they progress, and programatically trigger instances based on events across your services. - -Refer to the [get started guide](/workflows/get-started/guide/) to start building with Workflows. +With Workflows, you can build applications that chain together multiple steps, automatically retry failed tasks, +and persist state for minutes, hours, or even weeks - with no infrastructure to manage. + +Workflows give you: + +- Reliable multi-step operations without worrying about timeouts +- Automatic retries and error handling +- Built-in observability for long running operations +- Simple and expressive code for complex processes + + + +```ts +export class CheckoutWorkflow extends WorkflowEntrypoint { + async run (event, step) { + const processorResponse = await step.do( 'submit payment', async () => { + let resp = await submitToPaymentProcessor(event.params.payment) ; + return await resp.json(); + }) ; + + const textResponse = await step.do( 'send confirmation text', sendConfirmation); + await step.sleep('wait for feedback', '2 days'); + await step.do('send feedback email', sendFeedbackEmail); + await step.sleep('delay before marketing', '30 days'); + await step.do( 'send marketing follow up', sendFollowUp); + } +} +``` + + + +```json +{ + "name": "my-worker-with-workflow", + "main": "src/index.js", + "compatibility_date": "2025-02-27", + "workflows": [ + { + "name": "checkout-workflow", + "binding": "CHECKOUT", + "class_name": "CheckoutWorkflow" + } + ] +} +``` + + + + + Start building with Workflows + ***