# Workflow Triggers

This guide lists the workflow triggers supported by the portal, what each trigger is for, the useful payload fields, sample payload shapes, and common ways to use each trigger in workflow conditions and actions.

Do not paste real patient information, tokens, API keys, or PHI into workflow documentation, test payloads, email templates, SMS templates, or webhook examples.

## How to Use Payload Fields

Workflow conditions use plain payload paths:

```
order.status equals PROCESSING
payment.status equals FAILED
intake.status equals PENDING
cart.converted equals false
event.daysUntilRenewal equals 5
```

Merge tags in email, SMS, and webhook body fields use double braces:

```
{{patient.firstName}}
{{patient.email}}
{{order.orderNumber}}
{{order.total}}
{{subscription.id}}
{{intake.formName}}
{{paymentRecovery.recoveryUrl}}
```

For wait-based workflows, enable refresh/latest payload on the condition step after the wait when available. This is important for abandoned cart, intake pending, payment recovery, and delayed follow-up workflows.

## Condition Operators

| Operator       | Use                         |
| -------------- | --------------------------- |
| `equals`       | Exact value match           |
| `not_equals`   | Exact value does not match  |
| `contains`     | Text/array contains a value |
| `exists`       | Field has a non-empty value |
| `not_exists`   | Field is missing or empty   |
| `greater_than` | Numeric comparison          |
| `less_than`    | Numeric comparison          |

## Common Payload Objects

Most triggers include one or more of these objects:

| Object            | Meaning                                                              |
| ----------------- | -------------------------------------------------------------------- |
| `event`           | Trigger-specific event metadata                                      |
| `patient`         | Patient/contact details                                              |
| `customer`        | Checkout/cart customer details before a full patient exists          |
| `lead`            | CRM lead details                                                     |
| `order`           | Order status, totals, source, intake summary, and subscription links |
| `subscription`    | Primary subscription details                                         |
| `subscriptions`   | Related subscriptions array                                          |
| `invoice`         | Invoice details                                                      |
| `payment`         | Payment details                                                      |
| `paymentRecovery` | Recovery/dunning fields for failed payments                          |
| `cart`            | Cart or checkout session details                                     |
| `products`        | Products/line items involved in the event                            |
| `lineItems`       | Order line item details                                              |
| `intake`          | Intake/form response details                                         |
| `formResponse`    | Raw form response summary                                            |
| `form`            | Intake form metadata                                                 |
| `appointment`     | Appointment details                                                  |
| `prescription`    | Prescription details                                                 |
| `beluga`          | Beluga webhook/event details                                         |

## Trigger Summary

