Scripting Actions in the iOS 12 Shortcuts App

The iOS 12 Shortcuts app introduced robust automation capabilities to Apple devices, anchored by a dedicated "Scripting" category that allows users to build complex, logic-driven workflows. This article provides a comprehensive overview of the core scriptable actions available in iOS 12, detailing the tools used for control flow, data manipulation, network requests, and system interactions.

Control Flow and Logic

Control flow actions allow users to direct the execution path of a shortcut based on conditions or loops:

  • If / Otherwise / End If: Evaluates whether input meets specific criteria (e.g., equals, contains, is greater than) and executes corresponding actions.
  • Repeat: Runs an enclosed block of actions a set number of times.
  • Repeat with Each: Iterates through a list of items, executing the enclosed actions on each item individually.
  • Wait: Pauses execution for a specified number of seconds.
  • Wait to Return: Pauses execution until the user returns to the Shortcuts app from another application.
  • Exit Shortcut: Immediately stops the shortcut execution.

Variables and Data Storage

These actions manage how information is captured, modified, and passed between steps:

  • Set Variable: Assigns data to a named variable for later retrieval.
  • Get Variable: Recalls a previously defined variable.
  • Add to Variable: Appends an item to an existing variable list.
  • Dictionary: Creates structured key-value pairs (JSON format).
  • Get Dictionary Value: Retrieves a specific value associated with a key from a dictionary.
  • Set Dictionary Value: Inserts or updates a key-value pair within a dictionary.
  • List: Creates a static collection of items.
  • Choose from List: Prompts the user to select one or multiple items from a list.
  • Get Item from List: Extracts an item by index (first, last, random, or specific index).

Network, Web, and Advanced Execution

iOS 12 includes advanced scripting tools that interact with servers and external APIs:

  • Get Contents of URL: Performs HTTP requests (GET, POST, PUT, DELETE) with custom headers, request bodies, and JSON payloads.
  • Run Script Over SSH: Connects to a remote server via SSH to execute shell commands and return the standard output.
  • Base64 Encode / Decode: Encodes text or files into Base64 format or decodes Base64 data back to raw formats.
  • Generate Hash: Calculates MD5, SHA-1, SHA-256, or SHA-512 checksums for text or files.
  • Run Shortcut: Calls another shortcut from within the current shortcut, enabling modular script design.

User Interaction and Notifications

These actions solicit user input or present feedback:

  • Ask for Input: Prompts the user to enter text, numbers, dates, or URLs via a pop-up dialog.
  • Show Alert: Displays a customizable alert message with optional cancel and confirmation buttons.
  • Show Notification: Posts a local system notification containing text or attachments.
  • Show Result: Displays text or variable contents in a standard modal dialog.
  • Vibrate Device: Triggers haptic feedback.

Calculations and Number Formatting

  • Calculate: Performs basic arithmetic operations (+, -, ×, ÷) on numbers.
  • Calculate Statistics: Computes average, minimum, maximum, sum, median, or standard deviation from a list of numbers.
  • Format Number: Formats numerical values to specific decimal places or localized conventions.
  • Round Number: Rounds a number up, down, or to the nearest whole integer or decimal point.

Device and App Controls

Scriptable system-level actions allow direct toggling and app launching:

  • Open App: Launches a selected iOS application.
  • Continue in App: Transfers the running shortcut from the widget or Siri interface directly into the main Shortcuts app.
  • Set Low Power Mode: Toggles low-power mode on or off.
  • Set Wi-Fi / Bluetooth / Cellular Data: Enables or disables device connectivity states.
  • Set Do Not Disturb: Turns Do Not Disturb on or off, with optional duration parameters.