Branch, loop and reuse
This guide is for authors whose automations have outgrown a straight line. It shows when to use which block; each block’s reference page has every setting and trap.
Branch on one question
Section titled “Branch on one question”Use Condition for a yes or no. Pick the Value type, the Value, a Comparison and what to Compare with. The run leaves on True or False.
- The comparisons fit the type: text can contain or start with, numbers can be greater than, dates can be before or after, lists can contain an item.
- Text comparisons ignore letter case by default.
- One Condition tests one comparison. Chain them for more.
Branch on many values
Section titled “Branch on many values”Use Switch to pick a path from up to 8 exact values, such as a status or a country code. Set the Subject and the Cases; the first matching case wins. Always wire Otherwise, so an unexpected value is handled instead of ending the run quietly.
Map after a branch carefully
Section titled “Map after a branch carefully”A block after a branch can only use values from blocks that ran on its path. A setting that maps a block from the other branch has no value, and Condition and Switch fail on missing values rather than guess. Map from blocks that every path passes through.
Repeat for each item
Section titled “Repeat for each item”Use For each item to run the same blocks once for every item in a list, every row of a table or every file.
- Set Items to the list.
- Wire the blocks for one item to the Item exit. Inside, map the current item and its item number from the inputs list.
- Wire what should happen afterwards to the Done exit. It runs once, after every item.
- To gather each item’s result, connect the last block of the item branch back to the loop’s Collect input. The loop then outputs Results.
Items may run at the same time, so do not rely on one item finishing before the next starts.
If an item fails decides whether the loop stops after the items already running, or carries on and collects the errors. The loop outputs how many items succeeded and failed.
Reuse an automation
Section titled “Reuse an automation”When several automations do the same steps, build those steps once as their own automation and call it.
Make an automation callable
Section titled “Make an automation callable”- Create an automation with the Called by an automation trigger.
- On the trigger, declare the Inputs callers must give, and the Returns handed back, mapped from blocks that run after the trigger.
- Test it with sample inputs, then publish it. Only published automations can be called.
Call it
Section titled “Call it”- In the calling automation, open the block library’s Automations group and add the automation you want to call. This adds a Run automation block with the called automation’s inputs and returns filled in.
- Map its Inputs.
- Wire both exits: Completed, where its returned values are typed, and Failed, where an error code says why.
Each call runs the called automation’s live published version and waits for it to finish, approvals included. The called run has its own page under Runs, linked from the caller’s run.
- Calls cannot loop back, cannot nest more than 3 levels deep, and one run can make at most 100 calls.
- If you change the called automation’s inputs or returns in a way that would break callers, their next call fails until they are updated. The Run automation block keeps a copy of the contract from when it was added; adding it again from the Automations group takes the current one.
- A draft run of the caller starts the called automation’s published version with its writes held, so the called automation must be published.