Receive a value from Scriptable in Shortcuts

I’m looking for a way to receive a value from Scriptable in Shortcuts action.
args.all do the way from Shortcuts to Scriptable. Is there any command in reverse direction?

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

I appreciate your detailed guide to work around this issue! I’ll adapt x-callback-url way because it looks straightforward than pasteboard-way.
Feel wretched Apple putting a limit on interconnectivity between Shortcuts and third-party apps. Anyway, we can do this!

Hi, I was looking into a way to pass arguments into the script and as you guys noted above it can’t be done at the moment. However I saw that there is this shortcut action for Pythonista where they can pass input into sys.args

Any idea how they do that? I’m going to try to use it a little bit see if I can find something but you guys work on the scriptable app so you probably have better insight.

It’s built into the URL scheme for Pythonista, which is what Shortcuts is making use of, and sys is a Python module that Pythonista is making use of, with sys.argv being a standard Python construction.

In effect the details above on the x-callback-url for Scriptable are doing the same thing, just grabbing the data string directly. I think you should be able to write a function to process it like the sys module in Pythonista is doing. Just split the return with the parameter returns in the URL.

I’m trying to pass the contents of a object to a shortcut with x callback url which is new to me. I am new to x callback urls. As best I can tell I need a base url then add parameters which will be my object data. I cant tell what the base url should be in order to add data to my shortcut. Any help would be appreciated.

While x-callback-url is still available, and arguably has its place, using Shortcuts actions is generally easier, and Scriptable has some great ones.

Consider starting a new topic (this one is a year old and obviously isn’t getting you where you want to be) with full details of what you have and what you want to do.