Skip to content

Ask HN: Any way to program Siri Shortcuts in iOS 12 besides drag-and-drop?

14 pointsyangl19967 comments
On HN

The Shortcuts app in iOS 12 seems really powerful, comparable to a minimal weakly-typed scripting language. So I'm wondering whether there is an AppleScript-like way to program it, instead of dragging and dropping those blocks.

If not, will anyone be interested in some sort of tool that converts source code (in, say, a subset of Python or Bash) to Shortcuts program?

Comments

I just did some sleuthing and it looks like you can create a shortcut using XML. :)

You can reverse engineer the format by creating an iCloud link to a shortcut. There's a JSON payload that that the shortcut permalink page requests. That payload contains a link to a binary plist which can be translated into XML (`plistutil -i shortcut.plist`).

Here's one I just generated that expands shortened URLs: https://gist.github.com/dlo/1217af3b86f363faf578aa23408c19ef

After you write your shortcut, encode it in binary plist format (using plistutil), and then upload that blob to a URL. Use the following scheme to import it into Shortcuts.app:

    workflow://import-workflow/?name=URL20%Expander&url=encodedUrl
Hope this helps!

Thanks, that's really cool!

I just started working on this library, maybe it can be helpful :)

https://github.com/alexander-akhmetov/python-shortcuts

Cool, thanks! This one does have deep integration with Shortcuts.

It looks like if you buy pythonista ($10!) you can execute python scripts.

Thanks! I think Shortcuts has access to some lower-level system configs/functions which Pythonista doesn't have. Also, although Shortcuts can invoke a Pythonista script, control won't automatically return to Shortcuts after the script is executed. So I'm looking for a way to do everything within Shortcuts.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.