Create a form as input to Shortcuts action

I am new to Scriptable. I would like to create a script that is run using the Run Shortcut action to display a data input form, and passes the input to another Shortcut action (perhaps as CSV) for further processing. Assuming this is doable with Scriptable can anyone please provide a simple example?

Could you not just do this in shortcuts?

Here’s an example.

If you really wanna use Scriptable…


var myTextInput = new Alert()
myTextInput.title = "Input:"
myTextInput.addTextField("Column 1")
myTextInput.addTextField("Column 2")
myTextInput.addTextField("Column 3")

let inPut = await myTextInput.presentAlert()

var result = [myTextInput.textFieldValue(0), myTextInput.textFieldValue(1), myTextInput.textFieldValue(2)]

console.log(result)

I’m still a Scriptable newbie but this script works (I think).

Thanks, but what I was trying to test was whether I could use Scriptable from a shortcut to receive input which is passed to later actions. Yes, I can get input without using Scriptable but I am trying to find a way (ultimately) to have a complex data form(with pull downs, check boxes, etc.) that is filled in by the user and where the data is then processed by shortcut actions. I have yet to find any app that can work with Shortcuts in this way. FYI, the test script above cannot be called from Shortcuts as it says that alerts are not supported by Siri.

What I am looking for is doable with Pythonista using the internal webserver and appropriate HTML/JS but I am reluctant to tie this to a (wonderful) app that is no longer being actively supported by the author.

The script can be called with Shortcuts, you need to check the Open in Scriptable toggle.

If you want to have a complex data form, you can do this in Scriptable with WebViews. Unfortunately I cannot help you with that. There are other posts on the forum that deal with similar topics from more experienced automators than I.

You are right, the Shortcut that calls that script does not produce an error if the Open in Scriptable toggle is ON. However, how do I give control back to the Shortcut and pass the data so that following actions can process it?

I will also look into Scriptable webviews. I have not found any examples that take input and bring it back to Shortcuts.

to go back to shortcuts add this to the end of the script:

Script.complete()
Safari.open("shortcuts://")

Then you can use the Script Output magic variable in shortcuts.

There are no existing examples that explicitly do what you want, but you can tweak them a little for your purposes.

Couple of (beginner) questions. The original script above, does a console.log for output. This does not result in any output coming back as a result to the Shortcut. Do I merely replace that with a return statement? Also, is alert the sole way of requesting input? is there any downside to “run in App”?

From what I can tell, set Script.ShortcutOutput() will not work if Run in App is set (which I apparently need due to the Alert for input). How to get output back to the Shortcut? x-callback?

I’m pretty beginner too but I will try to answer!

  1. yes I think all input requires run in app. Unless you pass input from shortcuts.
  2. return action should work, yes. If not, I dunno. I think it should return a magic variable but I am not sure to be honest.

Hope I was of some help :slight_smile:

Return won’t work. See this reply Simon sent me on Twitter.

In case you find them useful there’s a few examples around calling Scriptable here:

And an old example that round trips utiliting x-callback-url that is probably equivalent to the simplest of forms.

Hope that helps.

Not being able to return a result to Shortcuts is quite a limitation, especially surprising given that there are several Scriptable Shortcut actions. I hope that Shortcuts in ios14 makes it easier to integrate Scriptable.