# UniFi Protect package delivered notifications on your phone > Get a push notification when a UniFi Protect camera spots a package at your door, with a button to open the event clip. - Company: UniFi Protect (https://www.justpush.io/recipes/unifi) - Event: `package` (Package) - Tags: Smart home, Security - Install: https://studio.justpush.io/recipes/unifi/package-detected - Web page: https://www.justpush.io/recipes/unifi/package-detected ## Setup 1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL. 2. In UniFi Protect, go to Settings > Alarm Manager and click Add Alarm. 3. Set the trigger to Package and select the camera(s) it should watch. 4. Under actions, add a Webhook with method POST and paste your webhook URL (shown in Studio after install)?tz=Europe/Amsterdam as the URL, using your own time zone. 5. Save the alarm, then press Test to send a sample event. 6. Add your time zone to the webhook URL so the notification shows the local time: 7. ``` 8. your webhook URL (shown in Studio after install)?tz=Europe/Amsterdam 9. ``` 10. Use your own [time zone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). UniFi only sends a UTC timestamp; without `tz`, the time is left out of the message. 11. Alarm Manager sends every alarm to the same webhook shape. This recipe only reacts when the alarm contains a package trigger, so it stays quiet if you point other alarms at the same integration. 12. Give the alarm a descriptive name, like "Front Door Package". The payload only identifies the camera by its MAC address, so the alarm name is what tells you where it happened. 13. The **View clip** button uses `eventLocalLink`, which only resolves on your home network (and shows a certificate warning). Away from home it won't load. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // UniFi Protect → package detected // Fires when a UniFi Protect camera (e.g. G4 Doorbell Pro / G6 Entry) spots a package. // // Set this up as an Alarm Manager alarm in UniFi Protect with a "Package" // trigger and a Webhook action pointing at your JustPush Studio integration URL. // UniFi only sends a UTC timestamp, not your console's time zone, so the time zone comes // from the webhook URL: ?tz=Europe/Amsterdam. Without one (or with an unknown name) the // time is left out rather than shown in the server's time zone. function localTime(timestamp, request) { const timeZone = typeof request.query?.tz === "string" ? request.query.tz.trim() : "" if (!timestamp || !timeZone) return null try { return new Date(timestamp).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit", timeZone }) } catch { return null // not a time zone name this runtime knows } } function handleRequest(request) { const alarm = (request.body || {}).alarm // Guard: ignore anything that isn't a UniFi Protect alarm payload. if (!alarm || !Array.isArray(alarm.triggers)) { console.log("Not a UniFi Protect alarm payload — skipping") return null } // Alarm Manager sends every alarm to the same webhook, so only handle packages. const parcel = alarm.triggers.find((trigger) => trigger?.key === "package") if (!parcel) { console.log(`Ignoring "${alarm.name ?? "unknown"}" alarm — no package trigger`) return null } const seenAt = localTime(parcel.timestamp, request) // The payload only carries the camera's MAC, so the alarm name is the most // readable hint of where this happened (e.g. "Front Door Package"). const where = alarm.name ? ` — ${alarm.name}` : "" // The local link only resolves on your LAN, and only when the event was recorded. const eventLink = alarm.eventLocalLink return { title: "📦 Package delivered", message: (seenAt ? `A package was left at ${seenAt}` : "A package was left at your door") + where, topic: "UniFi Protect", priority: 0, // Normal — good to know, nobody is waiting on you // sound: "incoming", // any of Studio's sounds, e.g. incoming, bugle, siren buttons: eventLink ? [{ cta: "View clip", url: eventLink }] : [], } } ``` ## UniFi Protect package webhook payload (sample) ```json { "alarm": { "name": "Front Door Package", "sources": [], "triggers": [ { "key": "package", "device": "FAKE_MAC", "eventId": "testEventId", "timestamp": 1783505319282 } ], "eventPath": "/protect/events/event/testEventId", "conditions": [ { "condition": { "type": "is", "source": "package" } } ], "eventLocalLink": "https://192.168.1.1/protect/events/event/testEventId" }, "timestamp": 1783505319286 } ``` ## FAQ ### Does this work on iPhone and Android? Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification. ### Do I need to write code? No. Install the recipe in Studio, paste your webhook URL into UniFi Protect and you are done. The code is there if you want to change the text, the sound or the buttons. ### Can I change what the notification says? Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save. ### What does it cost? JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.