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

# Steps

> Conditions, actions, waits and loops: the steps a flow is built from.

A flow's steps run in order under its [trigger](https://docs.subtotal.com/docs/flows/triggers.md). There are four kinds. An output can lead to several steps, each on its own [path](#paths).

## Condition

A condition checks its criteria, then goes on along **True** or **False**. Each output holds its own steps. An output with no steps ends that path.

A new condition starts with one criterion. Add more with **And another**. With two or more, choose under **True when**: *all of these criteria hold* or *at least one of these criteria holds*.

The fields you can test depend on the flow's trigger:

| Trigger | Field | Operators |
| :- | :- | :- |
| Purchase shared | **Status** | Equal to, Not equal to, Is any of, Is none of |
| Purchase shared | **Retailer** | Equal to, Not equal to, Is any of, Is none of |
| Purchase shared | **Brand** | Includes, Includes any of, Does not include, Contains |
| Purchase shared | **Product UPC** | Includes, Includes any of, Does not include |
| Purchase shared | **Purchase date** | On, On or before, On or after, In the last X days, Since account linked |
| Account connected | **Retailer** | Equal to, Not equal to, Is any of, Is none of |
| Account disconnected | **Retailer** | Equal to, Not equal to, Is any of, Is none of |

Notes on the fields:

* **Status** is `pending`, `shipped`, `ready_for_pickup`, `completed` or `cancelled`. A purchase with no status matches **Not equal to** and **Is none of**.
* **Brand** and **Product UPC** test the items of the purchase that are shared with your brand. **Includes** is true when at least one item matches. **Contains** matches part of a brand name.
* **In the last X days** counts back from the day of the event.
* **Since account linked** matches a purchase dated on or after the day the consumer linked the account.

## Action

An action sends to one of your apps for each event that reaches it.

| App | Action | Settings |
| :- | :- | :- |
| Klaviyo | Send event | **Action name**: the Klaviyo metric. Reusing a name keeps its metric history. |
| Braze | Send event | **Action name** |
| Attentive | Send event | **Action name** |
| Rivo, Smile, Yotpo | Award points | **Action name**, and **Points**: per \$1 spent on a purchase, or a flat number on an account event. |
| Rivo | Award store credit | **Action name**, and **Credit**: per \$1 spent on a purchase, or a flat dollar amount on an account event. |
| Okendo | Award points | **Action name**, and **Earning rule ID**. Okendo works out the points from its earning rule. |
| Meta | Send conversion | **Action name**, up to 50 characters, and **Dataset**: one of the datasets your [Meta](https://docs.subtotal.com/docs/integrations/meta/introduction.md) connection can reach. |
| TikTok | Send conversion | **Action name**, up to 50 characters, and **Pixel**: one of the pixels your TikTok connection can reach. |
| Webhooks | Send webhook | **Destination**: one of your [webhook destinations](https://docs.subtotal.com/docs/webhooks/configuration.md). The event type follows the trigger; see [Event types](https://docs.subtotal.com/docs/webhooks/events.md). |

An action needs its app to be installed: a step whose app is not connected sends nothing until you connect it. A Meta or TikTok action needs a dataset or pixel first. Not every action runs on every trigger; see [Which actions run on each trigger](https://docs.subtotal.com/docs/flows/triggers.md#which-actions-run-on-each-trigger).

## Wait

A wait pauses a purchase until its status changes. It is available on **Purchase shared** flows only. While a purchase waits, Subtotal keeps checking the order's status with the retailer, as long as the retail account stays linked.

![A Wait step open in the builder: Max wait 30 days, For status Equal to Completed.](https://mintcdn.com/typecastleinc/z9L8m88cpu_A6mvv/images/flows/wait-step.png?fit=max\&auto=format\&n=z9L8m88cpu_A6mvv\&q=85\&s=6f38c8fa6c30b496f09ffb068f3e17eb)

| Setting | What it does |
| :- | :- |
| **Max wait** | How many days the wait can last. A whole number, 1 or more. Starts at 30. |
| **For status** | Which status ends the wait. Starts at *Is any of Completed*. A wait ends on a change to Shipped, Ready for pickup, Completed or Cancelled. |

What happens when a purchase reaches a wait:

| The purchase | What the flow does |
| :- | :- |
| Already has a status that meets **For status** | Goes on to the next step at once. |
| Has no status, or a status that does not meet **For status** | Waits. The next step runs at the first status change that ends the wait. |
| Is still waiting when the max wait passes | That path ends. The steps after the wait do not run. The flow's other paths go on. |

`completed` and `cancelled` are final. To act on cancelled orders too, wait for both statuses and add a **Status** condition after the wait.

### Retailer status limits

At some retailers an order's status stops updating once the order is old. A waiting purchase there can end unsent at the max wait.

| Retailer | Limit | What it means for a wait |
| :- | :- | :- |
| Amazon | Shows no status on an order older than about four months. | A purchase that old when it is shared has no status, so a wait on it ends unsent at the max wait. |
| Ulta | Marks a ship-to-home order shipped and never delivered. Subtotal reads delivery from the carrier's tracking, which is kept for about six months. | A shipped order older than about six months stays shipped, so a wait for completed on it ends unsent at the max wait. |

### Example: reward a purchase only when it completes

1. Trigger: **Purchase shared**.
2. **Wait**, with **For status** set to *Completed*.
3. Action: **Award points**.

A purchase that is cancelled never meets the condition, so it earns nothing. A purchase at a retailer outside the [status list](https://docs.subtotal.com/docs/webhooks/events.md#purchase-status) never has a status, so to wait only where one exists, put the wait under a condition with a **Retailer** criterion.

## Go back to

**Go back to** ends a path by returning to an earlier step on the same path. Use it to check a purchase again after each status change.

The earlier step, or a step between it and **Go back to**, must be a **Wait**, so that each loop pauses. After a **Go back to**, the wait holds until the next status change, even if the purchase already meets **For status**.

### Example: send an event at each status change

1. Trigger: **Purchase shared**.
2. **Wait**, with **For status** set to *Is any of Shipped, Ready for pickup, Completed, Cancelled*.
3. Action: **Send event**.
4. **Go back to** step 2.

Each lap waits up to the max wait for the next status change.

## Paths

The trigger, an action, a wait and each output of a condition can lead to up to 10 steps. Each of those steps starts its own path, and the paths run at the same time:

* A wait holds its own path only. The other paths go on.
* A path that ends ends that path only. A failed send to an app does not stop the steps after it.

### Example: send an event now and reward the purchase when it completes

1. Trigger: **Purchase shared**.
2. Two steps under the trigger:
   * Action: **Send event**.
   * **Wait**, with **For status** set to *Completed*, then the action **Award points**.

The event goes out when the purchase is shared. The points wait for the order to complete.


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