GUIDE

Call a JavaScript function from Siri Shortcuts

Updated September 09, 2026 By microfn 2 min read
siri shortcuts webhook ios

Apple Shortcuts can call a deployed Microfn function with Get Contents of URL. This gives a shortcut a small JavaScript backend without running a server on your Mac or iPhone.

Create the function

Create a function named format-note in Microfn:

type Input = { title?: string; body?: string };

export async function main(input: Input) {
  const title = input.title?.trim() || "Untitled";
  const body = input.body?.trim() || "";

  return {
    markdown: `# ${title}\n\n${body}`,
    createdAt: new Date().toISOString(),
  };
}

Save the function, open Triggers, and copy its HTTP run URL.

Build the shortcut

In Shortcuts on iPhone, iPad, or Mac:

  1. Add Ask for Input twice, once for a title and once for the note body.
  2. Add a Dictionary with title and body, using the two provided-input variables.
  3. Add Get Contents of URL and paste the Microfn run URL.
  4. Set the method to POST, set the request body to JSON, and use the dictionary as the body.
  5. Add Get Dictionary Value for markdown, then send that value to Notes, the clipboard, or another shortcut action.

Run the shortcut once and inspect the matching entry under Executions in Microfn. If the input arrives in a wrapper, use the captured execution to adjust the function to the exact shape delivered by the HTTP trigger.

Protect sensitive actions

Anyone who can call an unauthenticated run URL may be able to trigger its side effects. Keep the function read-only or low-impact unless you add an authentication check that the Shortcuts request can supply. Store downstream API credentials as function secrets, never in the shortcut URL.

For server-to-server events, use the JavaScript webhook guide. For recurring work, schedule the function with cron.

Related guides

All guides