# Workflows That Do Three Things at Once: Parallel Branches, Loops and Sub-Workflows

> Real processes branch, repeat and reuse. TR Workflow OS now runs branches at the same time, repeats steps for every item in a list and calls other workflows. Runs stay durable, and approvals, limits and verification keep working inside every branch.

Source: https://www.ticketresolve.ai/blog/workflows-that-do-three-things-at-once · Published 2026-11-18 · TicketResolve AI

At 2:14 p.m. a payment provider's webhook reports that a large customer's invoice payment failed. The support lead on duty wants three answers before she replies: is the card actually declined in billing, has the account manager already been in touch (CRM), and is the payment provider having an outage (status page)?

Done in a straight line, the workflow checks billing, *then* the CRM, *then* the status page. Each call takes a few seconds and the status page sometimes takes twenty, so the answer arrives late. It also turns out that five customers were affected by the same failure, so the whole thing has to be built five times. And ten other workflows already start with the same "look up the account" steps, each copied and slightly different.

Real processes don't run in a straight line. They **branch**, **repeat** and **reuse**. TR Workflow OS now does all three in the runtime, so the workflows you already have can too.

## First, the basics

- **A workflow** is a set of steps a computer follows automatically when something happens.
- **In sequence** means one step after another. **In parallel** means several steps at the same time. Think of a restaurant kitchen: starters, mains and drinks are prepared at once, not one after the other.
- **A loop ("for each")** repeats the same steps for every item in a list, such as every affected customer, like a teacher marking each paper in a pile the same way.
- **A sub-workflow** is a workflow used inside another one, so common steps are written once and reused, the way a recipe might say "make the basic dough (see page 12)".
- **A durable run** survives interruptions: if a server restarts mid-way, the work continues from where it stopped instead of starting over or being lost.

Why does this matter? Real business processes aren't straight lines. Customers wait less when checks happen at the same time, mistakes drop when the same steps are applied to every item, and maintenance gets easier when shared steps live in one place.

## The problem, in plain terms

1. **Waiting on things that could happen at the same time.** Independent lookups run one after another, and the slowest one sets the pace for everything.
2. **Copy-pasting steps for every item.** When the same action applies to each affected customer, order or ticket, people either duplicate steps or run the workflow by hand N times.
3. **The same steps rebuilt in ten places.** "Find the account and its owner" lives in every workflow, and when it changes, nine of the ten copies are wrong.

## Parallel branches

A **Parallel** step runs 2 to 5 branches at the same time and waits for all of them.

- Each branch is its own run of the same workflow version, so **approvals, retries and verification work inside it** exactly as they do anywhere else.
- When every branch has reached the step where they meet, their results and saved values come back into the main run.
- If a branch doesn't succeed, the step fails and **says which branch and why**. **Retry** starts fresh branches rather than re-reading the old ones.

## For each

A **For each** step repeats steps for every item in a list (the results of a lookup, or a list saved earlier in the run), up to 50 items.

- Inside the loop, `{{loop.item}}` and `{{loop.index}}` refer to the current item.
- Each item's result is collected for the steps after the loop.
- Loops run one item at a time and **survive restarts**: if the server restarts at item 23, the run continues at item 23.
- Loops can't be nested. That keeps runs readable and bounded.

## Run a workflow

A **Run a workflow** step starts another workflow with the values you pass, waits for it to finish, and gets its values back. Write the account lookup once, and use it everywhere.

## Three real-world scenarios

### 1. The failed payment, answered in seconds

**How TR handles it.** A Parallel step with three branches: *check the invoice in billing*, *read the last activity in the CRM*, *check the payment provider's status page*. All three run at once. The reply waits only for the slowest, not for the sum. If the status page branch fails because the page is down, the step says *"Branch 3 (status page) failed: timed out"*. The lead knows exactly which fact is missing and can retry just that.

### 2. A release broke exports for 37 customers

Engineering confirms a bug that affected 37 accounts. Each one needs a personal note on their ticket, a credit applied and a follow-up task for their account manager.

**How TR handles it.** A lookup returns the 37 affected accounts as a list. A **For each** runs the same three steps for every account, with `{{loop.item.name}}` in the note. Applying a credit moves money, so the risk policy puts an approval inside the loop. The finance lead approves the credits individually and can skip the one account that's already been compensated. If the worker restarts halfway through, the loop continues where it stopped, and nobody gets two credits.

### 3. One "find the account" workflow instead of ten copies

A RevOps team has ten workflows that each begin by finding the customer in the CRM, the billing system and the help desk, then deciding who the owner is.

**How TR handles it.** They build that once as its own workflow that returns the account ID, the plan and the owner. Each of the ten workflows now starts with **Run a workflow → Find the account**. When the ownership rule changes (say, enterprise accounts now belong to the regional lead), they change one workflow, and all ten pick it up.

## The guardrails still apply

- **The risk policy follows branches and loops.** A destructive or production-impacting step inside a branch still needs an approval before it.
- **Chain limits hold.** Workflows can be 3 levels deep, with 10 runs per chain, so a workflow that calls itself can't run away. Branches don't use up a workflow's runs per hour.
- **Nothing is counted twice.** Outcome Assurance records the run that started the work, not each branch.
- **Cancelling cancels everything.** Cancelling a run cancels its branches and sub-workflows, and the run's detail links to each one.

## Before and after

