Getting Nespresso Capsule Information With Workflow

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

I recently added a Nespresso machine to my growing collection of coffee paraphernalia. It arrived with a selection of some of the 26 varieties available in the OriginalLine range—each one has a different strength (intensity) and cup size (ristretto, espresso, or lungo).

However, there’s no way to know this information just by looking at the capsule as it only has the name printed on it. To know more, one needs to either keep the packaging, refer to the website, or have this information memorized. There is a Nespresso iOS app available, but it’s not easy to quickly find a capsule and get its strength and cup size.

This seemed like a good opportunity to explore Workflow’s Dictionary functionality, a feature I hadn’t really used before. I created this Nespresso Capsule Information workflow to look up the intensity and cup size for any Nespresso capsule. To make it a little more interesting, capsule information can be retrieved by selecting either its name or an image of it.

Nespresso Information Workflow

All of the capsule data is stored within a Dictionary action inside the workflow. I created a Base64-encoded archive of all capsule images and included it as a Text action in the workflow (that’s what the nonsensical first action is). This is decoded and extracted when running the workflow, so no images need to be separately copied or installed anywhere—allowing the the workflow to be entirely self-contained.

Get the Latest Cryptocurrency Prices With Workflow

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

For those wanting to keep track of popular cryptocurrency prices, this workflow retrieves a list of the top 10 cryptocurrencies on CoinMarketCap using their API. Selecting a currency returns the current price in USD, along with the percentage change from 24 hours ago.

The workflow can be run as normal, from the Today Widget, or directly on Apple Watch.

Device-Framed Screenshots in Workflow Redux

Update (2017-12-04): This workflow has been updated to include support for iPhone X. The following post has been updated to reflect this.

It’s been almost two years since I made a workflow to create device-framed screenshots. Since then, Workflow added an Overlay Image action that allows users to place one image on top of another, making the need to slice up device images redundant. I figured that those wanting to create device-framed screenshots would eventually use this as a replacement for my workflow.

Nonetheless, the original workflow proved to be quite popular and I still get asked about it from time to time. Just last week, I helped someone on Twitter who was having trouble using the old workflow. I’ve now created a replacement action extension workflow that uses Overlay Image to generate device-framed screenshots for iPhone, iPhone X, iPad, iPhone SE, and Apple Watch.

Device-framed screenshot for Apple Watch

iPhone X device screenshot

Unlike the old one, this workflow doesn’t need you to download image assets manually. The workflow operates as an action extension for images, but if you run it from within Workflow it will automatically download the image assets and save them to iCloud Drive for you.

Run the workflow from within the app to install the device images it needs

The workflow also automatically detects orientation and provides either portrait or landscape device-framed screenshots (excluding Apple Watch).

Device-framed screenshot for iPad

To correctly place the screenshot within the device, the following measurements were taken for each device image1:

  • Height and width of the screen area
  • X and Y distance of the top-left corner of the screen area from the edge of the image (where the image is to be positioned)

When the workflow is run and a device chosen, Workflow resizes the screenshot to the dimensions of the screen area. It then overlays it onto the device image at the appropriate coordinates so as to completely cover the screen area.

This workflow becomes especially useful when coupled with the new screenshot process in iOS 11. Instead of just saving a screenshot to the Camera Roll, iOS now provides an option for annotating and sharing a screenshot before deciding whether to save it. This means you can create a screenshot, annotate it (if needed), then share it and use the workflow to create a device image—all as part of one process. You can then discard the original screenshot without needing to save it.

Annotating screenshots in iOS 11

For use on the web, I highly recommend using my Optimize Image workflow to reduce the file size of the resulting PNG image. You can add a Run Workflow action at the very end of this workflow to pass the image directly into Optimize Image workflow, providing a single process for generating and optimizing device-framed screenshots.

Run workflow

This workflow only includes one device color, so consider it a starting point for further customization. You can easily add more devices or colors by customizing the workflow and using the same process for all other devices.

  1. I used the Crop tool in Pixelmator to get these dimensions. I’m almost certain there’s a better way of doing this, but it worked fine for what I needed. 

