Skip to content

Scripting

Control flow, variables, logic, prompts, and general shortcut utilities.

import Scripting;

addToVariable

Appends this action's input to the specified variable, creating the variable if it does not exist.

This allows you to make a variable hold multiple items.

addToVariable(WFVariableName: Any, WFInput: Any) -> Any
ParameterTypeDefault
WFVariableNameAny
WFInputAny

Shortcuts action: is.workflow.actions.appendvariable

adjustDate

Adds or subtracts an amount of time from the date passed into the action.

adjustDate(WFDate: Text, WFAdjustOperation: Text, WFDuration: Number) -> Text
ParameterTypeDefault
WFDateText
WFAdjustOperationText"Add"
WFDurationNumber

This action supports decimal numbers when adding or subtracting seconds, minutes, hours, or days. Otherwise only integers are supported.

Shortcuts action: is.workflow.actions.adjustdate

askForInput

Displays a dialog prompting the user to enter a piece of information.

askForInput() -> Any

Shortcuts action: is.workflow.actions.ask

base64Encode

Encodes or decodes text or files using Base64 encoding.

base64Encode(WFEncodeMode: Text, WFBase64LineBreakMode: Text, WFInput: Any) -> Text
ParameterTypeDefault
WFEncodeModeText"Encode"
WFBase64LineBreakModeText"Every 76 Characters"
WFInputAny

Shortcuts action: is.workflow.actions.base64encode

chooseFromList

Presents a menu of the items passed as input to the action and outputs the user's selection.

chooseFromList(WFInput: Any, WFChooseFromListActionPrompt: Text, WFChooseFromListActionSelectMultiple: Boolean, WFChooseFromListActionSelectAll: Boolean) -> Any
ParameterTypeDefault
WFInputAny
WFChooseFromListActionPromptText""
WFChooseFromListActionSelectMultipleBooleanfalse
WFChooseFromListActionSelectAllBooleanfalse

Shortcuts action: is.workflow.actions.choosefromlist

chooseFromMenu

Presents a menu and runs different actions based on which menu item was chosen.

chooseFromMenu(WFMenuPrompt: Text, WFMenuItems: List<Any>)
ParameterTypeDefault
WFMenuPromptText
WFMenuItemsList<Any>One,Two

Shortcuts action: is.workflow.actions.choosefrommenu

comment

This action lets you explain how part of a shortcut works. When run, this action does nothing.

comment(WFCommentActionText: Text)
ParameterTypeDefault
WFCommentActionTextText

Shortcuts action: is.workflow.actions.comment

continueInShortcutsApp

Switches into the Shortcuts app and continues to the next action.

continueInShortcutsApp()

Shortcuts action: is.workflow.actions.handoff

convertTimeZone

Converts the specified date and time from one time zone to another.

convertTimeZone(Date: Text, SourceTimeZone: Text, DestinationTimeZone: Text) -> Text
ParameterTypeDefault
DateText
SourceTimeZoneText
DestinationTimeZoneText

Shortcuts action: is.workflow.actions.converttimezone

count

Counts the number of items, characters, words, sentences, or lines passed as input.

count(WFCountType: Text, Input: Any) -> Number
ParameterTypeDefault
WFCountTypeText"Items"
InputAny

This is just like the Count in Sesame Street, but instead of a vampire, it's a Shortcuts action.

Shortcuts action: is.workflow.actions.count

createQrCode

Creates a Quick Response (QR) code for the specified text.

createQrCode(WFText: Text, WFQRForegroundColor: Text, WFQRBackgroundColor: Text, WFQRRounded: Boolean, WFQRErrorCorrectionLevel: Text) -> Any
ParameterTypeDefault
WFTextText
WFQRForegroundColorText[object Object]
WFQRBackgroundColorText[object Object]
WFQRRoundedBooleanfalse
WFQRErrorCorrectionLevelText"Medium"

