Here's a list of example workflows I've created to help people understand how to carry out different tasks in the Workflow iOS app. Each entry gives you an overview of what the workflow does. Select the workflow entry to open up the details where you can view a full screenshot of the workflow and also download a copy to your own device. If you want to find out more about Workflow, check out the main Workflow page on this web site].

Workflow Example: Call or SMS

This workflow gives the user a choice for calling or sending an SMS message to a particular telephone number.


Workflow Example: Clear Clipboard

This workflow sets the clipboard to “Foo bar”, shows the content, clears the content by setting it to nothing (note this is not simply an empty string of text) and then displays the clipboard contents.


Workflow Example: Next Monday

This workflow allows the user to specify the current date or another of their choosing. The date is then used seven times to add an incremental day to (covering a week) and a formatted version of each date is then searched for the text string “Mon”. This identifies the next Monday from that date. That date is then displayed to the user.


Workflow Example: Open URLs in Safari

This workflow simply takes a list of URLs (each on its own line) and splits it into a workflow list. The list is then used to open the URLs in the Safarai mobile browser app.


Workflow Example: Photo & Text to Mail

This workflow allows the user to take a photograph with their device camera and then enter some additional text. These are combined into a single variable and passed into an e-mail creation action. The text and photo are added as the content of the mail.


Workflow Example: Prefix lines

The workflow begins by allowing the user to work with some sample text or the contents of the device’s clipboard. The workflow then asks the user to enter some text with which to prefix each line. A text replacement action using a regular expression to identify each line is then used to prefix each line with the specified text. Finally the workflow allows the user to view the amended text (and potentially share it on) or simply set the clipboard to the amended text.


Workflow Example: Variable is Empty

This workflow shows how to check if a variable is empty. It offers the user to choices - populate a variable with the text “foo bar”, an image from the camera roll, or leave it empty. The number of characters are counted and if they are greater than zero (including when an image is in the variable), the variable contents are displayed to the user. Otherwise nothing is displayed.


Workflow Example: Day of Week

This workflow allows the user to specify a date and the workflow will then return the day of the week. The workflow does this by formatting the date with a custom string that returns the date just as the day of the week. For a short format (“EEE”), this would be “Mon” for Monday, whereas for the long format (“EEEE”), this would be the full word.


Workflow Example: S.O.S.

This workflow is a simple example of using the flashlight and a nested loop. The workflow specifies some timings and occurrence details which are held in variables and a list. These are used to flash the iOS devices flash to spell out “SOS” in Morse code (“… — …”) the specified number of times. For the sake of the example this is defaulted to two times, but if you think you might actually need this at some point then just add some digits and you’ll be up and running for a lot longer - though it may well affect your battery life!


Workflow Example: Readable PDF

This workflow is an action extension that allows a URL to be saved as a PDF. This could be a web page, web link on a contact record, etc. The workflow offers two ways to generate the PDF. The first uses the local workflow PDF generation action. The PDF produced by this sometimes has some strange artefacts and truncations, but it generally gets the job done. The second option uses an online service to generate the PDF which I think generally gives better results, but does typically take a bit longer and involves sending the work off your iOS device.


Workflow Example: Get External IP Address

This very simple workflow loads the content of a URL at ipecho.net which contains just the external IP address of the iOS device you are using to run the workflow. This is not the IP address of your device on the local network, but rather the IP address of your connection (cellular or WiFi) out onto the Internet.

The workflow displays the IP address within an alert box with the offer to copy it to the device clipboard. If the user cancels the workflow ends at this point. If not, the contents of the device clipboard will be replaced with the IP address found on the web page.


Workflow Example: Get Web Page Title

This workflow is configured as a workflow extension that accepts URLs, though if there is no URL passed in it will prompt for a URL to be entered. Once a URL has been received, the workflow retrieves the contents of the specified page and from that the name of the contents … which is the title of the page.


Workflow Example: Send E-mail to Contact

