{
  "name": "Dental Review Request (48h Post-Appointment)",
  "nodes": [
    {
      "parameters": { "rule": "schedule", "rule": { "interval": [{ "field": "HOUR", "hours": 9 }] } },
      "id": "daily-trigger",
      "name": "Daily 9am Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [250, 300]
    },
    {
      "parameters": {
        "url": "https://autostack-17.polsia.app/api/dental/appointments?pending_review=true&limit=20",
        "method": "GET"
      },
      "id": "fetch-appointments",
      "name": "Fetch Appointments Due for Review",
      "type": "n8n-nodes-base.httpRequest",
      "position": [500, 300]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            { "leftValue": "={{ $json.review_request_status }}", "rightValue": "pending", "operator": { "type": "string", "operation": "equals" } }
          ]
        }
      },
      "id": "filter-pending",
      "name": "Filter Pending Reviews",
      "type": "n8n-nodes-base.if",
      "position": [750, 300]
    },
    {
      "parameters": {
        "url": "https://autostack-17.polsia.app/api/dental/send-review",
        "method": "POST",
        "bodyParameters": {
          "parameters": [
            { "name": "appointment_id", "value": "={{ $json.id }}" }
          ]
        }
      },
      "id": "send-review-email",
      "name": "Send Review Request Email",
      "type": "n8n-nodes-base.httpRequest",
      "position": [1000, 200]
    },
    {
      "parameters": { "functionCode": "return [{ json: { message: 'No pending review requests this run.' } }];" },
      "id": "no-op",
      "name": "No Pending — Skip",
      "type": "n8n-nodes-base.function",
      "position": [1000, 400]
    }
  ],
  "connections": {
    "Daily 9am Trigger": { "main": [[{ "node": "Fetch Appointments Due for Review", "type": "main" }]] },
    "Fetch Appointments Due for Review": { "main": [[{ "node": "Filter Pending Reviews", "type": "main" }]] },
    "Filter Pending Reviews": {
      "main": [
        [{ "node": "Send Review Request Email", "type": "main" }],
        [{ "node": "No Pending — Skip", "type": "main" }]
      ]
    }
  },
  "settings": {},
  "description": "Imports into n8n: runs daily at 9am, finds appointments 48h+ past, sends review request emails. AutoStack runs this on Render during demo."
}