Shortcuts action: is.workflow.actions.generatebarcode

date

Passes the specified date and time to the next action.

date(WFDateActionMode: Text, WFDateActionDate: Text, WFEventOccurrenceMode: Text, WFEventOccurrenceSpecifiedYear: Text) -> Text
ParameterTypeDefault
WFDateActionModeText"Current Date"
WFDateActionDateText
WFEventOccurrenceModeText"Next Occurrence"
WFEventOccurrenceSpecifiedYearText

Shortcuts action: is.workflow.actions.date

dictionary

Passes the specified list of key-value pairs to the next action as a dictionary.

dictionary(WFItems: Dictionary) -> Dictionary
ParameterTypeDefault
WFItemsDictionary

When coerced to text, the dictionary is represented as JSON.

Shortcuts action: is.workflow.actions.dictionary

dismissSiriAndContinue

Switches into the Shortcuts app and continues to the next action.

dismissSiriAndContinue()

Shortcuts action: is.workflow.actions.dismisssiri

findApps

findApps()

Shortcuts action: is.workflow.actions.filter.apps

formatDate

Formats a date and time into text.

formatDate(WFDateFormatStyle: Text, WFRelativeDateFormatStyle: Text, WFTimeFormatStyle: Text, WFISO8601IncludeTime: Boolean, WFDateFormat: Text, WFDate: Text, WFLocale: Text) -> Text
ParameterTypeDefault
WFDateFormatStyleText"Short"
WFRelativeDateFormatStyleText"Medium"
WFTimeFormatStyleText"Short"
WFISO8601IncludeTimeBoolean
WFDateFormatText
WFDateText
WFLocaleText

Custom format strings use the format patterns from Unicode Technical Standard #35 (unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns).

Shortcuts action: is.workflow.actions.format.date

formatFileSize

Formats a file size into text.

formatFileSize(WFFileSizeFormat: Text, WFFileSizeIncludeUnits: Boolean, WFFileSize: Number) -> Text
ParameterTypeDefault
WFFileSizeFormatText"Automatic"
WFFileSizeIncludeUnitsBooleantrue
WFFileSizeNumber

1000 bytes are shown as 1 KB.

Shortcuts action: is.workflow.actions.format.filesize

formatNumber

Formats a number into text.

formatNumber(WFNumber: Number, WFNumberFormatDecimalPlaces: Number) -> Text
ParameterTypeDefault
WFNumberNumber
WFNumberFormatDecimalPlacesNumber2

Shortcuts action: is.workflow.actions.format.number

generateHash

Generates a MD5/SHA1 hash from the input.

generateHash(WFHashType: Text, WFInput: Any) -> Text
ParameterTypeDefault
WFHashTypeText"MD5"
WFInputAny

Shortcuts action: is.workflow.actions.hash

getAddressesFromInput

Returns any street addresses found in the output from the previous action.

getAddressesFromInput(WFInput: Any) -> Any
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.address

getContactsFromInput

Gets contacts from the result of the previous action.

getContactsFromInput(WFInput: Any) -> Any
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.contacts

getDatesFromInput

Returns any dates found in the output from the previous action.

getDatesFromInput(WFInput: Any) -> Text
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.date

getDetailsOfAppStoreApp

getDetailsOfAppStoreApp()

Shortcuts action: is.workflow.actions.properties.appstore

getDictionaryFromInput

Makes a dictionary from the text passed as input. JSON (like {"foo": "bar"}), key-value pairs (like foo=bar&baz=biz), and XML-based plist are supported.

getDictionaryFromInput(WFInput: Any) -> Dictionary
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.dictionary

getDictionaryValue

Gets the value for the specified key in the dictionary passed into the action.

getDictionaryValue(WFGetDictionaryValueType: Text, WFDictionaryKey: Text, WFInput: Any) -> Any
ParameterTypeDefault
WFGetDictionaryValueTypeText"Value"
WFDictionaryKeyText
WFInputAny