| Trigger                        | Fires When                              | Common Condition Fields                                        | Common Merge Tags                                        |
| ------------------------------ | --------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------- |
| `lead.created`                 | New CRM lead is created                 | `lead.source`, `lead.status`                                   | `{{lead.firstName}}`, `{{lead.email}}`                   |
| `lead.status_changed`          | Lead status changes                     | `previousStatus`, `newStatus`, `lead.status`                   | `{{lead.email}}`, `{{newStatus}}`                        |
| `patient.created`              | New patient is created                  | `patient.email`, `patient.mrn`                                 | `{{patient.firstName}}`, `{{patient.email}}`             |
| `patient.updated`              | Patient is updated                      | `patient.city`, `patient.state`, `patient.phone`               | `{{patient.firstName}}`, `{{patient.phone}}`             |
| `subscription.created`         | New subscription is created             | `subscription.status`, `subscription.product.id`               | `{{subscription.id}}`, `{{patient.email}}`               |
| `subscription.cancelled`       | Subscription is cancelled               | `subscription.status`                                          | `{{patient.firstName}}`, `{{subscription.id}}`           |
| `subscription.paused`          | Subscription is paused                  | `subscription.status`                                          | `{{patient.email}}`, `{{subscription.id}}`               |
| `subscription.activated`       | Subscription becomes active again       | `subscription.status`                                          | `{{patient.email}}`, `{{subscription.id}}`               |
| `subscription.upcomingrenewal` | Before next billing date                | `event.daysUntilRenewal`, `subscription.nextBillingDate`       | `{{event.nextBillingDate}}`, `{{patient.email}}`         |
| `subscription.order.created`   | Subscription billing creates an order   | `order.status`, `subscription.id`                              | `{{order.orderNumber}}`, `{{subscription.id}}`           |
| `order.created`                | New order is created                    | `order.source`, `order.intakeRequired`, `order.pendingFormIds` | `{{order.orderNumber}}`, `{{order.total}}`               |
| `order.updated`                | Order is updated                        | `previousStatus`, `order.status`, `order.intakeSubmitted`      | `{{order.orderNumber}}`, `{{order.status}}`              |
| `order.cancelled`              | Order is cancelled                      | `order.status`, `event.reason`                                 | `{{order.orderNumber}}`, `{{event.reason}}`              |
| `order.refunded`               | Order is refunded                       | `order.status`, `payment.status`                               | `{{order.orderNumber}}`, `{{payment.amount}}`            |
| `beluga.webhook_received`      | Beluga webhook arrives                  | `beluga.event`, `beluga.visitOutcome`, `beluga.masterId`       | `{{beluga.event}}`, `{{order.id}}`                       |
| `checkout.started`             | Cart/checkout session starts            | `cart.converted`, `cart.status`                                | `{{cart.cartId}}`, `{{customer.email}}`                  |
| `cart.viewed`                  | Cart page is opened/fetched             | `cart.status`, `cart.total`                                    | `{{cart.cartId}}`, `{{customer.email}}`                  |
| `cart.abandoned`               | Open cart is marked abandoned           | `cart.status`, `event.idleMinutes`                             | `{{cart.cartId}}`, `{{customer.email}}`                  |
| `cart.failed`                  | Cart checkout/payment fails             | `cart.status`, `payment.status`                                | `{{cart.cartId}}`, `{{payment.status}}`                  |
| `payment.succeeded`            | Payment succeeds                        | `payment.status`, `order.status`                               | `{{payment.transactionId}}`, `{{order.orderNumber}}`     |
| `payment.failed`               | Payment fails                           | `payment.status`, `order.recoveryStatus`, `order.retryCount`   | `{{paymentRecovery.recoveryUrl}}`, `{{patient.email}}`   |
| `intake.pending`               | Intake is assigned/required and pending | `intake.status`, `intake.isPending`, `intake.formId`           | `{{intake.formName}}`, `{{patient.email}}`               |
| `intake.completed`             | Patient submits intake                  | `intake.review.status`, `intake.formId`                        | `{{intake.formName}}`, `{{patient.email}}`               |
| `intake.resubmitted`           | Patient resubmits after correction      | `intake.isResubmission`, `intake.review.status`                | `{{intake.formName}}`, `{{patient.email}}`               |
| `intake.reviewed`              | Staff reviews intake                    | `intake.review.status`                                         | `{{intake.review.status}}`, `{{patient.email}}`          |
| `intake.approved`              | Staff approves intake                   | `intake.review.status`                                         | `{{patient.firstName}}`, `{{intake.formName}}`           |
| `intake.needs_correction`      | Staff requests correction               | `intake.review.status`, `event.reason`                         | `{{intake.review.note}}`, `{{patient.email}}`            |
| `intake.rejected`              | Staff rejects intake                    | `intake.review.status`, `event.reason`                         | `{{event.reason}}`, `{{patient.email}}`                  |
| `appointment.created`          | Appointment is created                  | `appointment.status`, `appointment.id`                         | `{{appointment.title}}`, `{{patient.email}}`             |
| `appointment.completed`        | Appointment is completed                | `appointment.status`                                           | `{{appointment.title}}`, `{{patient.email}}`             |
| `prescription.created`         | Prescription is created                 | `prescription.medication`, `prescription.sentAt`               | `{{prescription.medication}}`, `{{patient.email}}`       |
| `prescription.updated`         | Prescription is updated                 | `prescription.dosage`, `prescription.instructions`             | `{{prescription.medication}}`, `{{prescription.dosage}}` |
| `prescription.sent`            | Prescription is sent                    | `prescription.sentAt`                                          | `{{prescription.medication}}`, `{{patient.email}}`       |
| `manual`                       | Manual workflow test only               | Any field in test payload                                      | Any field in test payload                                |

