n8n flows
Notify: New Draft PO Created
Emails brand users when a new draft purchase order is created, respecting their notification preferences.
When a new draft purchase order appears, this flow emails the relevant brand users. It honors each user's notification preferences and sends only once per PO.
At a glance
- Status: Active
- Trigger: Webhook (
POST /webhook/4d6d3f71-ca60-4ef5-8a66-34651953b801), responds immediately. - Runs on: A call from Hourly: Create Draft POs when it creates a new draft PO.
- Talks to: Supabase (Draft POs, Brands, userRoles, user_settings, Auth Admin API); Gmail.
How it works
- The webhook receives the draft PO id.
- The flow reads the draft PO record and checks
notification_sent; if already sent, it stops. - It sets
notification_sent = true, then in parallel fetches the PO's account brand and its active users. Loop Over Usersreads each user's preferences and checkssend_notificationsandinventory_management.draft_pos.- For opted-in users it fetches the email through the Supabase Auth Admin API and sends a branded HTML notification via Gmail linking to the purchase-orders page.
Notes
- Idempotent via the
notification_sentflag: one email per PO. - Per-user opt-in gated on two preference flags.