Posted in

Send iOS Shortcuts automation data in background to a webhook

When you send data from Apple’s Shortcuts app to a webhook from a personal automation, you get those annoying notifications on your lock screen. Even when you tell the shortcut to stay silent. It won’t do that for data sent to a local app on your device. So the trick is to set up a little proxy app that will call the webhook.

What you need

  • Apple device
  • Shortscuts app
  • Scriptable app
  • Webhook target (i.e. Home Assistant)
  • An app with Shortcuts data

My setup

For this example I use my iPhone with iOS 26, DataMan app as data source, Scriptable app as proxy which is called by the shortcut, and a webhook automation in Home Assistant as receiver.

Start at the end: the webhook

Go to Home Assistant → Settings → Automations → Add a new one

Trigger

 
trigger: webhook
webhook_id: iphone-dataman-stats
allowed_methods:
  - POST
local_only: true
webhook_idreferenced in shortcut
local_onlyonly allow LAN access, set to ‘false’ if you use the HA external URL

Action

I created numeric helpers that will store the data usage.

Set the value template.

Scriptable tells HA it is sending JSON data, so then HA will parse the body and provide the fields in trigger.json throughout the automation.

 
{{ trigger.json.megabytes_left | float(0) }}

Next: Scriptable proxy

Download the app and create a new script with the code below.

Make sure to point the url to your webhook target. The code below works for all Home Assistant webhooks, so I have to maintain only one script. The shortcut will define the webhook_id for the HA trigger.

ℹ️ When you set the Content-Length header Home Assistant won’t parse the JSON to trigger.json data. So then you will have to do the parsing in your HA templates yourself. It’s easier without it.

The app must return something or else you get notifications again. I use the HTTP response code or error message. Could be nice for debugging and error handling.

 
try {
  const data = args.shortcutParameter;
  const webhook_id = data.webhook_id;
  delete data.webhook_id;

  const url = `http://homeassistant:8123/api/webhook/${webhook_id}`;

  const req = new Request( url );
  req.method = 'POST';
  req.body = JSON.stringify( data );
  req.headers = {
    'Content-Type': 'application/json',
  };
  req.timeoutInterval = 2;

  await req.load();
  return req.response.statusCode;
}
catch ( err ) {
  return err.message;
}

Finally: The shortcut itself

In the Shortcuts app (Opdrachten in Dutch) create a new shortcut.

Add the data source, DataMan for me → Smart Forecast

Disable the ‘Display execution’ toggle

Then add a dictionary

  1. New itemText
    1. key = webhook_id
    2. text = ios-dataman-stats (from earlier)
  2. New itemText
    1. key = megabytes_left
    2. text = app icon – Statistics
  3. Tap the app Statistics item and choose Megabytes Left

Now add ScriptableRun script

  • Script → choose your proxy script
  • Parameter → should already be set to dictionary
  • Display execution → disable

Give your shortcut a name and fancy icon.

Automation

Go back to the list → Automations+ → Personal (default) → Choose something

At the bottom choose ‘Execute immediately’ and disable ‘Notify when executed

Tap Next button → My shortcuts → Your new webhook shortcut

Leave a Reply

Your email address will not be published. Required fields are marked *