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(variable: Text, input: Any) -> Any
ParameterTypeDefault
variableText—
inputAny—

Shortcuts action: is.workflow.actions.appendvariable

adjustDate ​

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

adjustDate(date: Text, operation: Enum, duration: Number) -> Date
ParameterTypeDefault
dateText—
operationAdd | Subtract | Get Start of Minute | Get Start of Hour | Get Start of Day | Get Start of Week | Get Start of Month | Get Start of Year"Add"
durationNumber—

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(WFAskActionPrompt: Any, WFInputType: AskForInputType, WFAskActionDefaultAnswer: Any, WFAskActionDefaultAnswerNumber: Any, urlAnswer: Any, WFAskActionDefaultAnswerURL: Any, WFAskActionDefaultAnswerDate: Any, WFAskActionDefaultAnswerTime: Any, WFAskActionDefaultAnswerDateAndTime: Any, WFAskActionAllowsDecimalNumbers: Boolean, WFAskActionAllowsNegativeNumbers: Boolean, WFAllowsMultilineText: Boolean) -> Any
ParameterTypeDefault
WFAskActionPromptAny—
WFInputTypeText | Number | URL | Date | Time | Date and Time—
WFAskActionDefaultAnswerAny—
WFAskActionDefaultAnswerNumberAny—
urlAnswerAny—
WFAskActionDefaultAnswerURLAny—
WFAskActionDefaultAnswerDateAny—
WFAskActionDefaultAnswerTimeAny—
WFAskActionDefaultAnswerDateAndTimeAny—
WFAskActionAllowsDecimalNumbersBoolean—
WFAskActionAllowsNegativeNumbersBoolean—
WFAllowsMultilineTextBoolean—

Shortcuts action: is.workflow.actions.ask

base64Encode ​

Encodes or decodes text or files using Base64 encoding.

base64Encode(mode: Enum, lineBreaks: Enum, input: Any) -> Text
ParameterTypeDefault
modeEncode | Decode"Encode"
lineBreaksNone | Every 64 Characters | Every 76 Characters"Every 76 Characters"
inputAny—

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(list: Any, prompt: Text, selectMultiple: Boolean, selectAllInitially: Boolean) -> Any
ParameterTypeDefault
listAny—
promptText""
selectMultipleBooleanfalse
selectAllInitiallyBooleanfalse

Shortcuts action: is.workflow.actions.choosefromlist

chooseFromMenu ​

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

chooseFromMenu(prompt: Text, items: List<Any>)
ParameterTypeDefault
promptText—
itemsList<Any>One,Two

Shortcuts action: is.workflow.actions.choosefrommenu

convertTimeZone ​

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

convertTimeZone(date: Text, timeZone: Text, destinationTimeZone: Text) -> Date
ParameterTypeDefault
dateText—
timeZoneText—
destinationTimeZoneText—

Shortcuts action: is.workflow.actions.converttimezone

convertToFileType ​

Returns a particular file type from the input.

convertToFileType(type: Text, input: Any) -> File
ParameterTypeDefault
typeText"public.rtf"
inputAny—

Shortcuts action: is.workflow.actions.gettypeaction

count ​

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

count(type: Enum, input: Any) -> Number
ParameterTypeDefault
typeItems | Characters | Words | Sentences | Lines"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(text: Text, foregroundColor: Text, backgroundColor: Text, rounded: Boolean, errorCorrection: Enum) -> Image
ParameterTypeDefault
textText—
foregroundColorText"#000000"
backgroundColorText"#FFFFFF"
roundedBooleanfalse
errorCorrectionLow | Medium | Quartile | High"Medium"

Shortcuts action: is.workflow.actions.generatebarcode

date ​

Passes the specified date and time to the next action.

date(WFDateActionMode: Text, WFDateActionDate: Text, occurrence: Enum, year: Text) -> Date
ParameterTypeDefault
WFDateActionModeText"Current Date"
WFDateActionDateText—
occurrenceNext Occurrence | Specified Year"Next Occurrence"
yearText—

Shortcuts action: is.workflow.actions.date

dictionary ​

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

dictionary(items: Dictionary) -> Dictionary
ParameterTypeDefault
itemsDictionary—

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

Shortcuts action: is.workflow.actions.dictionary