This workflow starts by having the user select a contact. The workflow then extracts the e-mail addresses associated with that contact and counts them up.

If no e-mail addresses were found a message is displayed to the user and the workflow terminates there.

If multiple e-mail addresses are found then the is asked to choose just one of the addresses from the list of those available. If the contact had only one e-mail address, that is effectively selected automatically.

The workflow then opens up an e-mail composition sheet with the To address populated with the contact’s e-mail address. Note that “Nothing” is passed in as the input. This is because the input is the body of the message. You could of course pass anything in. For example you could grab a name from the contact and automatically add that to the start of the e-mail.


Workflow Example: Dice

This example workflow is a an example of how you might build a dice rolling system. It has a menu that lets you select from a pre-set list of single and multiple die examples as well as options to define your own on-the-fly dice combination and an option to quit. Note that the number generation prompting will loop round a ridiculously large number of times - but quitting will jump you out of the workflow.


Workflow Example: Text [Switching Tabs & Spaces]

This workflow demonstrates a simple way to use a find and replace to switch between using tabs and spaces. This is a common requirement for people working with scripting languages to keep code neatly formatted and whilst the numbers used here are not typical, they do help illustrate the work done.

The workflow uses a simple regular expression using the “\t” for tab token and plain old spaces.

When the workflow is run it copies the result to the clipboard. In Workflow, the standard outputs use non-monospaced fonts so it can be difficult to review the output. Instead I suggest pasting it into a text editor (such as Drafts) to review.


Workflow Example: Text [Get First or Last Line]

This workflow returns the content of either the first or the last line of a string of text.

The workflow being by generating a number of unique lines of content (by using a sequence number and some input about how many lines you wish to have). The result is stored in a variable called Content and displayed via a Quick Look action with the full set of lines between double quotes.

The content is then split (by new line) into a list and you are asked whether you would like to retrieve the first or the last line of the text (which would correspond to the first or last list item). Simple list item actions specifying “First Item” or “Last Item” respectively then retrieve the desired line of text and it is displayed braced in double quotes.


Workflow Example: Text [Prefix & Suffix]

This workflow allows text to be added to the start and end of lines of text. The workflow begins by generating some sample text. It takes a standard string of text (“The quick brown fox jumped over the lazy dog”) and replicates it a number of times specified by the user. The workflow even accommodates zero times.

The workflow generates the text and then displays it so you can see the before and after effects.

The user is then prompted to enter the text to prefix and append each line with. Both are optional and both can be applied at the same time.

Once set, the workflow carries out a find and replace using a regular expression and the prefix & suffix provided. The final result is then displayed.


Workflow Example: Text [Remove First or Last line]

This workflow removes the first or the last line of a string of text. Note that this workflow removes one or the other, not both; though it is certainly possible to do that.

The workflow being by generating a number of unique lines of content (by using a sequence number and some input about how many lines you wish to have). The result is stored in a variable called Content and displayed via a Quick Look action with the full set of lines between double quotes.

You are asked whether you would like to remove the first or the last line of the text.

Rather than using lists and iteratively rebuilding them without the first or last item, we can instead use some carefully crafter regular expressions to remove the first or last line. The result is then shown surrounded in double quotes.


Workflow Example: Text [Trim Whitespace]

This workflow shows how to trim whitespace from lines of text. The workflow can trim leading whitespace, trailing whitespace or both together.

The workflow starts by defining some sample text. The first line has whitespace before and after the visible text. The second line has whitespace only before the visible text. The third line has whitespace only after the visible text and the final line is a control having no whitespace.

Next the workflow prompts you to select whether to trim before, after or at both ends of the lines of text. The choice then runs one of three different regular expressions that carry out the specified trimming request.

Once complete you are immediately offered a menu with two options. Copy the result to the clipboard or send it to Drafts (app). The reason these options are given rather than an Alert or a Quick Look action is simply because getting the content into another app suitable for plain text editing (e.g. with a monospaced font) will better show how the text has changed.