Reverse Image Search With TinEye and Workflow

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

Social media is a wretched hive of misinformation at times and it happens because we take a lot of what we see at face value. This is exploited by those who would make false or greatly exaggerated claims, such as people who want to be internet famous or who are trying to push their political or prejudiced opinions onto others. A popular tactic for this is to make an unsubstantiated claim (or lie) and find an existing photo somewhere online (e.g., Getty Images) that fits their false narrative.

TinEye is a reverse image search engine and a superb resource for separating fact from fiction. You provide it with an image (either upload one or via URL) and TinEye can find web pages that also use it, even if it has been modified. For iOS users, I’ve created two workflows that makes it easy to search for an image using TinEye. Both workflows require the use of a Dropbox account.

TinEye Image is an action extension that accepts an image and temporarily stores it in your Dropbox folder. A public URL for the image is created and used as a TinEye search. Once you’ve seen the results, the workflow deletes the file from Dropbox.

The second workflow is TinEye URL, an action extension that accepts URLs. It gets the content of the URL, finds all images over 300px wide, and presents them all in a list for selection. The rest of the workflow is then the same as TinEye Photo.

Deleting Completed iCloud Reminders

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

Over at Six Colors, Dan Moren has some valid criticism about the lack of removing completed tasks from Reminders on the Mac and iOS, a feature that is available at iCloud.com:

Last week on Clockwise, we discussed how we use Apple’s Reminders app, and I lamented that there was no option to have old, checked-off reminders automatically discarded. If I look at my Shopping List, for example, there are more than 1100 completed reminders that I really don’t need to keep around. But there’s no easy way to get rid of them, except to go through and delete them one-by-one. Which I’m not going to do.

Listener Stephen pointed out, however, that there is an option to remove all your old completed reminders—it’s just not in an obvious place, because it’s not available in the macOS or iOS Reminders app.

That’s right, it’s on iCloud.

Inconsistency between iCloud and its Mac and iOS apps isn’t anything new, but it’s surprising that such a feature still doesn’t currently exist.

On the Mac front, Dr. Drang has offered up an AppleScript solution to accomplish this. Using Keyboard Maestro, it can also be scheduled to run automatically.

For those of us who mostly use iOS, removing completed reminders is easily done with Workflow. You can create a simple workflow that contains just two actions: Find Reminders Where and Remove Reminders.

The first action should be customized so it is only looking for completed reminders. You can also add another filter to restrict the results by different attributes, or even by list. The second action deletes all the reminders that meet the previous action’s criteria. Before doing so, it displays a warning that contains the total number of reminders it’s going to remove.

Unlike Dr. Drang’s Mac solution, there isn’t a way of scheduling scripts or workflows to automatically run in iOS. A workaround is to use the Share Sheet of the workflow to add it to Reminders, editing the details to make it a recurring task. This creates a reminder with a link directly to the workflow that you can tap. Whenever the reminder is due, you can tap the link icon to open Workflow directly on the workflow, ready to be run.

delete-completed-reminders.png

Optimizing Images With TinyPNG and Workflow

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

Whenever I include images or screenshots within the body of a blog post, I resize them so they aren’t unnecessarily large. iPad Pro screenshots, for instance, are 2732x2048px and often larger than 1MB. There’s no need to share these images full-size, so I reduce their dimensions to something like 1024x960px. This usually gets the file size down to around 200KB.

Back when I used a Mac to write blog posts, I would have also taken the step of optimizing the images using ImageOptim. This app uses clever compression techniques to reduce the file size while preserving quality. It was a simple drag-and-drop process that could drastically reduce the file size further. I haven’t yet found an equivalent iOS app that does something similar, so image optimization isn’t something I’ve been doing.

