### Workflow Started Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of the data payload for a 'Workflow Started' lifecycle event, including workflow name, definition, and start time. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples definition: name: orderPetWorkflow namespace: samples version: '1.0.0' startedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Install and Run Misspell for Typos Source: https://github.com/serverlessworkflow/specification/blob/main/contributing.md Install the `misspell` tool and use it to check for typos in the project. Golang is needed for installation. ```bash make install-misspell make misspell ``` -------------------------------- ### Task Started Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a task has started execution. Includes the workflow name, task JSON Pointer, and start timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' startedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### HTTP Call Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Shows how to perform an HTTP GET request to an external API. The endpoint and method are specified, with optional query parameters. ```yaml document: dsl: '1.0.3' namespace: test name: http-example version: '0.1.0' do: - getPet: call: http with: method: get endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` -------------------------------- ### External Resource Definition Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example defining an external resource with a name and endpoint details, including authentication. ```yaml name: sample-resource endpoint: uri: https://fake.com/resource/0123 authentication: basic: username: admin password: 1234 ``` -------------------------------- ### AsyncAPI Call Examples Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates publishing a message and subscribing to messages using the AsyncAPI call. The first example publishes a 'Hello, World!' greeting, while the second subscribes to a chat room for a specified duration. ```yaml document: dsl: '1.0.3' namespace: test name: asyncapi-example version: '0.1.0' do: - publishGreetings: call: asyncapi with: document: endpoint: https://fake.com/docs/asyncapi.json operation: greet server: name: greetingsServer variables: environment: dev message: payload: greetings: Hello, World! headers: foo: bar bar: baz - subscribeToChatInbox: call: asyncapi with: document: endpoint: https://fake.com/docs/asyncapi.json operation: chat-inbox protocol: http subscription: filter: ${ . == $workflow.input.chat.roomId } consume: amount: 5 for: seconds: 10 ``` -------------------------------- ### Basic Migration Example Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md Perform a standard migration of a workflow definition file from an older version to the latest. ```bash # Basic migration swf-migrate workflow-v0.8.json ``` -------------------------------- ### Workflow Correlation Started Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of the data payload for a 'Workflow Correlation Started' lifecycle event, including workflow name and start time. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples startedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### gRPC Call Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates how to make a gRPC call to an external service. Ensure the proto resource is correctly defined and accessible. ```yaml document: dsl: '1.0.3' namespace: test name: grpc-example version: '0.1.0' do: - greet: call: grpc with: proto: endpoint: file://app/greet.proto service: name: GreeterApi.Greeter host: localhost port: 5011 method: SayHello arguments: name: ${ .user.preferredDisplayName } ``` -------------------------------- ### JsonPath to jq Expression Conversion Examples Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md Provides examples of common JsonPath patterns and their corresponding jq equivalents used in the migration tool. Covers basic field access, array indexing, recursive descent, and array filtering. ```text | JsonPath Pattern | jq Equivalent | Complexity | |------------------|---------------|------------| | `$.field` | `.field` | Low | | `$.array[0]` | `.array[0]` | Low | | `$..recursive` | `.. \| .field? \| select(.)` | Medium | | `$.array[?(@.price < 10)]` | `.array[] \| select(.price < 10)` | Medium-High | | Complex multi-predicate filters | Custom jq logic | High (requires manual review) ``` -------------------------------- ### OpenAPI Call Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Illustrates calling an OpenAPI-defined service. Specify the OpenAPI document, operation ID, and any required parameters. ```yaml document: dsl: '1.0.3' namespace: test name: openapi-example version: '0.1.0' do: - findPet: call: openapi with: document: endpoint: https://petstore.swagger.io/v2/swagger.json operationId: findPetsByStatus parameters: status: available ``` -------------------------------- ### Start EV Charging Session Source: https://github.com/serverlessworkflow/specification/blob/main/use-cases/managing-ev-charging-stations/README.md Initializes a charging session, provides visual feedback, locks the slot, starts the charging session, and notifies relevant systems. ```yaml startSession: do: - initialize: set: session: card: ${ $context.card } slotNumber: ${ $context.slot.number } export: as: '$context + { session: . }' - feedBack: call: http with: method: post endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/leds/{slotNumber} body: action: 'on' color: blue - lockSlot: call: http with: method: put endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/slot/{slotNumber}/lock - start: call: http with: method: put endpoint: https://ev-power-supplier.com/api/v2/sessions/{sessionId}/start - notify: emit: event: with: source: https://ev-power-supplier.com type: com.ev-power-supplier.charging-station.session-started.v1 data: ${ $context.session } ``` -------------------------------- ### Basic Authentication Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Defines basic authentication using a username and password. Use this when the resource requires simple username/password credentials. ```yaml sampleBasic: basic: username: admin password: 123 ``` -------------------------------- ### Workflow Resumed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of the data payload for a 'Workflow Resumed' lifecycle event, including workflow name and resumption time. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples resumedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Task Resumed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that a task has been resumed. Includes workflow name, task reference, and resumption timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' resumedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### OpenIdConnect Authentication Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates how to configure OpenIdConnect authentication for HTTP calls. Ensure the authority URI is correct and the grant type is supported. ```yaml document: dsl: '1.0.3' namespace: test name: oidc-authentication-example version: '0.1.0' do: - sampleTask: call: http with: method: get endpoint: uri: https://secured.fake.com/sample authentication: oidc: authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration grant: client_credentials client: id: workflow-runtime secret: "**********" scopes: [ api ] audiences: [ runtime ] ``` -------------------------------- ### Task Completed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that a task ran to completion. Includes workflow name, task reference, completion timestamp, and output. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' completedAt: '2024-07-26T16:59:57-05:00' output: orderId: '0a7f8581-acb9-4133-a378-0460c98ea60c' petId: xt84hj202q14s status: placed ``` -------------------------------- ### Task Retried Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that a task is being retried. Includes workflow name, task reference, and retry timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' retriedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Workflow Cancelled Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a workflow has been cancelled. Includes the workflow name and cancellation timestamp. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples cancelledAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Wait State Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates how to use the 'wait' state to pause workflow execution for a specified duration using ISO 8601 duration format. ```yaml document: dsl: '1.0.3' namespace: test name: wait-example version: '0.1.0' do: - waitAWhile: wait: seconds: 10 ``` -------------------------------- ### Task Cancelled Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that a task has been cancelled. Includes workflow name, task reference, and cancellation timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' cancelledAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Task Created Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a task has been created. Includes the workflow name, task JSON Pointer, and creation timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' createdAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### MCP Call Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Shows how to invoke an MCP method, specifically 'tools/call' to publish a message to Slack. The transport configuration specifies the command and arguments for the Slack MCP server. ```yaml document: dsl: '1.0.3' namespace: test name: mcp-example version: '0.1.0' do: - publishMessageToSlack: call: mcp with: method: tools/call parameters: name: conversations_add_message arguments: channel_id: 'C1234567890' thread_ts: '1623456789.123456' payload: 'Hello, world! :wave:' content_type: text/markdown transport: stdio: command: npx arguments: [ slack-mcp-server@latest, --transport, stdio ] environment: SLACK_MCP_XOXP_TOKEN: xoxp-xv6Cv3jKqNW8esm5YnsftKwIzoQHUzAP ``` -------------------------------- ### Call Task Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates how to use the 'call' task to invoke an HTTP service. The 'with' property specifies the HTTP method and endpoint. ```yaml document: dsl: '1.0.3' namespace: test name: call-example version: '0.1.0' do: - getPet: call: http with: method: get endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` -------------------------------- ### OAuth2 Authentication Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Defines OAuth2 authentication with client credentials. Suitable for securing access to resources that use the OAuth2 framework. ```yaml sampleOAuth2: oauth2: authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration grant: client-credentials client: id: workflow-runtime secret: workflow-runtime-client-secret scopes: [ api ] audiences: [ runtime ] ``` -------------------------------- ### A2A Call Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Demonstrates how to use the 'a2a' function to send a message to an AI agent using the A2A protocol. Ensure the agentCard endpoint is correctly configured. ```yaml document: dsl: '1.0.3' namespace: test name: a2a-example version: '0.1.0' do: - GenerateReport: call: a2a with: method: message/send agentCard: endpoint: https://example.com/.well-known/agent-card.json parameters: message: parts: - kind: text text: Generate the Q1 sales report. ``` -------------------------------- ### Workflow Faulted Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a workflow has faulted. Includes the workflow name, fault timestamp, and error details. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples faultedAt: '2024-07-26T16:59:57-05:00' error: type: https://serverlessworkflow.io/spec/1.0.0/errors/communication title: Service Not Available status: 503 ``` -------------------------------- ### Task Faulted Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that a task has faulted. Includes workflow name, task reference, fault timestamp, and error details. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' faultedAt: '2024-07-26T16:59:57-05:00' error: type: https://serverlessworkflow.io/spec/1.0.0/errors/communication title: Service Not Available status: 503 ``` -------------------------------- ### Workflow Completed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a workflow has completed successfully. Includes the workflow name, completion timestamp, and optional output. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples completedAt: '2024-07-26T16:59:57-05:00' output: orderId: '0a7f8581-acb9-4133-a378-0460c98ea60c' petId: xt84hj202q14s status: placed ``` -------------------------------- ### Task Status Changed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event notifying that the status phase of a task has changed. Includes workflow name, task reference, update timestamp, and new status. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' updatedAt: '2024-07-26T16:59:57-05:00' status: completed ``` -------------------------------- ### Define a Custom Function with JavaScript Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Define the input, output, and execution logic for a custom function using a script. This example uses JavaScript to validate an email address. ```yaml #function.yaml input: schema: document: type: object description: The function's input properties: emailAddress: type: string description: The email address to validate. output: schema: document: type: object description: The function's output properties: isValid: type: boolean description: A boolean indicating whether or not the email address is valid. run: script: language: javascript code: | function validateEmail(email) { const re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; return re.test(email); } return { isValid: validateEmail(emailAddress) }; arguments: emailAddress: ${ .emailAddress } ``` -------------------------------- ### Retry Configuration for Specific Errors in YAML Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Configure retries for a specific error status (e.g., 503) within a 'try' block. This example retries up to 5 times with a 3-second delay and linear backoff. ```yaml try: call: http with: method: get endpoint: uri: https://example-service.com/healthz catch: errors: with: status: 503 retry: delay: seconds: 3 backoff: linear: {} limit: attempt: count: 5 ``` -------------------------------- ### Basic CLI Command Structure Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md The fundamental structure for invoking the migration tool. Specify the input file and any desired flags. ```bash swf-migrate [flags] ``` -------------------------------- ### Workflow Suspended Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of the data payload for a 'Workflow Suspended' lifecycle event, including workflow name and suspension time. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples suspendedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Sample Logging Extension in YAML Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md This sample demonstrates how to implement a logging extension for tasks in a workflow. It shows how to define 'before' and 'after' tasks to send log messages via HTTP before and after a specified task executes. ```yaml document: dsl: '1.0.3' namespace: test name: sample-workflow version: '0.1.0' use: extensions: - logging: extend: all before: - sendLog: call: http with: method: post endpoint: https://fake.log.collector.com body: message: "${ \"Executing task '\($task.reference)\'...\" }" after: - sendLog: call: http with: method: post endpoint: https://fake.log.collector.com body: message: "${ \"Executed task '\($task.reference)\'...\" }" do: - sampleTask: call: http with: method: get uri: https://fake.com/sample ``` -------------------------------- ### Migration with Custom Output and Namespace Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md Migrate a workflow, specifying a custom output file path and a target namespace for the 1.0.0 version. ```bash # Custom output and namespace test swf-migrate workflow.json -o migrated/workflow.yaml -n production ``` -------------------------------- ### Task Suspended Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a task has been suspended. Includes the workflow name, task JSON Pointer, and suspension timestamp. ```yaml workflow: orderPetWorkflow-ix7iryakiem8j.samples task: '/do/1/initialize' suspendedAt: '2024-07-26T16:59:57-05:00' ``` -------------------------------- ### Migration with JSON Output and Markdown Report Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md Configure the migration tool to output the migrated workflow in JSON format and generate a migration report in markdown format. ```bash # JSON output with markdown report test swf-migrate workflow.yaml -f json --report-format markdown ``` -------------------------------- ### Configure AsyncAPI Subscription Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Sets up a subscription to an AsyncAPI operation, with options for filtering, consumption lifetime, and message iteration. ```yaml document: dsl: '1.0.3' namespace: test name: asyncapi-example version: '0.1.0' do: - subscribeToChatInboxForAmount: call: asyncapi with: document: endpoint: https://fake.com/docs/asyncapi.json operation: chat-inbox protocol: http subscription: filter: ${ . == $workflow.input.chat.roomId } consume: amount: 5 for: seconds: 10 ``` -------------------------------- ### Workflow Correlation Completed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of the data payload for a 'Workflow Correlation Completed' lifecycle event, including workflow name, completion time, and correlation keys. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples completedAt: '2024-07-26T16:59:57-05:00' correlationKeys: petId: xt84hj202q14s orderId: '0a7f8581-acb9-4133-a378-0460c98ea60c' ``` -------------------------------- ### Workflow Status Changed Event Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Example of a cloud event payload indicating a workflow's status phase has changed. Includes the workflow name, update timestamp, and new status. ```yaml name: orderPetWorkflow-ix7iryakiem8j.samples updatedAt: '2024-07-26T16:59:57-05:00' status: completed ``` -------------------------------- ### Sequential Task Execution with Do Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Use the 'do' task to execute a series of subtasks sequentially. Each task in the sequence must complete before the next one begins. ```yaml document: dsl: '1.0.3' namespace: test name: do-example version: '0.1.0' use: authentications: fake-booking-agency-oauth2: oauth2: authority: https://fake-booking-agency.com grant: client_credentials client: id: serverless-workflow-runtime secret: secret0123456789 do: - bookHotel: call: http with: method: post endpoint: uri: https://fake-booking-agency.com/hotels/book authentication: use: fake-booking-agency-oauth2 body: name: Four Seasons city: Antwerp country: Belgium - bookFlight: call: http with: method: post endpoint: uri: https://fake-booking-agency.com/flights/book authentication: use: fake-booking-agency-oauth2 body: departure: date: '01/01/26' time: '07:25:00' from: airport: BRU city: Zaventem country: Belgium arrival: date: '01/01/26' time: '11:12:00' to: airport: LIS city: Lisbon country: Portugal ``` -------------------------------- ### Clone Open Workflow CTK Repository Source: https://github.com/serverlessworkflow/specification/blob/main/ctk/README.md Use this command to clone the Open Workflow CTK repository to your local machine. This is the first step to setting up the CTK for testing. ```sh git clone https://github.com/serverlessworkflow/specification.git ``` -------------------------------- ### Execute Shell Command with Stdin and Arguments Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Use the `runShell` action to execute shell commands. Pass data via stdin and provide arguments and environment variables. ```yaml document: dsl: '1.0.3' namespace: test name: run-shell-example version: '0.1.0' do: - setInput: set: message: Hello World - runShell: input: from: ${ .message } run: shell: stdin: ${ . } command: | input=$(cat) echo "STDIN was: $input" echo "ARGS are $1 $2" arguments: - Foo - Bar ``` -------------------------------- ### Configure Basic Authentication from Secret Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Use this to configure basic authentication by referencing a secret containing username and password. Ensure the secret is defined in the 'use.secrets' section. ```yaml document: dsl: '1.0.3' namespace: test name: authentication-example version: '0.1.0' use: secrets: - usernamePasswordSecret authentications: sampleBasicFromSecret: basic: use: usernamePasswordSecret do: - sampleTask: call: http with: method: get endpoint: uri: https://secured.fake.com/sample authentication: use: sampleBasicFromSecret ``` -------------------------------- ### Bearer Authentication Example Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Defines bearer authentication using a token. This is common for API authentication where a token is provided in the Authorization header. ```yaml sampleBearer: bearer: ${ .user.token } ``` -------------------------------- ### Configure AsyncAPI Server Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Configures the target server for an AsyncAPI operation, including server name and optional variables. ```yaml document: dsl: '1.0.3' namespace: test name: asyncapi-example version: '0.1.0' do: - publishGreetings: call: asyncapi with: document: endpoint: https://fake.com/docs/asyncapi.json operation: greet server: name: greetingsServer variables: environment: dev message: payload: greetings: Hello, World! headers: foo: bar bar: baz ``` -------------------------------- ### Automated SQL Server Backup to Minio Workflow Source: https://github.com/serverlessworkflow/specification/blob/main/use-cases/automated-data-backup/README.md This YAML defines a Serverless Workflow that automates SQL Server database backups and uploads them to Minio. It includes steps for database export, Base64 encoding, and Minio upload, scheduled to run daily. ```yaml document: dsl: '1.0.3' namespace: default name: sql-export-to-minio version: 0.1.2 do: - exportDatabase: run: container: image: mcr.microsoft.com/mssql-tools command: > /bin/bash -c "sqlcmd -S $SQLSERVER_HOST -U $SQLSERVER_USER -P '$SQLSERVER_PASSWORD' -Q 'BACKUP DATABASE [$DATABASE_NAME] TO DISK = N\'\\/var\\/backup\\/db.bak\'' && echo 'Database backup completed'" volumes: /var/backup: /backup environment: SQLSERVERHOST: sqlserver SQLSERVERUSER: SA SQLSERVERPASSWORD: P@ssw0rd DATABASENAME: YourDatabase - readBackupFile: run: container: image: alpine command: > /bin/sh -c "cat /backup/YourDatabase.bak | base64" volumes: /var/backup: /backup export: as: '$context + { base64Backup: . }' - uploadToMinio: call: http with: method: put endpoint: uri: https://minio.example.com/backups/db.bak authentication: bearer: token: 2548qsd5a8qsd43a headers: contentType: application/octet-stream body: ${ $context.base64Backup } schedule: cron: 0 0 * * * ``` -------------------------------- ### Perform Logging Before and After Tasks Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Applies logging extensions to all tasks. Ensures logs are sent before and after each task executes, using the 'all' extend type. ```yaml document: dsl: '1.0.3' namespace: test name: logging-extension-example version: '0.1.0' use: extensions: - logging: extend: all before: - sendLog: call: http with: method: post endpoint: https://fake.log.collector.com body: message: ${ "Executing task '\($task.reference)'..." } after: - sendLog: call: http with: method: post endpoint: https://fake.log.collector.com body: message: ${ "Executed task '\($task.reference)'..." } do: - sampleTask: call: http with: method: get endpoint: https://fake.com/sample ``` -------------------------------- ### Workflow Metadata Transformation Source: https://github.com/serverlessworkflow/specification/blob/main/adr/v1.0-adr-migration-tool.md Illustrates the mapping of metadata fields from older Serverless Workflow versions (0.8/0.9) to the 1.0.0 schema. Note the introduction of 'dsl', 'namespace', and the restructuring of 'name' and 'version'. ```text 0.8/0.9: name: "my-workflow" version: "1.0.0" specVersion: "0.8" 1.0.0: document: dsl: "1.0.0" namespace: "default" name: "my-workflow" version: "1.0.0" ``` -------------------------------- ### Use a Custom Function in a Workflow Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md Integrate a custom function into a Serverless Workflow by specifying its call endpoint and passing necessary arguments. This example calls a custom email validation function. ```yaml # workflow.yaml document: dsl: '1.0.3' namespace: default name: customFunctionWorkflow version: '0.1.0' do: - validateEmail: call: https://github.com/myorg/functions/validateEmailAddress@v1.0.0 with: emailAddress: ${ .userEmail } ``` -------------------------------- ### Define MCP Client Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Use this to describe an MCP client. Specify the client name and version for connecting to the MCP server. ```yaml name: synapse version: '1.0.0-alpha5.2' ``` -------------------------------- ### Example Error Structure in YAML Source: https://github.com/serverlessworkflow/specification/blob/main/dsl.md This YAML structure defines an error according to RFC 7807 Problem Details, including type, title, status, detail, and instance for specific error identification. ```yaml type: https://serverlessworkflow.io/spec/1.0.0/errors/communication title: Service Unavailable status: 503 detail: The service is currently unavailable. Please try again later. instance: /do/getPetById ``` -------------------------------- ### Run Container Task Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Execute a containerized process using the 'run' task. Specify the container image to be run. ```yaml runContainer: run: container: image: fake-image ``` -------------------------------- ### Run Script Task Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Execute a script using the 'run' task. Specify the script language and code. ```yaml runScript: run: script: language: javascript code: > Some cool multiline script ``` -------------------------------- ### Invoke Nested Workflow with Input Source: https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md Use the `startWorkflow` action to execute another workflow. Specify the target workflow's namespace, name, version, and any input data. ```yaml document: dsl: '1.0.3' namespace: test name: run-workflow-example version: '0.1.0' do: - startWorkflow: run: workflow: namespace: another-one name: do-stuff version: '0.1.0' input: foo: bar ```