You can reference values deep inside of a dictionary by providing multiple keys separated by dots. For example, to get the value "soup" from the dictionary {"beverages": [{"favorite": "soup"}]}, you can specify the key path "beverages.1.favorite".

Shortcuts action: is.workflow.actions.getvalueforkey

getEmailAddressesFromInput

Returns any email addresses found in the output from the previous action.

getEmailAddressesFromInput(WFInput: Text) -> Text
ParameterTypeDefault
WFInputText

Shortcuts action: is.workflow.actions.detect.emailaddress

getFileOfType

Returns a particular file type from the input.

getFileOfType(WFFileType: Text, WFInput: Any) -> Any
ParameterTypeDefault
WFFileTypeText"public.rtf"
WFInputAny

Shortcuts action: is.workflow.actions.gettypeaction

getImagesFromInput

Gets images from the result of the previous action.

For example, this action can get the album art of a song, or all the images on a web page.

getImagesFromInput(WFInput: Any) -> Any
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.images

getItemFromList

Returns one or more items from the list passed as input. You can get the first item, the last item, a random item, the item at a particular index, or items in a range of indexes.

getItemFromList(WFItemSpecifier: Text, WFItemIndex: Number, WFItemRangeStart: Number, WFItemRangeEnd: Number, WFInput: Any) -> Any
ParameterTypeDefault
WFItemSpecifierText"First Item"
WFItemIndexNumber
WFItemRangeStartNumber
WFItemRangeEndNumber
WFInputAny

Lists use one-based indexing, so the first item is at index 1, the second is at index 2, etc.

Shortcuts action: is.workflow.actions.getitemfromlist

getName

Returns the name of every item passed as input. Depending on the input, this could be a file name, the title of a website, the title of a calendar event, etc.

getName(WFInput: Any, GetWebPageTitle: Boolean) -> Text
ParameterTypeDefault
WFInputAny
GetWebPageTitleBooleantrue

Shortcuts action: is.workflow.actions.getitemname

getNumbersFromInput

Returns numbers from the previous action's output.

getNumbersFromInput(WFInput: Number) -> Number
ParameterTypeDefault
WFInputNumber

Shortcuts action: is.workflow.actions.detect.number

getObjectOfClass

Returns a particular object class from the input.

getObjectOfClass(Class: Text, Input: Any) -> Any
ParameterTypeDefault
ClassText
InputAny

Shortcuts action: is.workflow.actions.getclassaction

getPhoneNumbersFromInput

Returns any phone numbers found in the output from the previous action.

getPhoneNumbersFromInput(WFInput: Text) -> Text
ParameterTypeDefault
WFInputText

Shortcuts action: is.workflow.actions.detect.phonenumber

getTextFromInput

Returns text from the previous action's output.

For example, this action can get the name of a photo or song, or the text of a web page.

getTextFromInput(WFInput: Any) -> Text
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.detect.text

getTimeBetweenDates

Subtracts the specified date from the date passed into the action. For example, this action could get the number of minutes from now until a calendar event passed in as input.

getTimeBetweenDates(WFTimeUntilFromDate: Text, WFInput: Text, WFTimeUntilUnit: Text) -> Number
ParameterTypeDefault
WFTimeUntilFromDateText
WFInputText
WFTimeUntilUnitText"Minutes"

This action outputs a negative number if the input date takes place before the specified date.

Shortcuts action: is.workflow.actions.gettimebetweendates

getType

Returns the type of every item passed as input. For example, if a URL is passed, this action will return “URL”.

getType(WFInput: Any) -> Text
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.getitemtype

getUrlsFromInput

Returns any links found in the output from the previous action.

getUrlsFromInput(WFInput: Text) -> Text
ParameterTypeDefault
WFInputText

Shortcuts action: is.workflow.actions.detect.link

getVariable

Gets the value of the specified variable and passes it to the next action.