## Recommended Workflow Patterns

### Intake reminder after 5 minutes

Use this when you want to remind a patient if a required or assigned intake is still pending.

```
Trigger: intake.pending
Step 1: Wait 5 minutes
Step 2: Condition, refresh latest payload enabled
Condition: intake.status equals PENDING
True path: send SMS/email/webhook reminder
False path: exit
```

Useful fields:

```
intake.status
intake.isPending
intake.formId
intake.formName
patient.email
patient.phone
order.id
order.orderNumber
subscription.id
```

### Abandoned checkout follow-up

Use this when checkout starts but the cart has not converted after a wait.

```
Trigger: checkout.started
Step 1: Wait 30 minutes
Step 2: Condition, refresh latest payload enabled
Condition: cart.converted equals false
True path: send recovery email/SMS
False path: exit
```

Useful fields:

```
cart.cartId
cart.status
cart.converted
cart.orderId
customer.email
patient.email
products.0.name
marketing.source
```

### Failed payment recovery

Use this for dunning, failed subscription renewals, and recovery links.

```
Trigger: payment.failed
Condition: order.recoveryStatus equals RETRY_SCHEDULED
Action: send email/SMS with paymentRecovery.recoveryUrl
```

Useful fields:

```
payment.status
order.recoveryStatus
order.retryCount
order.nextRetryAt
paymentRecovery.recoveryUrl
patient.email
subscription.id
```

### Upcoming renewal reminder

Use this when subscription renewal reminders should go out before the next billing date.

```
Trigger: subscription.upcomingrenewal
Condition: event.daysUntilRenewal equals 5
Action: send reminder
```

Useful fields:

```
event.daysUntilRenewal
event.nextBillingDate
subscription.nextBillingDate
subscription.product.name
patient.email
```

### Intake review decision

Use this for approval, rejection, or correction workflows.

```
Trigger: intake.reviewed
Condition: intake.review.status equals NEEDS_CORRECTION
Action: send correction instructions
```

For simpler workflows, use the specific trigger:

```
intake.approved
intake.needs_correction
intake.rejected
```

## Sample Payloads

The examples below are intentionally short. Real payloads may include more fields such as billing, shipping, line items, marketing attribution, invoice, payment, subscriptions, and review history.

### `lead.created`

```json
{
  "lead": {
    "id": "lead_test_1",
    "firstName": "Test",
    "lastName": "Lead",
    "email": "lead@example.com",
    "phone": "+15551234567",
    "status": "NEW",
    "source": "Landing Page"
  }
}
```

### `lead.status_changed`

```json
{
  "lead": {
    "id": "lead_test_1",
    "email": "lead@example.com",
    "status": "QUALIFIED"
  },
  "previousStatus": "NEW",
  "newStatus": "QUALIFIED"
}
```

### `patient.created`

```json
{
  "patient": {
    "id": "pat_test_1",
    "mrn": "MRN-TEST",
    "firstName": "Test",
    "lastName": "Patient",
    "email": "test@example.com",
    "phone": "+15551234567"
  }
}
```

### `patient.updated`

```json
{
  "patient": {
    "id": "pat_test_1",
    "firstName": "Test",
    "lastName": "Patient",
    "email": "test@example.com",
    "phone": "+15557654321",
    "city": "San Diego",
    "state": "CA"
  }
}
```

### `subscription.created`

