{
 "name": "تذكير المواعيد — اسأل أبو خليفة",
 "nodes": [
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "triggerAtHour": 20
      }
     ]
    }
   },
   "id": "cca2d339-0a49-40f9-a27f-90d1098563e3",
   "name": "كل يوم 8 المساء",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    -440,
    0
   ]
  },
  {
   "parameters": {
    "operation": "getAll",
    "calendar": {
     "__rl": true,
     "mode": "list",
     "value": "primary"
    },
    "returnAll": true,
    "timeMin": "={{ $now.setZone('Asia/Riyadh').plus({ days: 1 }).startOf('day').toISO() }}",
    "timeMax": "={{ $now.setZone('Asia/Riyadh').plus({ days: 1 }).endOf('day').toISO() }}",
    "options": {
     "singleEvents": true
    }
   },
   "id": "59089d40-bb4a-4992-8bfe-6db5c389c78a",
   "name": "مواعيد بكرة",
   "type": "n8n-nodes-base.googleCalendar",
   "typeVersion": 1.3,
   "position": [
    -220,
    0
   ],
   "credentials": {
    "googleCalendarOAuth2Api": {
     "id": "",
     "name": "Google Calendar"
    }
   }
  },
  {
   "parameters": {
    "jsCode": "// مواعيد بكرة اللي فيها رقم واتساب في الوصف → رسالة تذكير لكل زبون\nconst out = [];\nfor (const i of $input.all()) {\n  const e = i.json; if (!e.start) continue;\n  const m = (e.description || '').match(/واتساب:\\s*(\\d{8,15})/); if (!m) continue;\n  const t = DateTime.fromISO(e.start.dateTime || e.start, { zone: 'Asia/Riyadh' });\n  out.push({ json: { to: m[1], name: (e.summary || '').replace('موعد: ', ''), time: t.setLocale('ar').toFormat('cccc h:mm a') } });\n}\nreturn out;"
   },
   "id": "d2c14242-7778-4cca-ac7a-bcaea4178b70",
   "name": "تجهيز التذكير",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    0,
    0
   ]
  },
  {
   "parameters": {
    "resource": "message",
    "operation": "sendTemplate",
    "phoneNumberId": "حط هنا Phone number ID",
    "recipientPhoneNumber": "={{ $json.to }}",
    "template": "appointment_reminder|ar",
    "components": {
     "component": [
      {
       "type": "body",
       "bodyParameters": {
        "parameter": [
         {
          "type": "text",
          "text": "={{ $json.name }}"
         },
         {
          "type": "text",
          "text": "={{ $json.time }}"
         }
        ]
       }
      }
     ]
    }
   },
   "id": "0b545bf1-c247-47b9-b559-e42a3b07bfc7",
   "name": "أرسل التذكير (قالب واتساب)",
   "type": "n8n-nodes-base.whatsApp",
   "typeVersion": 1.1,
   "position": [
    220,
    0
   ],
   "credentials": {
    "whatsAppApi": {
     "id": "",
     "name": "WhatsApp (Access token + Business Account ID)"
    }
   }
  }
 ],
 "connections": {
  "كل يوم 8 المساء": {
   "main": [
    [
     {
      "node": "مواعيد بكرة",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "مواعيد بكرة": {
   "main": [
    [
     {
      "node": "تجهيز التذكير",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "تجهيز التذكير": {
   "main": [
    [
     {
      "node": "أرسل التذكير (قالب واتساب)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1",
  "timezone": "Asia/Riyadh"
 },
 "pinData": {}
}