Receive a value from Scriptable in Shortcuts

Unfortunately passing data between Shortcuts is not supported by iOS. However there are two workarounds that you can look into.

  1. Use the pasteboard. Both Scriptable and Shortcuts supports manipulating the pasteboard. In Scriptable this is done with the Pasteboard API. When you run a script, you can put a string or image into the pasteboard and read it in Shortcuts. The benefit of this approach is that it doesn’t require Shortcuts or Siri to open scriptable. The next approach does.
  2. Use x-callback-url. Shortcuts supports opening a x-callback-url and processing the result when a third party app invokes x-success. In Scriptable, you can use the URLScheme API to get the x-success URL and the Safari API to open the URL. It looks like the following:

Shortcut

Scriptable script

let params = URLScheme.allParameters()
let baseURL = params["x-success"]
let url = baseURL + "?hello=world&foo=bar"
Safari.open(url)
5 Likes