Workflow Example: Choosing From a List

This simple workflow shows a handful of aspects relating to lists. It begins by creating a list of items from some lines of text by splitting the text at each new line. It then picks out and displays the second item from the list.

Next it takes the list (which has been stored in a variable - i.e. the collection of items is held together as one “thing” in the variable) and allows you to choose from the items, each item being displayed by content and then displaying the selection that was made.


Workflow Example: Current Address

This workflow uses the current device location, querying it for address properties such as street name and postcode. The resulting properties are put together to form an address which is shown to the user. The address is then URL encoded and appended to a URL string to create a Google Maps link to the address.

Please note that there is a Get Addresses from Input action that can retrieve the address in a single action. This however is an example showing how you can iterate over and combine properties such as those from a location.


Workflow Example: Current Location Map URL

This workflow uses the device’s current geographic location and then displays it in the user’s choice of the Apple Maps app or the Google Maps app (the Google Maps app should be installed for this to work).

At the time of writing, the current version of Workflow contains an action to open a location in Apple Maps, but not in Google Maps. The Apple Maps actions are therefore quite straight forward. For the Google Maps app, the longitude & latitude of the current position are passed as parameters (along with a specified map zoom level) to a URL string that will open the Google Maps app.

The workflow does not automatically open the specified mapping application, but first prompts the user to select an option from “Copy to Clipboard”, “Share”, “Share with Extensions” (full share sheet) or “View in App”.


Workflow Example: Event From Variables

This workflow takes a set of information relating to a new calendar event and stores them in variables. The workflow then creates a new calendar event in a specified calendar using these variables as input parameters for the action. Specifically this shows an example of data & time as text that can be used to create the event.


Workflow Example: Remove URL Parameters

Given a URL as input this workflow will strip out any parameters by removing the “?” and everything after it. If a URL is not received as input, the workflow will offer to use one of two default URLs (one with parameters or one without).

The parameters are stripped using a regular expression substitution that replaces the matched group with nothing - effectively deleting it.


Workflow Example: Text [Remove Blank Lines]

This workflow takes some sample text containing some blank lines and first displays it to the user. The blank lines are then removed using a couple of regular expressions - using two allows a blank first and blank last line to be accounted for. The result is then displayed back to the user.


Workflow Example: Add an Entry to Day One

This example workflow is for use with the Day One journaling app on iOS. It allows you to optionally choose to enter text and a photo (or just one of these) and then add this as an entry (for the current day) into Day One. The workflow makes use of a multi select list to allow the user to make a selection. Normally the Create Day One Entry action would expect to receive an image, but in this workflow the option to add an entry without an image is enabled by the use of the Nothing action (to pass in what is in effect a null image).


Workflow Example: Base64 Encode/Decode

This workflow demonstrates how the Base64 Encode action can be used to encode and decode data. The workflow begins by grabbing the last image (including screen shots). It then encodes the image producing a set of text (that could be copied into some system that only supports text) displayed via a Quick look action.

The text is then passed into the Base64 Encode action again, but this time the Decode parameter is set (instead of Encode). This converts the text back into an image which is then shown via the Quick Look action.


Workflow Example: Coordinates From Google Maps Share

This workflow is configured as an action extension. It is intended to receive map shares from the Google Maps app and to return some coordinate details for the location.

The workflow first checks to see if the input to it contains “/maps/” (which Google Maps shares do). If not it substitutes in example content from a Google Map share.

The URL passed in is first expanded (just to be sure we always have a full URL to work with) and then the initial part of the maps URL is stripped using a Replace Text action.