dismissSiri ​

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

dismissSiri()

Shortcuts action: is.workflow.actions.dismisssiri

findApps ​

findApps(sortBy: Enum, order: Enum, WFContentItemLimit: Boolean, WFContentItemLimitNumber: Number) -> App
ParameterTypeDefault
sortByName—
orderLatest First | Oldest First—
WFContentItemLimitBooleanfalse
WFContentItemLimitNumberNumber5

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

formatDate ​

Formats a date and time into text.

formatDate(dateFormat: Enum, alternateFormat: Enum, timeFormat: Enum, includeIso8601Time: Boolean, formatString: Text, date: Text, locale: Text) -> Text
ParameterTypeDefault
dateFormatNone | Short | Medium | Long | Relative | RFC 2822 | ISO 8601 | Custom"Short"
alternateFormatShort | Medium | Long"Medium"
timeFormatNone | Short | Medium | Long | Relative"Short"
includeIso8601TimeBoolean—
formatStringText—
dateText—
localeText—

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(format: Enum, includeUnits: Boolean, fileSize: Number) -> Text
ParameterTypeDefault
formatAutomatic | Bytes | KB | MB | GB | TB | PB | EB | ZB | YB or Higher"Automatic"
includeUnitsBooleantrue
fileSizeNumber—

1000 bytes are shown as 1 KB.

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

formatNumber ​

Formats a number into text.

formatNumber(number: Number, WFNumberFormatDecimalPlaces: Number) -> Text
ParameterTypeDefault
numberNumber—
WFNumberFormatDecimalPlacesNumber2

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

generateHash ​

Generates a MD5/SHA1 hash from the input.

generateHash(type: Enum, input: File) -> Text
ParameterTypeDefault
typeMD5 | SHA1 | SHA256 | SHA512"MD5"
inputFile—

Shortcuts action: is.workflow.actions.hash

getAddressesFromInput ​

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

getAddressesFromInput(input: Location) -> Location
ParameterTypeDefault
inputLocation—

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

getContactsFromInput ​

Gets contacts from the result of the previous action.

getContactsFromInput(input: Contact) -> Contact
ParameterTypeDefault
inputContact—

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

getContentOfType ​

Returns a particular object class from the input.

getContentOfType(class: Text, input: Any) -> Any
ParameterTypeDefault
classText—
inputAny—

Shortcuts action: is.workflow.actions.getclassaction

getDatesFromInput ​

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

getDatesFromInput(input: Date) -> Date
ParameterTypeDefault
inputDate—

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

getDetailsOfAppStoreApp ​

getDetailsOfAppStoreApp(get: Enum) -> Any
ParameterTypeDefault
getName | Artist | Price | Store URL | Store ID | Rating | Rating Count | Release Date | Artwork | Artwork URL | Supported Languages | Is Universal | Category | Description | Version | Release Notes | Content Rating | Minimum OS Version | File Size | Supported Devices | Currency Code | Screenshot URLs | iPad Screenshot URLs—

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(input: Dictionary) -> Dictionary
ParameterTypeDefault
inputDictionary—

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

getDictionaryValue ​

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

getDictionaryValue(get: Enum, key: Text, dictionary: Dictionary) -> Any
ParameterTypeDefault
getValue | All Keys | All Values"Value"
keyText—
dictionaryDictionary—

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(input: Text) -> Email
ParameterTypeDefault
inputText—

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

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(input: Image) -> Image
ParameterTypeDefault
inputImage—

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(get: Enum, index: Number, startIndex: Number, endIndex: Number, list: Any) -> Any
ParameterTypeDefault
getFirst Item | Last Item | Random Item | Item At Index | Items in Range"First Item"
indexNumber—
startIndexNumber—
endIndexNumber—
listAny—

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(item: Any, getWebPageTitle: Boolean) -> Text
ParameterTypeDefault
itemAny—
getWebPageTitleBooleantrue

Shortcuts action: is.workflow.actions.getitemname

getNumbersFromInput ​

Returns numbers from the previous action's output.

getNumbersFromInput(input: Number) -> Number
ParameterTypeDefault
inputNumber—

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

getPhoneNumbersFromInput ​

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

