# n8n pass-through: Sarvam → Calendar

Thin webhook between Sarvam agent `saloon-spa-784bd53b-e858` (`book_slot`) and the host booking API.

## Flow

```
Sarvam book_slot
  → POST n8n /webhook/calendar-book-slot
  → POST https://calendar.gventure.info/api/v1/hosts/336d3947-0b4d-4c40-a267-f35c3850fd1b/bookings
  → same JSON back to Sarvam
```

Calendar responses (unchanged):

- `{ "created": true, "booking": { ... } }` — booked
- `{ "created": false, "availableTimes": [ ... ] }` — offer alternatives

## Live n8n workflow

| Field | Value |
|-------|--------|
| n8n UI | `http://192.187.106.194:5678` |
| Workflow id | `lAfghFlUMaJsIrDm` |
| Workflow name | Sarvam to Calendar book_slot pass-through |
| HTTP webhook | `http://192.187.106.194:5678/webhook/calendar-book-slot` |

Importable export: [`n8n-calendar-book-slot.json`](./n8n-calendar-book-slot.json)

## HTTPS URLs (Sarvam requires https)

Sarvam cannot call plain `http://`. Use one of these permanent fronts after deploy:

1. **Apache** (preferred): `https://calendar.gventure.info/n8n-webhook/calendar-book-slot`  
   Enabled by [`deploy/apache-calendar.gventure.info.conf`](../deploy/apache-calendar.gventure.info.conf) + `sudo bash scripts/configure-apache.sh`

2. **Calendar API proxy**: `https://calendar.gventure.info/api/v1/integrations/n8n/book-slot`  
   Implemented in [`node/src/routes/n8n.routes.ts`](../node/src/routes/n8n.routes.ts)  
   Optional env: `N8N_BOOK_SLOT_WEBHOOK_URL` (defaults to `http://127.0.0.1:5678/webhook/calendar-book-slot`)

## Sarvam

Agent `saloon-spa-784bd53b-e858` `book_slot` must point at an **https** n8n front URL above.

Committed agent version **8** currently uses a temporary Cloudflare tunnel HTTPS URL so Sarvam can reach n8n before Apache is patched. After you run `sudo bash scripts/enable-n8n-https-proxy.sh` on the server, update `book_slot.url` to:

`https://calendar.gventure.info/n8n-webhook/calendar-book-slot`

Keep body fields:

- `startTime`, `guestName`, `guestEmail`, `guestTimezone`

Keep the existing `resp_template` that branches on `created` / `availableTimes`.

After changing the URL, commit a new agent version.

## Smoke test

```bash
curl -sS -X POST "http://192.187.106.194:5678/webhook/calendar-book-slot" \
  -H "Content-Type: application/json" \
  -d '{
    "startTime": "2026-10-10T09:00:00.000Z",
    "guestName": "n8n Smoke Test",
    "guestEmail": "n8n-smoke@example.com",
    "guestTimezone": "Asia/Kolkata"
  }'
```

Expect either `created: true` or `created: false` with `availableTimes`.