```json
{
  "subscription": {
    "id": "sub_test_1",
    "status": "ACTIVE",
    "amount": 199,
    "interval": "monthly",
    "nextBillingDate": "2026-06-20T12:00:00.000Z",
    "product": {
      "id": "prod_test_1",
      "name": "Weight Loss Program"
    },
    "currentPhase": {
      "id": "phase_1",
      "name": "Starter Phase",
      "belugaVisitType": "weightloss"
    }
  },
  "phaseInfo": {
    "cycleInPhase": 1,
    "totalPhases": 3
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `subscription.cancelled`

```json
{
  "subscription": {
    "id": "sub_test_1",
    "status": "CANCELLED",
    "cancelledAt": "2026-05-22T12:00:00.000Z"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `subscription.paused`

```json
{
  "subscription": {
    "id": "sub_test_1",
    "status": "PAUSED"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `subscription.activated`

```json
{
  "subscription": {
    "id": "sub_test_1",
    "status": "ACTIVE"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `subscription.upcomingrenewal`

```json
{
  "event": {
    "source": "SUBSCRIPTION_UPCOMING_RENEWAL",
    "subscriptionId": "sub_test_1",
    "daysUntilRenewal": 5,
    "nextBillingDate": "2026-06-20T12:00:00.000Z"
  },
  "subscription": {
    "id": "sub_test_1",
    "status": "ACTIVE",
    "nextBillingDate": "2026-06-20T12:00:00.000Z"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `subscription.order.created`

```json
{
  "event": {
    "source": "SUBSCRIPTION_CYCLE",
    "subscriptionId": "sub_test_1",
    "cycleNumber": 3
  },
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "AWAITING_FULFILLMENT",
    "subscriptionId": "sub_test_1",
    "total": 199
  },
  "subscription": {
    "id": "sub_test_1",
    "status": "ACTIVE"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `order.created`

```json
{
  "event": {
    "source": "CHECKOUT_CART",
    "cartId": "crt_test_123"
  },
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "PENDING",
    "total": 299,
    "source": "BUY_URL",
    "sourceContext": "CHECKOUT",
    "subscriptionId": "sub_test_1",
    "intakeRequired": true,
    "intakeSubmitted": false,
    "intakeComplete": false,
    "requiredFormIds": ["form_weight_history", "form_medical_screening"],
    "submittedFormIds": ["form_weight_history"],
    "pendingFormIds": ["form_medical_screening"]
  },
  "payment": {
    "id": "pay_test_1",
    "status": "SUCCEEDED",
    "amount": 299
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `order.updated`

```json
{
  "previousStatus": "PENDING",
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "PROCESSING",
    "intakeRequired": true,
    "intakeSubmitted": true,
    "pendingFormIds": []
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `order.cancelled`

```json
{
  "event": {
    "source": "ORDER_STATUS_CHANGE",
    "orderId": "ord_test_1",
    "previousStatus": "PENDING",
    "newStatus": "CANCELLED",
    "reason": "Patient requested cancellation"
  },
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "CANCELLED"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `order.refunded`

```json
{
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "REFUNDED",
    "total": 299
  },
  "payment": {
    "id": "pay_test_1",
    "status": "REFUNDED",
    "amount": 299
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `beluga.webhook_received`

```json
{
  "event": {
    "source": "BELUGA",
    "type": "beluga.webhook_received",
    "orderId": "ord_test_1",
    "masterId": "ord_test_1",
    "belugaEvent": "BOOKING_CREATED"
  },
  "beluga": {
    "event": "BOOKING_CREATED",
    "masterId": "ord_test_1",
    "docName": "Dr. Test Beluga",
    "scheduledDate": "2026-05-22T12:00:00.000Z",
    "location": "Virtual",
    "bookingLink": "https://booking.example.test"
  },
  "order": {
    "id": "ord_test_1"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `checkout.started`

```json
{
  "event": {
    "source": "BUY_URL",
    "cartId": "crt_test_123",
    "sourcePath": "/buy/test",
    "sourceDomain": "google.com"
  },
  "cart": {
    "cartId": "crt_test_123",
    "status": "OPEN",
    "converted": false,
    "isConverted": false,
    "orderId": null,
    "total": 199,
    "currency": "USD"
  },
  "customer": {
    "email": "test@example.com"
  },
  "products": [
    {
      "id": "prod_test_1",
      "name": "Test Product",
      "type": "subscription",
      "price": 199
    }
  ]
}
```

### `cart.viewed`

```json
{
  "event": {
    "source": "CART_PAGE_VIEW",
    "cartId": "crt_test_123",
    "viewedAt": "2026-05-22T12:00:00.000Z"
  },
  "cart": {
    "cartId": "crt_test_123",
    "status": "OPEN",
    "total": 199,
    "currency": "USD"
  },
  "customer": {
    "email": "test@example.com"
  }
}
```

### `cart.abandoned`

```json
{
  "event": {
    "source": "CART_PROCESSOR",
    "status": "ABANDONED",
    "reason": "IDLE_TIMEOUT",
    "idleMinutes": 95
  },
  "cart": {
    "cartId": "crt_test_123",
    "status": "ABANDONED",
    "total": 199,
    "currency": "USD"
  },
  "customer": {
    "email": "test@example.com"
  }
}
```

### `cart.failed`

```json
{
  "event": {
    "source": "CHECKOUT_CART",
    "status": "FAILED",
    "reason": "PAYMENT_FAILED"
  },
  "cart": {
    "cartId": "crt_test_123",
    "status": "FAILED",
    "total": 199
  },
  "payment": {
    "id": "pay_test_1",
    "status": "FAILED"
  }
}
```

### `payment.succeeded`

```json
{
  "payment": {
    "id": "pay_test_1",
    "status": "SUCCEEDED",
    "amount": 299,
    "gateway": "STRIPE",
    "transactionId": "ch_test_123"
  },
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "status": "PENDING",
    "total": 299
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `payment.failed`

```json
{
  "payment": {
    "id": "pay_test_1",
    "status": "FAILED",
    "amount": 299,
    "gateway": "STRIPE"
  },
  "order": {
    "id": "ord_test_1",
    "orderNumber": "ORD-TEST",
    "recoveryStatus": "RETRY_SCHEDULED",
    "retryCount": 1,
    "maxRetryCount": 3,
    "nextRetryAt": "2026-05-23T12:00:00.000Z",
    "recoveryUrl": "/patient/invoices?recovery=1"
  },
  "paymentRecovery": {
    "status": "RETRY_SCHEDULED",
    "retryCount": 1,
    "maxRetryCount": 3,
    "recoveryUrl": "/patient/invoices?recovery=1",
    "autoChargeStatus": "FAILED",
    "autoChargeMessage": "Gateway declined the renewal charge"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `intake.pending`

```json
{
  "event": {
    "source": "INTAKE_ASSIGNED",
    "patientId": "pat_test_1",
    "orderId": "ord_test_1",
    "formId": "form_weight_history",
    "assignedAt": "2026-05-22T12:00:00.000Z"
  },
  "intake": {
    "responseId": "fr_test_1",
    "status": "PENDING",
    "isPending": true,
    "isSubmitted": false,
    "formId": "form_weight_history",
    "formName": "Weight History",
    "formSlug": "weight-history",
    "assignment": {
      "status": "PENDING",
      "source": "STAFF_ASSIGNED",
      "orderId": "ord_test_1",
      "subscriptionId": "sub_test_1"
    },
    "reachedFinalStep": false
  },
  "form": {
    "id": "form_weight_history",
    "name": "Weight History"
  },
  "order": {
    "id": "ord_test_1",
    "pendingFormIds": ["form_weight_history"]
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `intake.completed`

```json
{
  "event": {
    "source": "PATIENT_INTAKE_SUBMIT",
    "orderId": "ord_test_1",
    "formId": "form_weight_history"
  },
  "intake": {
    "responseId": "fr_test_1",
    "status": "SUBMITTED",
    "isPending": false,
    "isSubmitted": true,
    "submittedAt": "2026-05-22T12:00:00.000Z",
    "formId": "form_weight_history",
    "formName": "Weight History",
    "answers": {
      "qualifies": true,
      "bmi": 32
    },
    "review": {
      "status": "PENDING_REVIEW"
    },
    "reachedFinalStep": true
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `intake.resubmitted`

```json
{
  "event": {
    "source": "PATIENT_INTAKE_RESUBMIT",
    "orderId": "ord_test_1",
    "formId": "form_weight_history",
    "previousReviewStatus": "NEEDS_CORRECTION"
  },
  "intake": {
    "responseId": "fr_test_1",
    "formId": "form_weight_history",
    "isResubmission": true,
    "review": {
      "status": "RESUBMITTED",
      "resubmittedAt": "2026-05-22T12:00:00.000Z"
    }
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `intake.reviewed`

```json
{
  "event": {
    "source": "EMR_INTAKE_REVIEW",
    "orderId": "ord_test_1",
    "formId": "form_weight_history",
    "reviewStatus": "APPROVED"
  },
  "intake": {
    "responseId": "fr_test_1",
    "formId": "form_weight_history",
    "review": {
      "status": "APPROVED",
      "reviewedAt": "2026-05-22T12:00:00.000Z",
      "reviewedBy": {
        "name": "Clinician Test",
        "role": "CLINICIAN"
      }
    }
  }
}
```

### `intake.approved`

```json
{
  "event": {
    "source": "EMR_INTAKE_REVIEW",
    "reviewStatus": "APPROVED"
  },
  "intake": {
    "responseId": "fr_test_1",
    "formName": "Weight History",
    "review": {
      "status": "APPROVED"
    }
  },
  "patient": {
    "email": "test@example.com"
  }
}
```

### `intake.needs_correction`

```json
{
  "event": {
    "source": "EMR_INTAKE_REVIEW",
    "reviewStatus": "NEEDS_CORRECTION",
    "reason": "Please correct answer 3"
  },
  "intake": {
    "responseId": "fr_test_1",
    "formName": "Weight History",
    "review": {
      "status": "NEEDS_CORRECTION",
      "note": "Please correct answer 3"
    }
  },
  "patient": {
    "email": "test@example.com"
  }
}
```

### `intake.rejected`

```json
{
  "event": {
    "source": "EMR_INTAKE_REVIEW",
    "reviewStatus": "REJECTED",
    "reason": "Patient is not eligible"
  },
  "intake": {
    "responseId": "fr_test_1",
    "formName": "Weight History",
    "answers": {
      "qualifies": false,
      "bmi": 17
    },
    "review": {
      "status": "REJECTED",
      "note": "Patient is not eligible"
    }
  },
  "order": {
    "id": "ord_test_1",
    "status": "REJECTED"
  },
  "patient": {
    "email": "test@example.com"
  }
}
```

### `appointment.created`

```json
{
  "appointment": {
    "id": "appt_test_1",
    "title": "Initial Consultation",
    "status": "SCHEDULED"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `appointment.completed`

```json
{
  "appointment": {
    "id": "appt_test_1",
    "title": "Initial Consultation",
    "status": "COMPLETED"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  }
}
```

### `prescription.created`

```json
{
  "prescription": {
    "id": "rx_test_1",
    "medication": "Semaglutide 0.25mg",
    "dosage": "0.25mg",
    "frequency": "Weekly",
    "duration": "12 weeks",
    "refills": 0,
    "sentAt": null
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  },
  "order": {
    "id": "ord_test_1"
  }
}
```

### `prescription.updated`

```json
{
  "prescription": {
    "id": "rx_test_1",
    "medication": "Semaglutide",
    "dosage": "0.5mg",
    "instructions": "Updated instructions"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  },
  "order": {
    "id": "ord_test_1"
  }
}
```

### `prescription.sent`

```json
{
  "prescription": {
    "id": "rx_test_1",
    "medication": "Semaglutide 0.25mg",
    "dosage": "0.25mg",
    "sentAt": "2026-05-22T12:00:00.000Z"
  },
  "patient": {
    "id": "pat_test_1",
    "email": "test@example.com"
  },
  "order": {
    "id": "ord_test_1"
  }
}
```

### `manual`

```json
{
  "event": {
    "source": "MANUAL_TEST"
  },
  "patient": {
    "email": "test@example.com"
  },
  "custom": {
    "note": "Manual test payload"
  }
}
```

## Field Reference by Workflow Area

### Lead

```
lead.id
lead.firstName
lead.lastName
lead.email
lead.phone
lead.status
lead.source
previousStatus
newStatus
```

### Patient and Contact

```
patient.id
patient.mrn
patient.firstName
patient.lastName
patient.email
patient.phone
patient.gender
patient.dateOfBirth
patient.address
patient.city
patient.state
patient.zipCode
patient.country
```

### Order

```
order.id
order.orderNumber
order.status
order.total
order.source
order.sourceContext
order.subscriptionId
order.subscriptionIds
order.primarySubscriptionId
order.intakeRequired
order.intakeSubmitted
order.intakeComplete
order.requiredFormIds
order.submittedFormIds
order.pendingFormIds
order.recoveryStatus
order.retryCount
order.maxRetryCount
order.nextRetryAt
order.recoveryUrl
```

### Cart and Checkout

```
cart.id
cart.cartId
cart.status
cart.converted
cart.isConverted
cart.orderId
cart.orderIds
cart.total
cart.currency
cart.completedAt
cart.checkoutCompletedAt
customer.email
customer.phone
event.cartId
event.idleMinutes
```

### Subscription

```
subscription.id
subscription.status
subscription.amount
subscription.interval
subscription.intervalCount
subscription.nextBillingDate
subscription.product.id
subscription.product.name
subscription.currentPhase.name
subscription.currentPhase.belugaVisitType
phaseInfo.currentPhaseIndex
phaseInfo.cycleInPhase
phaseInfo.totalPhases
event.daysUntilRenewal
```

### Payment and Recovery

```
payment.id
payment.status
payment.amount
payment.gateway
payment.transactionId
paymentRecovery.status
paymentRecovery.retryCount
paymentRecovery.maxRetryCount
paymentRecovery.nextRetryAt
paymentRecovery.recoveryUrl
paymentRecovery.autoChargeStatus
paymentRecovery.autoChargeMessage
```

### Intake

```
intake.responseId
intake.status
intake.isPending
intake.isSubmitted
intake.submittedAt
intake.assignedAt
intake.formId
intake.formName
intake.formSlug
intake.answers
intake.context
intake.assignment.status
intake.assignment.source
intake.assignment.orderId
intake.assignment.subscriptionId
intake.review.status
intake.review.note
intake.review.reviewedAt
intake.review.reviewedBy
intake.isResubmission
intake.reachedFinalStep
form.id
form.name
form.slug
formResponse.id
formResponse.formId
```

### Beluga

```
beluga.event
beluga.masterId
beluga.orderId
beluga.visitOutcome
beluga.docName
beluga.docNpi
beluga.scheduledDate
beluga.location
beluga.bookingLink
beluga.carrier
beluga.tracking
```

### Appointment

```
appointment.id
appointment.title
appointment.status
```

### Prescription

```
prescription.id
prescription.medication
prescription.dosage
prescription.frequency
prescription.duration
prescription.refills
prescription.instructions
prescription.sentAt
```

## Notes and Gotchas

* Use plain field paths in condition fields, not merge tags. Correct: `order.status`. Incorrect: `{{order.status}}`.
* Use merge tags only in content fields such as email body, SMS body, webhook body, or subject.
* `checkout.started` can fire before full patient, billing, or shipping data exists.
* `cart.viewed` may fire often. Add conditions or wait steps if you do not want repeated actions.
* `intake.pending` is the best trigger for pending-intake reminders because it represents one specific form assignment/requirement.
* `order.created` and `order.updated` include intake summary fields, but they are broader order events.
* For `intake.pending` after a wait, refresh the latest payload before checking `intake.status`.
* Failed payment recovery workflows should prefer `paymentRecovery.recoveryUrl` when available.
* `manual` is for test-only workflows and does not fire from app events.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.healthyliving.clinic/workflow-triggers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