getPhoneNumbersFromInput(input: Text) -> Phone
ParameterTypeDefault
inputText—

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(input: Any) -> Text
ParameterTypeDefault
inputAny—

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(firstDate: Text, secondDate: Text, in: Enum) -> Number
ParameterTypeDefault
firstDateText—
secondDateText—
inTotal Time | Seconds | Minutes | Hours | Days | Weeks | Months | Years"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(item: Any) -> Text
ParameterTypeDefault
itemAny—

Shortcuts action: is.workflow.actions.getitemtype

getUrlsFromInput ​

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

getUrlsFromInput(input: Text) -> URL
ParameterTypeDefault
inputText—

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

getVariable ​

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

getVariable(variable: Any) -> Any
ParameterTypeDefault
variableAny—

Shortcuts action: is.workflow.actions.getvariable

handoff ​

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

handoff()

Shortcuts action: is.workflow.actions.handoff

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(inputType: Text, inputSurface: Text, ifTheresNoInput: Enum, response: Text, type: Enum)
ParameterTypeDefault
inputTypeText—
inputSurfaceText""
ifTheresNoInputStop and Respond | Ask For | Get Clipboard | Continue"Stop and Respond"
responseText—
typeFiles | Text | Date | Photos | Contacts | Email Address | Music | Phone Number"Photos"

Shortcuts action: is.workflow.actions.input

list ​

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

list(items: List<Any>) -> Any
ParameterTypeDefault
itemsList<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(app: Text, appName: Text, windowLocation&Size: Enum) -> App
ParameterTypeDefault
appText—
appNameText—
windowLocation&SizeFull Screen | Left | Right | Top | Bottom | Top Leading | Top Trailing | Bottom Leading | Bottom Trailing | Left Third | Middle Third | Right Third"Full Screen"

Shortcuts action: is.workflow.actions.openapp

openFile ​

Opens the input as a file in the specified app.

openFile(showOpenInMenu: Boolean, app: Text, appName: Text, file: File)
ParameterTypeDefault
showOpenInMenuBooleanfalse
appText—
appNameText—
fileFile—

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(items: Any) -> Any
ParameterTypeDefault
itemsAny—

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

runApplescript ​

This action executes an AppleScript.

runApplescript(input: File, Script: Text) -> Any
ParameterTypeDefault
inputFile—
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: File, Script: Text) -> Any
ParameterTypeDefault
inputFile—
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(script: Text, host: Text, port: Text, user: Text, authentication: Enum, password: Text, sshKey: Text, input: File) -> File
ParameterTypeDefault
scriptText—
hostText—
portText"22"
userText—
authenticationPassword | SSH Key"Password"
passwordText—
sshKeyText—
inputFile—

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: File, passInput: Enum, runAsAdministrator: Boolean) -> Text
ParameterTypeDefault
ScriptText—
shellText—
inputFile—
passInputto stdin | as arguments"to stdin"
runAsAdministratorBooleanfalse

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() -> Barcode

Shortcuts action: is.workflow.actions.scanbarcode

setDictionaryValue ​

Sets a value in the dictionary passed into the action.

setDictionaryValue(key: Text, value: Text, dictionary: Dictionary) -> Dictionary
ParameterTypeDefault
keyText—
valueText—
dictionaryDictionary—

Shortcuts action: is.workflow.actions.setvalueforkey

setName ​

Sets the name of the item passed as input.

setName(name: Text, don'tIncludeFileExtension: Boolean, input: Any) -> Any
ParameterTypeDefault
nameText—
don'tIncludeFileExtensionBoolean—
inputAny—

Shortcuts action: is.workflow.actions.setitemname

setVariable ​

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

setVariable(input: Any, variable: Text)
ParameterTypeDefault
inputAny—
variableText—

Shortcuts action: is.workflow.actions.setvariable

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, ifTheresNowhereToOutput: Enum, WFResponse: Text)
ParameterTypeDefault
WFOutputText""
ifTheresNowhereToOutputRespond | Do Nothing | Copy to Clipboard"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

useModel ​

Use a model to handle complex requests in your shortcuts.

useModel(request: Text, model: Text, followUp: Boolean, output: Text) -> Any
ParameterTypeDefault
requestText—
modelText—
followUpBooleanfalse
outputText—

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