The first part (based on separation by forward slash (“/”) of the remaining portion of the URL is taken and split based on the position of a comma. The variable Coordinates then contains the coordinate elements of the map location being processed.

Latitude is the first element and longitude the second. These are stored in other variables and the result (along with the original (expanded) URL) are displayed to the user via a Quick Look action.

Note also the use of the Set Name action to title the Quick Look window that is displayed.


Workflow Example: Get Tagged Pocket Article Content

This workflow is an example of how to access items in Pocket (a multi-platform read-later application). The first action retrieves up to five articles from Pocket, but it only retrieves articles tagged with a specific tag that the user is prompted to enter when this action is executed. It retrieves these from the entire collection of current and archived articles in Pocket.

The list of matching articles is returned and the user is then prompted to select one from a list. The URL of the selected article is passed to the next action which fetches a simplified (article) version of the original web page. This is then displayed to the user via a Quick Look action.


Workflow Example: Select File From Dropbox Sub-Folder

This workflow demonstrates how to select a file from a particular sub-folder in Dropbox (so you don’t have to navigate manually each time). By disabling the Show Dropbox Picker parameter in the Get Files from Dropbox action this allows you to specify a base file path (this should start with a forward slash (“/”) to indicate the path is form the root of the Dropbox folder).

In this example the workflow fetches the PDF files in this folder and then feeds this into a list to prompt the user to select which they want to select. The selected PDF is then shown to the user via the Quick Look action.


Workflow Example: Split Characters onto New Lines

This workflow shows how text can be split to place each character on a new line. It demonstrates this using two methods, a new line not currently being possible to add into the Replace action as a replace parameter. When run the user is prompted to select one of the methods using a menu action.

The first method takes a text action containing a new line and stores this in a variable. That variable can then be used in the replace action to replace each character with the character and the content of the variable (a new line). Note that the replace makes use of a regular expression.

The second method carries out a similar replacement, but this time using some placeholder text (“[character]”). That placeholder is then used as a custom separator for the Split Text action which separates each character into a separate element. These elements are then recombined using a new line separator with the Combine Text action.

The results are then displayed via a Quick Look action for verification and sharing.


Workflow Example: Split Text by Paragraph

This workflow shows how text can be chunked into separate elements by paragraph. It demonstrates this using two methods, a double new line not currently being possible to add into the Split Text action as a separator parameter. When run the user is prompted to select one of the methods using a menu action.

The first method takes a text action containing two new lines and stores this in a variable. That variable can then be used in the Split Text action as the paragraph separator.

The second method carries out a regular expression based replacement of two new lines with some placeholder text (“–Paragraph Marker–”). That placeholder is then used as a custom separator for the Split Text action which separates each paragraph into a separate element.

The results are then displayed via a Quick Look action for verification and sharing.


Workflow Example: Clipboard Google Search

A very simple example workflow this one but like the majority of the example workflows presented on this site, it’s one that was used to help someone online … so maybe it will be of use to someone else?

This workflow simply takes whatever is on your clipboard, opens a new tab in the Safari browser and passes this as a search to Google. note that this only works for text on the clipboard. If there is something like an image on the clipboard, Workflow will do it’s best to pull some text based information from that item (e.g. when it was copied to the clipboard, a URL of an object) and pass that to the search.


Workflow Example: Date Difference

This workflow demonstrates the basics of determining the difference between two dates (including dates & time or just time). The example begins with an example date and time against which to do our elapsed time comparison. The user is then prompted to enter a second date. If the Now option is selected, Workflow will use the date and time at that point. If Other is selected, Workflow will prompt the user for input but pre-populate it with the current date and time.

Whilst there is an option to prompt a user to enter the date and time with Ask for Input, if you opt for date & time granularity, only the day, month, hours and minutes are available. Nothing for specifying the year. As a result this example uses a text input and then pulls the date and time from that. Note that the maximum level of granularity is to the minute regardless of if you type in seconds or fractional parts of minutes.

With both dates entered, the Get Time Between Dates action is used to determine the difference. Here the units are specified as Total Time meaning it will give you a full break down of combined time units for the difference, but this could be set to be just seconds, minutes, hours, days, weeks or years. No option for months and slightly surprising that seconds appears given the level of granularity for entering the time.


Workflow Example: Directions Home

This workflow shows how to build a simple workflow to get directions home. The workflow starts with an address (in this case the Apple store in Leeds, UK). The user is then given a list of transportation types to choose from.

Once selected, a Show Directions action is triggered for the Google Maps service with the transportation type selected.

The workflow could be simplified to simply offer the Ask When Run option on the Show Directions. However I prefer to have a nice menu option with the question on it. But there is another consideration. If you wanted to use this as a notification centre widget entry, using the menu option will display the list in situ in the notification centre whereas the Ask When Run approach will bounce the user into Workflow which makes the overall process a little less streamlined.


Workflow Example: Dropbox, Save RTF to PDF

This workflow downloads an online rich text file (RTF) and downloads it into the root directory of the user’s Dropbox account (overwriting any existing file of the same name).

The workflow then retrieves the file from Dropbox, generates a PDF file from it and saves that file back to the Dropbox root directory (with the same file name as the RTF file … but with a .PDF file extension appended to it).

The PDF file is then opened from Dropbox via a Quick Look action. After this the user is offered the option to save/open it directly into iBooks.

Please note that this is simply an example of some interactions relating to Dropbox, RTF files, PDFs and an external app (iBooks). In reality you would be unlikely to want to keep writing to and immediately reading back from Dropbox - using variables to store files on the device for processing would be much faster.


Workflow Example: Get Named Date From Contact

This workflow shows how dates can be read from contacts. The Get Details of Contacts action does not (as of the time of writing) allow custom date fields to be read in from a contact. Instead you must use the Get Dates from Input action. In the workflow the user first selects a contact (ideally with some custom date fields populated) and the workflow then parses the dates returned from the contact - selecting the names of the fields using the Get Name action.

The user is then presented with a list of the available fields and can select one of these to be retrieved. Once selected Workflow parses the list of dates again until it finds one with a matching name (to that selected by the user). The workflow then retrieves the date associated with that field and formats it into the standard short date format.

This is finally returned to the user via a Quick Look action.


Workflow Example: Get Web Page HTML

This simple example shows how Workflow can be used to get some HTML for a web page. The workflow asks the user to enter a web page URL. The contents of the URL are then retrieved. The retrieved page is then transformed to HTML using the Make HTML from Rich Text action and the final HTML is displayed to the user via a Quick Look action.

Note that this is a generated set of HTML and will not necessarily match the HTML used on the web page if you view the source of it.


Workflow Example: Image Combination & Order

This example workflow demonstrates various ways to combine images in differing orders. In Workflow the combine images action allows you to create a composite image by placing existing images linearly or in a grid and then creating a new larger image.

By default the images are put together in reverse chronological order - i.e. the newest comes first with the oldest at the end (combination starts from the top left). However with a bit of effort that ordering can be changed.

The workflow begins by prompting the user to select how to construct the image. The first option is to auto-select the last “N” images. The user enters the number and then the remainder of the process is automatic. The other two options require a manual selection of images.

Using the time ordering option, the user selects all of the images at once. Using the manual order however, the user will ned to go through a more tedious process. The user first enters how many photos they wish to select and then the workflow loops to allow the user to select that number of images but only one at a time - that’s what override’s the default time based ordering.

With the images selected and the order effectively set the workflow generates a single row combination of the images in the order specified. This is stored in a variable.

Next the workflow takes the set of images used to generate the composite image and reverses the order by simply reading them back in reverse order from the variable the images are stored in.

This reversed image set is now combined in the same way as before and then this image is added to the variable containing the previous combined image.

The variable holding the two images is then passed to the Combine Images action but this time set to combine vertically rather than horizontally. The final image is then the first row of images (auto-selected & time based, manually selected & time based or manually selected & manually ordered) on the top row and its reverse on the bottom row. The result is displayed via Quick Look action.


Workflow Example: Markdown to HTML

This workflow example takes a sample of text in Markdown format and generates the HTML equivalent of the text ready for native online publishing.

The workflow takes the markdown text and transforms it to rich text as an intermediate format. The rich text is then transformed to Markdown. The Markdown is them placed into as text action to ensure the HTML is stored as text rather than as HTML to be implicitly rendered.


Workflow Example: Text [Remove 'N' Lines]

This workflow takes a block of text and offers to remove a number of lines for the user. The user can select whether to remove them from the beginning or the end of the text and the workflow uses some validation for numeric data entry to put in some better edge case handling.

The workflow starts by storing the text and counting the number of lines in it (ten in this case). It then asks the user how many lines they would like to remove. The input must be a number, but beyond that it is validated by several actions to be a positive integer less than or equal to the maximum number of lines in the text. The input begins by being rounded down to the nearest integer. This is then compared against 0 and the number of lines to ensure it falls between them (inclusively). If it does not then the user receives a notification and is prompted to enter the number again (via a loop that will give the user 42 chances to enter the right number … after which anyone might give up the will to live ;-) )