**Before.** Three lookups run one after another, so the reply waits for the slowest *plus* the others. The 37-account clean-up is done by hand in a spreadsheet, two accounts get the credit twice, and one gets nothing. Ten workflows each have their own slightly different "find the account" steps, and the ownership rule change is applied to three of them.

**After.** The lookups run together and the reply waits only for the slowest. The clean-up is one loop with an approval per credit that resumes where it stopped if anything restarts. The account lookup is one workflow that ten others call, so a rule change is made once.

## Choosing the right building block

- Use **Parallel** when steps are **independent** and you need all their results: different systems, same moment.
- Use **For each** when the **same steps** apply to **every item** in a list, and order or one-at-a-time matters.
- Use **Run a workflow** when the same group of steps appears in **several workflows** and should change in one place.

## Mistakes to avoid

- **Parallelising steps that depend on each other.** If step B needs step A's result, they can't run together.
- **Looping over huge lists.** For each handles up to 50 items. For more, narrow the list first with a transform, or split the work.
- **Copying instead of calling.** If you paste the same five steps into a second workflow, make it a sub-workflow instead.

## A worked example, start to finish

Here's the 2:14 p.m. failed payment, after the support operations team rebuilt the workflow.

**Last week.** The team built a small sub-workflow, *Find the account*, which takes an e-mail address and saves `account_id`, `plan` and `owner`. Ten existing workflows now call it with **Run a workflow** instead of carrying their own copy of those steps.

**2:14:00.** The payment provider's webhook reports a failed invoice payment. The failed-payment workflow starts and calls *Find the account*, which returns the account, its Enterprise plan and the account manager.

**2:14:02.** A **Parallel** step starts three branches at once: *Check invoice in billing*, *Read last CRM activity* and *Check provider status page*.

**2:14:04.** Billing answers: the card was declined with "insufficient funds". The CRM answers: the account manager e-mailed the customer about a new card last Tuesday.

**2:14:21.** The status page answers after 17 seconds: the provider reports a partial outage affecting one card network.

**2:14:21.** All three branches have reached *Decide the reply*, so the workflow continues together. The reply step uses all three results: the decline may be caused by the provider's outage, not the customer's card.

**2:14:25.** A lookup returns the **five accounts** affected by the same failure. A **For each** step runs *Post a personal note* and *Apply credit* for each account, using `{{loop.item.name}}`. The credit step is privileged, so the risk policy puts an approval before it, and finance approves each of the five credits.

**2:31.** The support lead replies to the first customer with all three facts and a goodwill credit. In a straight line, she'd still have been waiting for the status page before the workflow even started on the other four.

The run's detail lists the three branches with their timings, the sub-workflow, and each of the five loop items with its result.

## How to tell it's working

- **Run times fall** where independent checks now happen in parallel.
- **Copied steps disappear**: common lookups live in one sub-workflow.
- **Loops still get approvals** for privileged steps, item by item.
- **Failed branches are named** in the run detail, not lost.

## Do it in TicketResolve, step by step

**Where:** Workflows (`/dashboard/workflows`). **You'll need:** permission to manage automation. **Full guide:** [Parallel branches, loops and sub-workflows](https://www.ticketresolve.ai/docs/guide/workflow-branches-loops).

### A. Three checks at once (parallel)

1. Open your failed-payment workflow and add a **Parallel** step after the trigger.
2. Create three branches, each starting at its own step: *Check invoice in billing*, *Read last CRM activity*, *Check provider status page*.
3. Choose the step where they **continue together**, for example *Decide the reply*. Each branch ends when it reaches that step, and the workflow waits for all of them.
4. In *Decide the reply*, use each branch's results, such as `{{steps.check_invoice.data.status}}`.

### B. The same steps for every affected account (for each)

1. Add a lookup that returns the affected accounts, for example `steps.affected.items`.
2. Add a **For each** step: name the list, the first step to repeat (*Post a personal note*) and where to continue afterwards.
3. In the repeated steps, use `{{loop.item.name}}` and `{{loop.item.ticket_id}}`.
4. Put the **Apply credit** step inside the loop. The risk policy adds an approval before it, so finance approves each credit.

### C. One "find the account" workflow, reused (sub-workflow)

1. Build a small workflow that looks up the account and saves `account_id`, `plan` and `owner`.
2. In each of your other workflows, add **Run a workflow**, choose *Find the account* and pass values as `name=value` lines (for example `email={{ticket.requester_email}}`).
3. Read its answers as `{{steps.find_account.vars.owner}}`.

**How to check it worked:** open a run's detail. It lists its branches and sub-workflows with their status, and each loop item's result. If a branch fails, the Parallel step names which one and why, and **Retry** starts fresh branches.

## Frequently asked questions

**Do approvals work inside a parallel branch or a loop?**
Yes. Each branch is a full run, and loops pause for approvals like any other step.

**What happens if one branch fails?**
The Parallel step fails, names the branch and the reason, and Retry starts fresh branches.

**How many items can a For each handle?**
Up to 50 per loop, one at a time, resuming after restarts.

**Can a sub-workflow call another sub-workflow?**
Yes, up to 3 levels deep and 10 runs per chain.

**Does a parallel branch skip the approval rules?**
No. Risk classes and approvals apply inside branches, loops and sub-workflows just as elsewhere.

**How do I use a sub-workflow's results?**
As `{{steps.<step>.vars.<name>}}`, for example `{{steps.find_account.vars.owner}}`.

**What happens when I retry a failed parallel step?**
Retry starts fresh branches.