However, there are web services that perform image optimization. One such service, TinyPNG, has an API that can receive images and return a URL to an optimized version. Using Workflow’s recent API support, I’ve created this workflow that both resizes and optimizes JPG or PNG images using the TinyPNG API. When the action extension workflow is run, there’s an option to resize the image (using Workflow’s built-in image resize action), after which it’s uploaded to TinyPNG for optimization. An alert displays the difference in file size before the optimized image is downloaded. TinyPNG uses randomly-generated filenames, so you’re asked by the workflow to specify a new one.

The following PNG screenshot, resized to 1024x960px, was originally 202KB. After optimization, it’s just 57KB.

TinyPNG is free to use if you’re optimizing up to 500 images per month, which is plenty for most bloggers. As with most API services, you need an API key to use TinyPNG (the workflow has an import question that prompts for this).

Before you start optimizing images, keep in mind that TinyPNG is a web service and you’re uploading images to a third-party. It’s entirely up to you about what images you feel comfortable optimizing. I’m happy to use this for any public images and screenshots I’d share on my blog anyway, though I wouldn’t use it to optimize images that contain sensitive information (scans of passports, screenshots of bank account details, etc.).

Revisiting Workflow’s IFTTT Functionality

Unfortunately, Shortcuts no longer supports IFTTT so the following functionality is no longer possible.

Although Workflow’s recently added support for API interaction, it’s already been possible to create workflows that interact with many online services already, albeit in a more basic way. Back in June, Workflow added support for IFTTT, a web automation service that makes it simple to connect hundreds of different services to each other.

IFTTT functionality within Workflow is something that I feel is too easily overlooked. I rarely see any workflows that make use of this integration, and even I don’t make much use of it. In fact, the only workflow at Workflow Directory that uses IFTTT is one that I wrote to demonstrate its functionality—a workflow that triggers an IFTTT recipe to call your phone and get you out of an awkward situation.

Workflow’s API support opens up so many possible uses but it can get really complicated very quickly. It’s worth keeping in mind that some of the functionality you’re looking to achieve could be done much more easily with IFTTT1. After spending some time exploring what’s possible, I’ve created some examples of IFTTT-powered workflows that demonstrate the usefulness of this action.

Post to Medium

Only a handful of iOS apps support posting to Medium, each of which has slightly different limitations or requirements. Using Workflow, it’s possible to send Markdown-formatted text from almost any app and post it to Medium. Thanks to IFTTT’s extensive Medium support, it’s also possible to specify tags, publication ID, and even a canonical URL if you’re cross-posting a piece you’ve published somewhere already. Interestingly, IFTTT’s support for Medium is actually better than most iOS apps that provide some sort of Medium integration.

This workflow, used as an action extension with any Markdown-formatted text, uses this IFTTT recipe to create a published post on Medium. The workflow prompts for a title, tags, and canonical URL (if required) during the process before it’s published. If you prefer, you can edit the recipe so that the post is unlisted or also added to a publication.

If you edit the recipe to have IFTTT create a draft post instead, tags are not included and need to be added when you edit the draft.

Create GitHub issue

I’ve covered using the GitHub API in Workflow before, but you don’t need to start delving into that if you just want an easy way to create GitHub issues. Using this workflow and IFTTT recipe, you can create an issue within the GitHub repository you specify. There’s also provides an option to include a photo or screenshot when creating the issue. To accommodate this, the workflow uploads it to Dropbox and gets a direct link to use within the issue description.

Creating a GitHub issue using Workflow and IFTTT

Subscribe to RSS feed in NewsBlur

This workflow makes me wish I had spent more time looking into Workflow’s support of IFTTT. I’d been looking into the NewsBlur API to create a workflow that subscribes to a site I provide, but this is something that I can do just by using IFTTT. This workflow makes use of this recipe and detects the RSS feed of a website, then passes it to NewsBlur to subscribe to.

  1. There might even be services that you want to make use of which don’t have a public API but are available through IFTTT. 

Using Workflow to Perform OCR

Microsoft’s Cognitive Services (née Project Oxford) is an interesting collection of APIs that leverage machine learning to determine useful information about any provided data. One useful example of the APIs available is the Computer Vision API. It offers OCR functionality that detects any readable text within an image and outputs the results as plain text. Thanks to Workflow’s new API support, we can harness the power of machine learning to perform some very quick, and very accurate, text recognition.