Once the number has been verified the user is presented with the option to remove the lines from the start or the end of the text.

When removing the lines, the workflow splits the text by new lines and loops through the lines. It uses the index number of the loop to determine whether to retain the line or not. If it should then this is added to an Output variable.

Once the lines have all been processed, the content of the Output variable is recombined (with new lines as the separator) and the lines are displayed to the end user via a Quick look action. Finally an Exit Workflow action is triggered to break out of the loop used to validate the input.


Workflow Example: New TextExpander Snippet

This workflow is intended for use with Smile Software’s TextExpander Touch application. In a recent release an option was added to the application’s URL scheme to allow new text expansion snippets to be created by a call.

This workflow asks the user for a snippet abbreviation and the snippet content. These are both encoded for inclusion in the URL call. A callback URL for workflow is specified and also encoded.

The TextExpander URL call is generated and then initiated through an Open URL action.


Workflow Example: Combine List Items

The combine list items workflow example takes two lists and concatenates the corresponding entries by position. The first item of the first list and first item of the second list are paired, the second item of each list is paired and so on through to the last item

The workflow begins by creating a list from a set of text. It does this by splitting the lines of text into list items. The workflow then repeats this for a second set of text; producing a second list.

A repeat loop is then used to iterate through the second list. The number of the repeat item is used to fetch a list item (by index) from the first list. These are then concatenated (with a pipe/vertical bar as a separator) within a Text action.

