# Embed Form in Wix (Shortcode)

Your automation runs on **your server**. Wix only displays the form via an embed snippet.

---

## Option 1 — Script embed (recommended)

1. Deploy this app to a public URL (e.g. `https://automation.yourdomain.com`)
2. In **Wix Editor** → open the page where you want the form
3. Click **Add (+)** → **Embed Code** → **Embed HTML**
4. Paste:

```html
<script src="https://YOUR-SERVER-URL/embed/form.js"></script>
<div data-lipbp-form></div>
```

5. Resize the embed box to fit the form (~500px tall)
6. **Publish** your Wix site

The form submits to your server and starts the full email + SMS automation.

---

## Option 2 — iFrame embed

Use if Wix blocks external scripts:

```html
<iframe
  src="https://YOUR-SERVER-URL/embed/form"
  width="100%"
  height="620"
  frameborder="0"
  style="border:none;border-radius:12px;"
  title="Long Island Pickleball Pros — Get Started">
</iframe>
```

---

## Option 3 — Custom element ID

```html
<script src="https://YOUR-SERVER-URL/embed/form.js"></script>
<div id="lipbp-form"></div>
```

---

## Local testing on Wix

While developing locally, use a tunnel (ngrok, Cloudflare Tunnel) so Wix can reach your machine:

```bash
ngrok http 3847
```

Then paste the ngrok URL in the embed code:

```html
<script src="https://abc123.ngrok.io/embed/form.js"></script>
<div data-lipbp-form></div>
```

---

## Security — site key

Set `EMBED_SITE_KEY` in your `.env` file. The form sends this key with every submission to prevent spam.

---

## Hooking up bookings (outside Wix)

When a customer books on your site or scheduling tool, POST to your API:

**Booking confirmed:**
```bash
POST /api/bookings/confirm
{
  "email": "customer@email.com",
  "service_name": "Learn to Play Clinic",
  "session_at": "2026-07-15T10:00:00.000Z",
  "location": "Smithtown Courts"
}
```

**Booking abandoned:**
```bash
POST /api/bookings/abandon
{
  "email": "customer@email.com",
  "service_name": "Learn to Play Clinic",
  "resume_url": "https://your-site.com/book/resume/abc"
}
```

**Session attended (mark check-in):**
```bash
POST /api/bookings/checkin
{ "email": "customer@email.com" }
```

**No-show:**
```bash
POST /api/bookings/no-show
{ "email": "customer@email.com" }
```

Use Zapier/Make to connect Calendly, Acuity, or Wix Bookings webhooks to these endpoints.

---

## Preview form locally

Open: http://localhost:3847/embed/form