getVariable(WFVariable: Any) -> Any
ParameterTypeDefault
WFVariableAny

Shortcuts action: is.workflow.actions.getvariable

if

Tests if a condition is true, and if so, runs the actions inside. Otherwise, the actions under “Otherwise” are run.

if()

Shortcuts action: is.workflow.actions.conditional

input

Stops execution of the current shortcut and dismisses the shortcut on screen. No more actions will be run after this action.

input(WFInputType: Text, WFInputSurface: Text, WFNoInputBehavior: Text, WFStopAndRespondResponse: Text, WFAskForType: Text)
ParameterTypeDefault
WFInputTypeText
WFInputSurfaceText""
WFNoInputBehaviorText"Stop and Respond"
WFStopAndRespondResponseText
WFAskForTypeText"Photos"

Shortcuts action: is.workflow.actions.input

list

Allows you to specify a list of items to be passed to the next action.

list(WFItems: List<Any>) -> Any
ParameterTypeDefault
WFItemsList<Any>One,Two

If you specify a variable, the contents of that variable will be included in the list.

Shortcuts action: is.workflow.actions.list

nothing

This action does nothing and produces no output. It is useful to separate blocks of actions, or to explicitly pass an empty input to an action.

nothing() -> Any

Shortcuts action: is.workflow.actions.nothing

openApp

Opens the specified app.

openApp(WFSelectedApp: Text, WFAppName: Text, WFWindowingFormat: Text) -> Any
ParameterTypeDefault
WFSelectedAppText
WFAppNameText
WFWindowingFormatText"Full Screen"

Shortcuts action: is.workflow.actions.openapp

openFile

Opens the input as a file in the specified app.

openFile(WFOpenInAskWhenRun: Boolean, WFSelectedApp: Text, WFAppName: Text, WFInput: Any)
ParameterTypeDefault
WFOpenInAskWhenRunBooleanfalse
WFSelectedAppText
WFAppNameText
WFInputAny

Shortcuts action: is.workflow.actions.openin

repeat

Repeats the contained actions, running them the specified number of times.

repeat(WFRepeatCount: Number) -> Any
ParameterTypeDefault
WFRepeatCountNumber1

Shortcuts action: is.workflow.actions.repeat.count

repeatWithEach

Takes a list of items as input, and runs the contained actions once for each item in the list.

repeatWithEach(WFInput: Any) -> Any
ParameterTypeDefault
WFInputAny

Shortcuts action: is.workflow.actions.repeat.each

runApplescript

This action executes an AppleScript.

runApplescript(Input: Any, Script: Text) -> Any
ParameterTypeDefault
InputAny
ScriptText`"on run
(* Your script goes here *)
return input

end run"` |

Shortcuts action: is.workflow.actions.runapplescript

runJavascriptForMacAutomation

This action executes a JavaScript for Automation (JXA) script.

runJavascriptForMacAutomation(Input: Any, Script: Text) -> Any
ParameterTypeDefault
InputAny
ScriptText`"function run(input, parameters) {
// Your script goes here
return input;

}"` |

Shortcuts action: is.workflow.actions.runjavascriptforautomation

runScriptOverSsh

Runs a script on a remote computer over SSH.

runScriptOverSsh(WFSSHScript: Text, WFSSHHost: Text, WFSSHPort: Text, WFSSHUser: Text, WFSSHAuthenticationType: Text, WFSSHPassword: Text, WFSSHKey: Text, WFInput: Any) -> Any
ParameterTypeDefault
WFSSHScriptText
WFSSHHostText
WFSSHPortText"22"
WFSSHUserText
WFSSHAuthenticationTypeText"Password"
WFSSHPasswordText
WFSSHKeyText
WFInputAny

Shortcuts action: is.workflow.actions.runsshscript

runShellScript

This action executes a UNIX shell script. The script will execute starting in your user’s home directory.