The text is then added to a variable. Each addition creates a new item effectively building a new list in the variable. The variable is then returned at the end of the workflow.


Workflow Example: Combining PDFs

The combine list items workflow example takes two lists and concatenates the corresponding entries by position. The first item of the first list and first item of the second list are paired, the second item of each list is paired and so on through to the last item

The workflow begins by creating a list from a set of text. It does this by splitting the lines of text into list items. The workflow then repeats this for a second set of text; producing a second list.

A repeat lop is then used to iterate through the second list. The number of the repeat item is used to fetch a list item (by index) from the first list. These are then concatenated (with a pipe/vertical bar as a separator) within a Text action.

The text is then added to a variable. Each addition creates a new item effectively building a new list in the variable. The variable is then returned at the end of the workflow.


Workflow Example: Coordinates for UK Postcode

Workflow can easily leverage the geographic information available to today’s iOS devices. In this example the workflow takes a postal code and returns the longitude and latitude for that location. Please note that because postal codes are for a street or small area ‘the longitude and latitude are corresponding approximations for those locations.

The workflow begins by capturing a UK post code. It could also be a non-UK postal code if you amend the country in the Street Address action that follows the storage of the post code. The resulting address object I held in the Location variable.

This is then queried for the latitude and longitude. Those details are then combined and output via Quick Look.


Workflow Example: Fetch Home Address

Workflow is an amazing piece of software, but it can’t always do everything you might want. At least not yet. One such thing that a Twitter user was having an issue with was identifying the home address of a contact. This was simply information iOS contacts hold, but was not directly available to check against within Workflow. There is however a way around this which is what this example is all about.

