Sub topic 2
Actions: the building blocks and how output feeds the next step
This chapter explains the working model behind every shortcut: each action takes input, does one job, and produces output that flows to the next action. It assumes you can open the Shortcuts app, create a new shortcut, and add actions from the sidebar or the search field. If you have done that once, you have the prerequisites. Variables get their own chapter, so here we focus on the default flow of data from one step to the next.
What an action is
An action is one step in a shortcut. It performs a single task, such as getting text, changing text, resizing an image, or showing an alert. A shortcut is an ordered list of actions that run from top to bottom.
Most actions have three parts:
- Input. The content the action works on. It usually comes from the action above it.
- Parameters. Settings you choose in the action itself, such as which file format to convert to or what text to match.
- Output. The content the action produces. The next action receives it as input.
Some actions have no input because they create content from nothing, such as Text or Current Date. Some have no output because they only cause an effect, such as Show Notification.
The default flow: output becomes input
When you place an action below another, the Shortcuts app connects them automatically. The output of the upper action becomes the input of the lower one. You do not draw a wire or name anything. The order of the list is the wiring.
Here is a small shortcut you can build to see this in practice:
- Create a new shortcut and name it "Flow Test".
- Add a Text action and type
hello world. - Add a Change Case action. Set it to UPPERCASE.
- Add a Show Result action.
- Click the Run button (the triangle) in the editor toolbar.
A result window shows HELLO WORLD. You never told Change Case where its text came from. It took the output of the Text action because that action sits directly above it.
Reading an action's input
Each action that accepts input declares what kinds of content it can use. Change Case accepts text. Resize Image accepts images. Get Contents of URL accepts a URL. If the previous output is not the right kind, the Shortcuts app tries to convert it. If it cannot, the action may fail or do nothing.
Conversion works in your favour in many cases. A file containing plain text can be treated as text. A rich-text document can be turned into plain text. A number can be treated as text. It works against you when the conversion loses information, for example when an image is passed to an action that wants text and the result is only a file name.
Two practical habits help:
- Check the type of the output of each action when you build, not only at the end. Run the shortcut after adding each action or two.
- Look at the preview of the previous action's output (covered below), so you know what the next action will see.
Single items and lists
Many actions return a list of items rather than one. Find Files, Get Contents of Folder, Split Text, and Select Photos can all return several items. When the next action receives a list, how it behaves depends on the action:
- Some actions process each item separately and return a list of results. Change Case applied to a list of three lines returns three changed lines.
- Some actions work on the list as a whole. Combine Text joins the items into one piece of text. Calculate Statistics works across all items.
- Some actions use only the first item, or only the last. Check the action's description if you are unsure.
If you need exact control over each item, wrap the steps in a Repeat with Each action. That action is covered in the control flow chapter. For now, the key point is that a list passes through the chain just as a single value does.
A worked example: tidy a list of names
This example builds a shortcut with several actions and shows how the data changes at each step. It takes a block of text with names on separate lines, sorts them, and shows them in a combined result.
- Add a Text action with these lines:
``text mira anil zoe ben ``
- Add Split Text. Set it to split by New Lines. Output: a list of four items.
- Add Change Case. Choose Capitalize Every Word. Output: a list of four capitalized names.
- Add Sort. Choose Alphabetically, order A to Z. Output: the list, sorted.
- Add Combine Text. Choose Custom and set the separator to a comma and a space. Output: one piece of text.
- Add Show Result.
The result is Anil, Ben, Mira, Zoe.
The table below tracks the data type as it moves through the chain.
| Step | Action | Output type | Output value |
|---|---|---|---|
| 1 | Text | Text | The four-line block |
| 2 | Split Text | List of text | `mira`, `anil`, `zoe`, `ben` |
| 3 | Change Case | List of text | `Mira`, `Anil`, `Zoe`, `Ben` |
| 4 | Sort | List of text | `Anil`, `Ben`, `Mira`, `Zoe` |
| 5 | Combine Text | Text | `Anil, Ben, Mira, Zoe` |
| 6 | Show Result | None | Displays the text |
Notice how the shape of the data changes: one piece of text becomes a list, then returns to one piece of text. Knowing the shape at each step is the most useful skill in this chapter.
Inspecting output while you build
You can see what an action produced without adding Show Result everywhere. After you run a shortcut in the editor, each action that ran can show a result preview below it. Click the preview to open a larger view of the content. For a list, you see each item. For a file, you see its name and a quick look.
The Shortcuts app also shows the input and output for each action when you run the shortcut step by step. The debugging chapter covers that in full. For now, use the preview as a quick check after each run.
Actions that change the flow of data
A few actions do not follow the simple "output feeds next input" pattern:
- Nothing. This action outputs nothing. Use it to clear the data so the next action starts with no input.
- Set Variable and Add to Variable. These store a value for later. They pass their input through to the next action unchanged.
- Get Variable. This action ignores the output above and outputs the stored value instead.
- Text, Number, Date, and similar actions. These create new content. They ignore what comes above and start a fresh output.
The consequence is that a "source" action in the middle of a chain breaks the default flow. Anything above it no longer reaches the actions below it unless you saved it to a variable first.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| An action does nothing or returns empty output | The previous action produced no output, or a type the action cannot use | Run the shortcut and check the preview of the step above |
| Only the first item appears in the result | The action works on a single item, not a list | Use Repeat with Each, or an action that accepts lists |
| Everything appears on one line | The list was combined with the default separator | Set a custom separator in Combine Text |
| A later action uses the wrong data | A source action in between replaced the default flow | Use a variable to keep the earlier value |
| A file shows only a name where you expected text | A file was passed to an action that wanted text | Add Get Text from Input, or an action that reads file contents |
Editing the order of actions
Because order is the wiring, moving an action changes what it receives. Drag an action by its left edge to a new position, and the Shortcuts app reconnects input and output based on the new order. After any move, run the shortcut again and check the previews, since a type mismatch can appear without warning.
To remove an action, select it and press Delete. The actions above and below become neighbours, and the lower one receives the output of whatever is now above it. This is useful for trimming a shortcut and a common source of confusion if you delete a step that other steps relied on.
Summary
- A shortcut is an ordered list of actions. Each action has input, parameters, and output.
- By default, an action's output becomes the input of the action below it.
- The Shortcuts app converts content between types when it can. It can fail or lose detail when it cannot.
- Lists pass through the chain. Some actions handle each item, some handle the whole list, and some use one item.
- Actions that create new content, such as Text, break the default flow.
- Run the shortcut and check each preview often. Do this while you build, not only at the end.
Exercise
You build a shortcut with these actions in order: Text ("red,green,blue"), Split Text (separator: Custom, comma), Text ("done"), Combine Text (separator: New Line), Show Result. The result shows only "done". Why does this happen, and how would you change the shortcut so the result shows "red", "green", "blue", and "done" on separate lines?
Show answer
The second Text action creates new content and ignores the list from Split Text, so Combine Text only receives "done". To fix it, store the split list in a variable right after Split Text, or move the "done" Text action above the Split Text action's position in a way that keeps the list as the flow. A simple approach is to add Set Variable after Split Text, then after the Text ("done") action use Add to Variable to append "done" to that list, then Combine Text on the variable. The result is "red", "green", "blue", "done" on separate lines.
Exercise
A Change Case action set to UPPERCASE is applied to a list of three items. What does it return, and which action would you use to turn the result into one piece of text?
Show answer
It returns a list of three uppercase items, because Change Case handles each item separately. Use Combine Text to join them into a single piece of text, choosing a separator such as New Lines or a custom string.