# Automation 1 — Reminder email (close − 10 days)

**Scope item 2:** email sent 10 days before the customization window closes, with a
personalized link, current tier + default selection, and the deadline.

## Recommended: Shopify Flow (scheduled) + email

Shopify Flow's **Scheduled time** trigger runs a workflow on a cron. Since the 10-day
mark is derived from each cycle's `close_at`, run a daily check and fire for whichever
cycle hits the mark.

### Workflow: "Wine Club — 10-day reminder"

1. **Trigger:** Scheduled time — daily at 09:00.
2. **Condition:** there exists a `wineclub_cycle` with `status = open` and
   `close_at` is exactly 10 days from today.
   - Flow can't query metaobjects directly today, so use one of:
     - **(a)** A tiny scheduled call to the App Proxy `/tasks/reminders` route (add it to
       the Worker) that returns the members to email and sends via the Shopify
       `customer email` / a transactional email provider. **Recommended** — one place.
     - **(b)** Keep a "reminder date" on the cycle and use Flow's date comparison.
3. **Action:** For each active member of that cycle, send email:
   - Subject: `Your {{cycle.name}} wine club box — customize by {{close_at | date}}`
   - Personalized link: `https://www.maisonfayard.com/pages/wine-club-customize`
     (the portal auto-resolves their tier + cycle on load; optionally append
     `?cycle={{handle}}` for clarity).
   - Body shows: tier label, the default box (3 or 6 bottles), deadline.

### If done in the Worker (recommended, route to add)

```
GET /apps/wineclub/tasks/reminders   (protected: run via Cloudflare Cron Trigger)
  → find open cycle with close_at == today+10
  → list active members (Appstle subscribers on that tier)
  → for each: send templated email (Shopify Email API / Postmark / Resend)
  → return { sent: N }
```

Cloudflare **Cron Triggers** can invoke the Worker daily with zero extra infra — this
keeps the "one small backend" principle instead of splitting logic across Flow.

## Email content (personalized)

- Greeting with first name.
- "Your Q2 2026 Classic Club box is ready to customize."
- Current default selection (bottle names).
- Deadline: **Customization closes May 30, 2026** (matches the portal banner).
- CTA button → portal.
- "Do nothing and we'll ship your curated default." (sets up the fallback, automation 3).