The workflow starts by saving a contact (you’ll need to amend the contact to one of your own) to file in iCloud. This is where the trick starts as the output format is a VCard and this contains some details that allow the address type to be identified. After saving, the workflow capture the file name and then reads the file back in from iCloud (unfortunately there doesn’t seem to be a way at this point in time to delete the file from within workflow).

Upon reading it in the file name is altered to give it a .TXT extension. This allows the content to be interpreted by Workflow as plain text.

A regular expression pattern match is then used to find a line where the address type has been set as “HOME”. That line is then split (by semi-colon separator) and the five items from the fifth item onwards are captured. These are the five potential address lines.

Theses are finally combined and displayed.


Workflow Example: Get Tweet Info

This workflow is an example of how you can get content and meta data information about a specific Twitter post (“tweet”) if you have the URL of the post. This includes details about who made the post and when it was made.

The workflow begins by offering to allow you to select an example Tweet URL, to enter your own (custom) URL or to use a URL on the clipboard (there’s no validation on this as this is just an example workflow). The workflow takes the tweet ID from the end of the URL (by splitting the URL on the forward slashes and taking the last item). It then appends this to a pre-set Twitter API URL. The URL is then used by Workflow to retrieve a JSON result set from the Twitter API.

At this point the workflow prompts you to select the meta data item to return (name, user name (handle), user profile URL, the actual content of the tweet and the date on which the tweet was posted.

A number of JSON dictionary keys are then used to read in the appropriate data for the tweet. The name and user profile URLs are simple data item retrievals. The user name however is extrapolated form the user profile URL (it’s the last part) and prefixed with an “@”.

Retrieving the content of the tweet requires a bit of extra work as some extraneous information is stripped out with a bit of splitting and replacing. This extraneous information is the name, user name and date line appended to the end of the content. The upshot is however that a similar approach can be made to extract the date and this can then be reformatted.

You could easily modify this basic example to fetch multiple items and build other outputs; but always note that this workflow is entirely dependent on the Twitter API. If that API changes or if deprecated it is quite possible this workflow will need to be re-worked in some way.


Workflow Example: iCloud Persistent Variable

Sometimes you want to maintain data for longer than the duration of a single workflow run. Perhaps you want to access data on subsequent runs of the same workflow or from a run of a different workflow. This is where we want to take advantage of persistent variables. This example shows how persistent variables can effectively be provisioned by saving data to a file in iCloud and reading it back in. It would be great to do this as JSON as this would easily allow multiple variables to be saved in a single file, but until workflow allows you to write back individual keys into a JSON dictionary it’s just much easier to store one data item per file.

The workflow begins by attempting to read in a file that is to hold the variable data. If the file exists it will be stored in a variable. If it doesn’t the variable is initialised to zero.

The variable is incremented and saved back to the file. The file is created if it does not already exist and overwritten if it does. The workflow output is the incremented value.


Workflow Example: Loop & Pause

This workflow is just an example of how you can use loops and delays and demonstrates a way you could keep checking for something over a period of time and then escape from the checking loop once something has occurred. The example here is based on the user choosing to end the check, but you would more likely set this to be some sort off automated check such as checking that some content has appeared on a remote URL or perhaps a change in state of something on device.

The workflow begins by initialising a couple of variables to be used in the checking. It doesn’t actually matter what the content of these is as long as they are set to be the same. Because of this we can actually use this to hold a particular piece of text that will be of use later in the workflow and make it a little more efficient than setting this text up separately. The workflow sets up a set of actions that will be repeated (up to) five times.

Those actions begin by checking a variable to see if the user has selected to exit the repeated actions. If the check is still matching as “Loop not manually exited” the workflow will pause for two seconds and then display a question to the user asking if they would like to continue in the loop or to stop and exit the loop.

If they choose continue the workflow displays an alert to indicate an action could be run. This is where you might check for a change in a web page or some other change externally or in a device property/state.

If they choose stop checking then the Check variable is set to some informational text stating on which loop the user chose to exit. If this option is chosen, when the loop begins again and the check variable is checked, the app will note that the content has changed from it’s original value. It will repeat the remaining loop iterations, but it will not run any actions other than the check for the change. By having all the actions in the repeat loop inside the If action we can effectively jump out of the loop by doing nothing for all the remaining repeats.

At the end of the workflow an alert is displayed to the user. This contains the content of the check variable. If the user did not choose to stop checking this will contain the original content of the variable. If they did choose to stop it will contain the text indicating that they chose to stop and on which time through the loop they chose to stop.


Workflow Example: Nearest Quarter Hour

This workflow provides an example of working with times and rounding them off. Not simply up or down but to the nearest quarter of an hour.

The workflow begins by capturing a (date and) time. This can be the current (date and )time or one that you specify. This is then reformatted to a short time format.

The resulting time is split (by colon) into two parts - the hours and minutes. The hours are stored in a variable whereas the minutes are then run through a set of calculation operations. The minutes are divided by 15 and rounded to zero decimal places. This will give a value between 0 and 4. That figure is then multiplied by 15 which will give 0, 15, 30, 45 or 60 as a result.

If the minutes are 60 then the workflow sets the minutes to 0 and increments the hours by 1. If the hours are already set to 23 this will be set as 00 rather than 24.

The minutes are then formatted to two digits and the result is displayed via a Quick Look action.


Workflow Example: Send 3 Week Event List

This workflow is an example of how you can fetch sets of information from a calendar and send it to someone. This is a useful basis for sharing your availability with someone and can be easily customised to provide more or less information depending upon how much information you might choose to share with the recipient.

The workflow searches through a particular calendar (“Test Calendar”) to find details of all of the events coming up in the next three weeks. It takes each event in turn and extracts the title, start date & time and end date & time. These are collected together as a set of text with a blank line between each event’s details.

The workflow takes this set of event information and prompts the user to e-mail the content (where upon it will open up a mail message with the content pre-populated into the body of the e-mail), message the content (to a predetermined recipient ‘555 123456’) or copy it to the clipboard.


Workflow Example: Split by Two New Lines

This workflow is really an example of how to split paragraphs of text where a blank line is used to create a paragraph spacer. More over there is an option within Workflow to split data by newlines, but not by a newline followed by or preceded by something else (e.g. another new line).

The workflow begins with what is probably the key step. Defining the two newlines. Many of the text entry areas are single line and standard tokens such as “\n” are not recognised. As a result a Text action is used and simply contains two new lines. It looks blank … but they are there.

The workflow then saves this to a variable for use later and sets out some example content to be split. Note the use of single and double lines.

The Split Text action is then used to split this text using a custom separator of the variable set earlier.

The result is then displayed and you can swipe through to see the content of each item.


Workflow Example: Stats

Workflow has a statistics calculation action that takes a set of numeric data and performs one f a variety of statistical operations on it. This workflow is simply an example of the use of these statistics.

The workflow begins with a text based list of five numbers. Each number Is held on a separate line which is then split by new line and stored in the Data variable as multiple items of data.

A new Text action then lists the available statistical operations by name. This is again split by new line, but this is passed to a repeat block. Each repeat iteration will therefore correspond to one of the statistics.

The numeric data is passed into a statistical calculation operation defined by the input list and the resulting calculation type and result is appended to a variable called Output. Note by using he variable by name we’re bypassing the combining of results if we were simply to add them to a variable.

The results of all of the statistical calculations are then displayed via a Quick Look action.


Workflow Example: Weekday or Weekend

This example takes a date and determines if it is a week day or a weekend. The basic approach for this relies on the simple fact that the only days (in English) that begin with the letter “S” are the days of the weekend.

The workflow begins by capturing a date. This is then formatted using the “EEEEE” format string to return the first letter of the day of the week for that date. If this is “S” then an alert is shown identifying the date as a weekend day. If this is not an “S” then an alert if shown identifying the date as a weekday day.