Use variables in Shortcuts
In Shortcuts, you can:
Place a variable in a text field: For example, you can place a variable in the text field of an email shortcut, letting you choose a specific salutation (such as “Dear Sir” or “Dear Madam”) when you run the shortcut.
Use a variable to replace an action’s parameter (a setting inside an action): You can embed a variable in an action. For example, you can place an Ask Each Time variable in the Repeat parameter of a Play Music action, letting you choose whether or not to repeat a song when you run the shortcut.
Variables are represented by small, pill-shaped tokens.
Add a variable to a text field
In My Shortcuts , tap on the shortcut you want to modify, then tap any text field in an action.
Note: Not all actions contain text fields.
The Variables bar and keyboard are displayed.
Tap Variables.
The Variables bar expands, displaying the Select Magic Variable button and all of the manual or Magic Variables made available by previous actions.
Tap Select Magic Variable.
The shortcut editor displays an alternate view showing each action’s output as an available variable, ready for selection.
Tap the variable that you want to add to the text field.
The variable is placed inline in the text field (at the original insertion point). This is where the stored data will be placed when the shortcut is run.
You can continue to use the Variables bar to access Magic Variables that you may want to add.
Optional: To add a special variable, tap Done, tap a text field, tap Variables, then tap one of the following special variables that appear as tokens:
Ask Each Time: Prompts you to enter text in its place when the shortcut is run.
Clipboard: Inserts what you’ve most recently copied at the time the shortcut runs.
Current Date: Inserts today’s date and time, formatted to your preference.
Shortcut Input: Grabs the input that was passed into the beginning of the shortcut (applicable for shortcuts that are set to run in another app).
Note: You may need to swipe left to see all of the special variables.
The special variable is placed inline in the text field (at the original insertion point).
Remove a variable
In My Shortcuts , tap on the shortcut you want to modify.
Do one of the following:
In a text field: Position the cursor in front of the variable in the text field, then tap in the onscreen keyboard.
In an action’s parameter: Tap the variable token to select it, then tap Clear.
Pass the contents of a variable as input into another action
In My Shortcuts , tap on the shortcut you want to modify.
Do one of the following:
In a text field: Position the cursor where you want to place a variable, then tap .
In an action’s parameter: Tap the variable token to select it, then tap Select Magic Variable.
Select a magic variable from the within the action list.
When the shortcut is run, the content of the variable is retrieved and passed as input into the selected action.
Replace a parameter with a variable
You can replace an action’s parameter (a setting inside an action) with a variable to dynamically switch between the settings of an action while a shortcut is running.
Important: For parameters with on/off switches, use a 1 or 0 to set the button as active or inactive, respectively.
In My Shortcuts , tap on the shortcut you want to modify.
In the shortcut editor, tap any parameter name, then choose a replacement variable from the list that appears.
Note: You may need to tap and hold some parameters to replace them with a variable.
In this example, the Ask Each Time variable replaces the Repeat parameter in the Play Music action.
When the shortcut runs, you’re prompted to choose a Repeat parameter.