> ## Documentation Index
> Fetch the complete documentation index at: https://crossword.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Workflows run multi-step actions such as tracking an order or starting a return. Each one follows a fixed path with defined inputs, outputs, and errors.

> [!NOTE]
>
> Dynamic components also use the word Workflow. There it means the pipeline that writes the words a component shows on your store pages. Read [Workflows for dynamic components](https://crossword.ai/docs/components/dynamic/workflows.md).

A Workflow is how a multi-step action runs, such as tracking an order or starting a return. It gives the parts of a conversation that must be exact a fixed path with defined inputs, outputs, and error handling. The Agent decides when to run it, and the Workflow decides what happens once it runs.

## What it contains

The diagram shows a Workflow, what it is built from, and who runs it.

```mermaid theme={null}
flowchart TB
  W["Workflow<br/><small>a multi-step action</small>"]
  W --> IN["Inputs<br/><small>values it needs before it runs</small>"]
  W --> OUT["Outputs<br/><small>values it returns</small>"]
  W --> STEPS
  W --> EH["Error and timeout handling<br/><small>retry, branch, respond, or hand off</small>"]
  subgraph STEPS["Steps, in order"]
    S1["Store operation"]
    S2["Agent invocation"]
    S3["Condition or branch"]
    S4["Confirmation or approval"]
    S5["Response or handoff"]
  end
  AG["Agent"]
  CS["Campaign step"]
  AG -. "runs" .-> W
  CS -. "runs" .-> W
```

| Concept | Meaning | Example |
| - | - | - |
| Inputs | The values a Workflow needs before it runs | Order number, items to return |
| Outputs | The values it returns | Order status, return label link |
| Steps | The ordered steps it runs | Look up order, confirm items, create label |
| Error and timeout handling | What happens when a step fails or takes too long | Retry the lookup once, then hand off to a human |

## Step types

| Step type | What it does | Example |
| - | - | - |
| Store operation | Runs a fixed action against your store or other systems | Look up an order, create a return |
| Agent invocation | Asks an Agent for content or a judgement inside the Workflow | Summarize why the shopper is returning |
| Condition or branch | Chooses the next step from the values so far | Is the order within 30 days? |
| Confirmation or approval | Pauses until the shopper or someone on your team confirms | "Return these two packs?" |
| Response or handoff | Replies to the shopper, or hands the conversation to an Agent or a human | "Your return is started" |

When a step fails or times out, the Workflow retries it, branches, responds to the shopper, or hands off. A Workflow that hits an unhandled error ends and returns control to the Agent.

## Who runs a Workflow

* **An Agent.** Workflows back the Agent's [actions and integrations](https://crossword.ai/docs/agents/rich-responses-and-actions.md). The Agent decides when the conversation needs one, passes the inputs, and uses the outputs in its reply. The Agent's [guardrails](https://crossword.ai/docs/agents/guardrails-and-fallback.md) still apply, so a support Agent that must never block a return always runs the return.
* **A Campaign step.** A Workflow can be a step in a [Campaign](https://crossword.ai/docs/orchestration/campaigns.md) sequence, which passes the inputs and can branch on the outputs.

An Agent reads its [knowledge and customer context](https://crossword.ai/docs/agents/knowledge-and-context.md) directly. It changes nothing in your store except through an action.

## Example

The Brand and Support Agent runs a Start a return Workflow when a shopper says a product is not working for them.

```yaml theme={null}
workflow: Start a return
inputs: [order_number, items]
steps:
  - Look up the order
  - Branch on whether the order is within the 30-day guarantee
  - Offer a better-fit swap first
  - Confirm the items with the shopper
  - Create the return and reply with the next steps
on_error: Hand off to a human with name, email, order number, and problem
```

## Related

> [card] [Rich responses and actions](https://crossword.ai/docs/agents/rich-responses-and-actions.md)

> [card] [Guardrails and fallback](https://crossword.ai/docs/agents/guardrails-and-fallback.md)

> [card] [Escalation and handoff](https://crossword.ai/docs/agents/escalation-and-handoff.md)

> [card] [Campaigns](https://crossword.ai/docs/orchestration/campaigns.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.