Tutorial: Retrieving Floating Menu Content via Shortcuts App

The Shortcuts app offers many useful functions and there might be some pretty cool use cases for defining floating menus via a Shortcut. E.g. creating a HomeKit controller or displaying some other app data.

Here is a simple tutorial on how to use the Simple JSON Format to define a menu's content via a Shortcut.

Note I'm absolutely no expert at Shortcuts, this was just the quickest way I could make it work.

This example will retrieve some Calendar events and display them in a Floating Menu. The idea is to make the Shortcut return a simple JSON array like this:

[
{"title": "some title\nwith two lines"},
{"title": "some other title\nwith two lines"},
]

Additionally we will make use of the "Simple JSON Format's" templateitemuuid property, which allows us to specify one or multiple items to use as styling template for the Floating Menu items.

Let's first create a Floating Menu Item and add a template item to it. We want the calendar event to be shown in two lines, so the template item should reflect this:

Disable that item (cmd+d) and copy its UUID (right-click, "Copy selected item UUID")

Now let's first create a Shortcut that retrieves the 5 upcoming calendar events. It can be done like this:

https://www.icloud.com/shortcuts/4803d57a16ab4e54b0dd6b5e4b6885a7

Finally let's enable a content retrieval script on the Floating Menu that calls this shortcut to retrieve the items:

async function retrieveJSON() {
  let items = await runAppleShortcut({name: "CalendarEventsExample"});
  return items;
}

Done!

This technique can be used for all kind of things available in the Shortcuts app.