For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to Design a Workflow: Best Practices and Patterns

Designing an effective workflow is about balancing structure, flexibility, and clarity. In the XYB platform, workflows give teams control over core logic but with that power comes responsibility to ensure workflows are maintainable, observable, and secure.

This guide outlines key principles and common patterns to help teams design workflows that scale.

1. Define the Goal

Start with a clear, outcome-focused goal:

  • What process are you trying to automate?

  • What services will be involved?

  • What is the desired end state?

Example:

"When a customer is flagged RiskClosed, close all associated investigation tasks."

2. Choose the Right Trigger (if applicable)

Some workflows begin with a service event, others are internal processes. Determine whether your workflow is:

  • Service-driven (e.g. entity created, payment initiated)

  • Scheduled (e.g. rotate secrets weekly)

  • Manual (e.g. operator triggers the flow)

3. Break It Into Steps

Decompose the workflow into logical stages:

  • Input validation

  • Risk or eligibility checks

  • Routing or decision branches

  • Execution actions (create task, update status)

Use sequence contexts for ordered steps, and selection contexts to branch.

4. Use Parameters for Flexibility

Avoid hardcoding logic inside a workflow. Use parameterized values for things like:

  • Thresholds (e.g. transaction size limits)

  • Recipient accounts or task templates

  • Provider selection

Parameters can be adjusted per workflow version or client without code changes.

5. Handle Failures Gracefully

Services should handle retries and timeouts, but workflows should:

  • Detect known error conditions

  • Set workflow states appropriately

  • Avoid infinite loops or recursion

Workflows can use the ENDING state or terminal transitions to mark completion.

6. Reuse Through Templates

Abstract repeated logic into reusable templates. Examples:

  • Standard ledger validation block

  • Common risk escalation flow

  • Account + wallet creation bundle

Templates reduce duplication and improve quality.

Last updated