This workflow prompts you to either select a photo or take one with the camera, then uses it to make an appropriate API request. The detected text is returned back and displayed as plain text that can be easily shared or copied to the clipboard.

OCR of a Notes screenshotOCR of a photo taken of a page in a book

Cool, right? Well it gets even better. The Computer Vision API can OCR images containing text in different languages so Workflow can also translate the detected text into our chosen language. The workflow includes a Translate Text action so you can try this for yourself.

After the OCR process, text can be translated within Workflow

This is really useful, especially when traveling. For instance, if you’re on vacation and are wondering what a street sign means, just run this workflow and take a photo, and you’ll get a translated version of the text.

Similar to other API services, an API key is needed to authenticate your requests. Just register for the service and copy/paste the appropriate subscription key for Computer Vision. There are also some size limits (both file and resolution) you need to consider so I recommend reading through the relevant documentation.

Workflow and APIs

Shortcuts no longer supports shortcut file imports and workflow.is links no longer function. Any links to shortcuts in this post have been updated to use iCloud links.

In what is most certainly an early Christmas present for people like myself, Workflow has just received one if its most significant updates-extensive support for making API requests. I can’t emphasize enough how useful this is and the impact it’s going to have when it comes to iOS automation.

Workflow’s “Get Contents of URL” action has been overhauled to provide support for GET, POST and PUT request methods, including custom header information. The action also features an easy-to-use way of creating a request body that handles the formatting and escaping of values automatically. This opens your workflows up to all kinds of interactions with many APIs, such as Stripe or GitHub.

To demonstrate just how powerful this revamped action can be, I’ve created a few example workflows that leverage some popular APIs. These examples don’t perform any sort of error handling, nor do they represent what the limits of Workflow are. Consider these workflows a starting point for building your own.

A word about API keys

Keep them secret, keep them safe.
– Gandalf the Grey hat

Interacting with an API almost always requires some sort of API key or token. This is usually a string of random characters that can be used to directly perform actions on behalf of your account. If someone were to obtain this, they can not only access your account information but also perform actions on your behalf.

If you create a workflow that you want to share, make sure to remove your API key from it beforehand!

GitHub: Create Gist

This is a workflow I’ve always wanted to create, and the new API support makes it possible. Gists are great to share small pieces of text information, such as code snippets or scripts. This action extension workflow accepts files of any type (though they must be text-based) and creates a gist using the GitHub API.

You need to create a GitHub personal access token before you can use this workflow. GitHub allows you to create multiple access tokens with different permissions. For the purpose of this workflow, I recommend creating a token that can only be used to work with gists.

Stripe: Get Recent Charges

Stripe is a payments platform that’s built for developers. This workflow retrieves some basic information about the last three charges processed on your Stripe account, such as:

  • Charge ID
  • Amount
  • Last four digits of the card used

To use this workflow yourself, include your test or live secret API key, depending on whether you want to retrieve test or live payment information.

Stripe: Create a Payment

This is an excellent demonstration of Workflow’s API support–use Workflow as a point-of-sale device! This workflow prompts you to enter credit card information and an amount to charge, along with some additional information, then creates a payment.

Create a payment on Stripe using Workflow

A notification is displayed once the payment has been processed and a link to the payment in your Stripe Dashboard is copied to the clipboard.

A payment created with Workflow

Stripe: Create a Customer

Moving on from creating payments, this workflow creates a customer object using the information you provide. A link to the customer object in your Stripe Dashboard is also copied to the clipboard.

Digital Ocean: Create Droplet

Digital Ocean is a cloud computing platform that makes it easy to deploy a server (droplet) in just a few seconds. Using its API, this workflow creates a new droplet using the information provided, such as the Linux distribution, how much RAM it should have, and the datacenter location.

Digital Ocean: Get Droplets Info

This workflow simply retrieves a list of all your current droplets and provides the following information for each:

  • Name
  • ID
  • IP address
  • Status