runShellScript(Script: Text, Shell: Text, Input: Any, InputMode: Text, RunAsRoot: Boolean) -> Any
ParameterTypeDefault
ScriptText
ShellText
InputAny
InputModeText"to stdin"
RunAsRootBooleanfalse

Shortcuts action: is.workflow.actions.runshellscript

scanQrOrBarcode

Scans a QR code or barcode using the camera, and returns the text/URL that is found.

scanQrOrBarcode() -> Any

Shortcuts action: is.workflow.actions.scanbarcode

setDictionaryValue

Sets a value in the dictionary passed into the action.

setDictionaryValue(WFDictionaryKey: Text, WFDictionaryValue: Text, WFDictionary: Any) -> Dictionary
ParameterTypeDefault
WFDictionaryKeyText
WFDictionaryValueText
WFDictionaryAny

Shortcuts action: is.workflow.actions.setvalueforkey

setName

Sets the name of the item passed as input.

setName(WFName: Text, WFDontIncludeFileExtension: Boolean, WFInput: Any) -> Any
ParameterTypeDefault
WFNameText
WFDontIncludeFileExtensionBoolean
WFInputAny

Shortcuts action: is.workflow.actions.setitemname

setVariable

Sets the value of the specified variable to the input of this action.

setVariable(WFInput: Any, WFVariableName: Any)
ParameterTypeDefault
WFInputAny
WFVariableNameAny

Shortcuts action: is.workflow.actions.setvariable

showContentAttribution

Shows the Content Source of Input contents

showContentAttribution(Input: Any)
ParameterTypeDefault
InputAny

Shortcuts action: is.workflow.actions.debug.contentattribution

stopAndOutput

Stops execution of the current shortcut, and outputs content. This action is useful when: • Running a shortcut from another shortcut (using the Run Shortcut action). The output will be used as the output of the Run Shortcut action. • Running a shortcut from Quick Actions in Finder on macOS. The output will be saved as a file alongside the files selected in Finder. • Running a shortcut from Services on macOS. The output will replace the selected text, if applicable. • Or, when running a shortcut from another location that supports output, like the command-line or the Shortcuts URL scheme.

No more actions will be run after this action.

stopAndOutput(WFOutput: Text, WFNoOutputSurfaceBehavior: Text, WFResponse: Text)
ParameterTypeDefault
WFOutputText""
WFNoOutputSurfaceBehaviorText"Do Nothing"
WFResponseText""

Shortcuts action: is.workflow.actions.output

stopThisShortcut

Stops execution of the current shortcut and dismisses the shortcut on screen. No more actions will be run after this action.

stopThisShortcut()

Shortcuts action: is.workflow.actions.exit

unknownIntent

unknownIntent(ShowWhenRun: Boolean)
ParameterTypeDefault
ShowWhenRunBooleantrue

Shortcuts action: is.workflow.actions.sirikit.donation.handle

unknownUserActivity

unknownUserActivity()

Shortcuts action: is.workflow.actions.useractivity.open

useModel

Use a model to handle complex requests in your shortcuts.

useModel(WFLLMPrompt: Text, WFLLMModel: Text, FollowUp: Boolean, WFGenerativeResultType: Text) -> Any
ParameterTypeDefault
WFLLMPromptText
WFLLMModelText
FollowUpBooleanfalse
WFGenerativeResultTypeText

Shortcuts action: is.workflow.actions.askllm

wait

Waits for the specified number of seconds before continuing with the next action.

wait(WFDelayTime: Number)
ParameterTypeDefault
WFDelayTimeNumber1

Shortcuts action: is.workflow.actions.delay

waitToReturn

Pauses execution until you leave the Shortcuts app and return to it.

This action might be useful after an action that switches apps, to pause execution until you return to the Shortcuts app.

This action will only take effect when running shortcuts in the Shortcuts app.

waitToReturn()

Shortcuts action: is.workflow.actions.waittoreturn