{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d8baed5b-bcd2-496b-9491-e24c5ec32d46",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        176
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1f038d5e-fe34-4c63-9408-af97807e8549",
      "name": "Validate the sender",
      "type": "n8n-nodes-base.if",
      "position": [
        -784,
        176
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fb744796-a127-4f5c-a2de-4a27d0b4d562",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.from.id }}",
              "rightValue": "[You chat ID]"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ef4bde48-b288-4de9-ae40-1f46f52ca01a",
      "name": "Check if it's Text",
      "type": "n8n-nodes-base.if",
      "position": [
        -576,
        176
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ce3039fc-2d6a-4a4e-bb8a-b74926b62f87",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0ef22117-c3b3-4f99-9874-ebb8df747e57",
      "name": "Get prayer times",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        96,
        176
      ],
      "parameters": {
        "url": "https://islamicapi.com/api/v1/prayer-time",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "lat",
              "value": "30.06263"
            },
            {
              "name": "lon",
              "value": "31.24967"
            },
            {
              "name": "method",
              "value": "5"
            },
            {
              "name": "school",
              "value": "1"
            },
            {
              "name": "api_key",
              "value": "<YOUR_ISLAMICAPI_KEY>"
            }
          ]
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "cf98117b-f28c-4b7d-84da-ae8d8f4039fc",
      "name": "Map Prayer data",
      "type": "n8n-nodes-base.set",
      "position": [
        320,
        176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3e5676cf-76e2-4f24-98b6-cc00ed7521c6",
              "name": "Prayers",
              "type": "string",
              "value": "=Fajr: {{ $json.data.times.Fajr }}\nSunrise: {{ $json.data.times.Sunrise }}\nDuhr: {{ $json.data.times.Dhuhr }}\nAsr: {{ $json.data.times.Asr }}\nSunset: {{ $json.data.times.Sunset }}\nMaghrib: {{ $json.data.times.Maghrib }}\nIsha: {{ $json.data.times.Isha }}"
            },
            {
              "id": "22cd1ec6-b4a7-4a4e-b085-bc6debfbe4fa",
              "name": "Readable Gregorian Date",
              "type": "string",
              "value": "={{ $json.data.date.readable }}"
            },
            {
              "id": "037074cf-5aac-41aa-80e5-5d3cb112a1b2",
              "name": "Hijri Date",
              "type": "string",
              "value": "={{ $json.data.date.hijri.date }} - {{ $json.data.date.hijri.weekday.en }} - {{ $json.data.date.hijri.month.en }} - {{ $json.data.date.hijri.designation.abbreviated }} Format"
            },
            {
              "id": "0f6980ee-4444-4120-ae98-2301809165c1",
              "name": "Time Zone",
              "type": "string",
              "value": "={{ $json.data.timezone.name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "db254998-3952-40df-9e2a-3433d941cd09",
      "name": "Check for triggers",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "49c12799-4f67-44d2-a09f-66b2d0607f3f",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": "/salah"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "42599ba8-3d4c-48b5-8ddc-52cae0974552",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        176
      ],
      "parameters": {
        "jsCode": "const prayers = [\n  { name: 'Fajr',    time: $('Get prayer times').first().json.data.times.Fajr,    offset: 50 },\n  { name: 'Dhuhr',   time: $('Get prayer times').first().json.data.times.Dhuhr,   offset: 40 },\n  { name: 'Asr',     time: $('Get prayer times').first().json.data.times.Asr,     offset: 40 },\n  { name: 'Maghrib', time: $('Get prayer times').first().json.data.times.Maghrib, offset: 25 },\n  { name: 'Isha',    time: $('Get prayer times').first().json.data.times.Isha,    offset: 40 },\n];\n\nconst dateString = $input.first().json['Readable Gregorian Date'];\nconst tz = 'Africa/Cairo';\n\nconst baseDate = DateTime.fromFormat(dateString, 'd MMM yyyy', { zone: tz });\n\nfunction buildISO(dt) {\n  return dt.set({ second: 0, millisecond: 0 }).toISO();\n}\n\nfunction calcStart(dt) {\n  const flooredMinute = Math.floor(dt.minute / 10) * 10;\n  return buildISO(dt.set({ minute: flooredMinute }));\n}\n\nfunction calcEnd(dt, offset) {\n  const shifted = dt.plus({ minutes: offset });\n  const roundedMinute = Math.ceil(shifted.minute / 10) * 10;\n  if (roundedMinute === 60) {\n    return buildISO(shifted.plus({ hours: 1 }).set({ minute: 0 }));\n  }\n  return buildISO(shifted.set({ minute: roundedMinute }));\n}\n\nconst result = {};\n\nfor (const prayer of prayers) {\n  const [h, m] = prayer.time.split(':').map(Number);\n  const prayerDT = baseDate.set({ hour: h, minute: m, second: 0, millisecond: 0 });\n\n  result[prayer.name] = {\n    startTime: calcStart(prayerDT),\n    endTime:   calcEnd(prayerDT, prayer.offset),\n  };\n}\n\nreturn [{ json: result }];"
      },
      "typeVersion": 2
    },
    {
      "id": "9e692c3e-1395-4c82-93b3-1232261dc528",
      "name": "Book for Fajr",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -1008,
        400
      ],
      "parameters": {
        "end": "={{ $json.Fajr.endTime }}",
        "start": "={{ $json.Fajr.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "color": "2",
          "summary": "Fajr",
          "showMeAs": "opaque",
          "description": "The fajr prayer time no meeting at this time"
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9f37759b-f121-4256-aa0c-9fab55ef5d13",
      "name": "Book for Duhr",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -800,
        400
      ],
      "parameters": {
        "end": "={{ $('Code in JavaScript').item.json.Dhuhr.endTime }}",
        "start": "={{ $('Code in JavaScript').item.json.Dhuhr.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "color": "2",
          "summary": "Duhr",
          "showMeAs": "opaque",
          "description": "The fajr prayer time no meeting at this time"
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "dc2ebbd7-8263-4586-9a06-628e132dae5f",
      "name": "Book for Asr",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -576,
        400
      ],
      "parameters": {
        "end": "={{ $('Code in JavaScript').item.json.Asr.endTime }}",
        "start": "={{ $('Code in JavaScript').item.json.Asr.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "color": "2",
          "summary": "Asr",
          "showMeAs": "opaque",
          "description": "The fajr prayer time no meeting at this time"
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "683b9cf9-31a7-440d-ac3f-9031502fee0d",
      "name": "Book for Maghrib",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -352,
        400
      ],
      "parameters": {
        "end": "={{ $('Code in JavaScript').item.json.Maghrib.endTime }}",
        "start": "={{ $('Code in JavaScript').item.json.Maghrib.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "color": "2",
          "summary": "Maghrib",
          "showMeAs": "opaque",
          "description": "The fajr prayer time no meeting at this time"
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "84b95eeb-ce77-49a8-a84f-ce4a527933d4",
      "name": "Book for Isha",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -128,
        400
      ],
      "parameters": {
        "end": "={{ $('Code in JavaScript').item.json.Isha.endTime }}",
        "start": "={{ $('Code in JavaScript').item.json.Isha.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "color": "2",
          "summary": "Isha",
          "showMeAs": "opaque",
          "description": "The fajr prayer time no meeting at this time"
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "4766f787-21d7-42f1-ad68-f7187acd5f38",
      "name": "Map outputs",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "01ee7b91-8f26-4141-bc8a-d66a760fff4d",
              "name": "Message",
              "type": "string",
              "value": "=<b>As-salamu alaykum! \ud83d\udc4b</b>\n\nYour prayer schedule is confirmed for today <b>{{ $now.toFormat('EEEE') }}</b>. Here are the full time windows for today:\n\n\u2728 <b>Fajr:</b> {{ $('Code in JavaScript').first().json.Fajr.startTime.toDateTime().toFormat('h:mm a') }} - {{ $('Code in JavaScript').first().json.Fajr.endTime.toDateTime().toFormat('h:mm a') }}\n\u2600\ufe0f <b>Dhuhr:</b> {{ $('Code in JavaScript').first().json.Dhuhr.startTime.toDateTime().toFormat('h:mm a') }} - {{ $('Code in JavaScript').first().json.Dhuhr.endTime.toDateTime().toFormat('h:mm a') }}\n\ud83c\udf24\ufe0f <b>Asr:</b> {{ $('Code in JavaScript').first().json.Asr.startTime.toDateTime().toFormat('h:mm a') }} - {{ $('Code in JavaScript').first().json.Asr.endTime.toDateTime().toFormat('h:mm a') }}\n\ud83c\udf05 <b>Maghrib:</b> {{ $('Code in JavaScript').first().json.Maghrib.startTime.toDateTime().toFormat('h:mm a') }} - {{ $('Code in JavaScript').first().json.Maghrib.endTime.toDateTime().toFormat('h:mm a') }}\n\ud83c\udf19 <b>Isha:</b> {{ $('Code in JavaScript').first().json.Isha.startTime.toDateTime().toFormat('h:mm a') }} - {{ $('Code in JavaScript').first().json.Isha.endTime.toDateTime().toFormat('h:mm a') }}\n\n<b>Time zone:</b> {{ $('Book for Maghrib').first().json.start.timeZone }}\n\n<i>I'll send you a nudge when each one is about to begin!</i> \ud83e\udd32"
            },
            {
              "id": "c59fd749-5e79-42ac-8167-22de7e0d338d",
              "name": "Fajr start time",
              "type": "string",
              "value": "={{ $('Book for Fajr').first().json.start.dateTime }}"
            },
            {
              "id": "24ce6f8d-5b1e-433e-9521-2d0c2b4b0157",
              "name": "Fajr end time",
              "type": "string",
              "value": "={{ $('Book for Fajr').first().json.end.dateTime }}"
            },
            {
              "id": "663d58e0-0fc5-441c-a634-ebeed2bdf92c",
              "name": "Fajr id",
              "type": "string",
              "value": "={{ $('Book for Fajr').first().json.id }}"
            },
            {
              "id": "8ed7fb3c-7079-4940-af50-012bc485988c",
              "name": "Duhr start time",
              "type": "string",
              "value": "={{ $('Book for Duhr').first().json.start.dateTime }}"
            },
            {
              "id": "4b350fa3-99af-4899-a207-02bc3e11832f",
              "name": "Duhr end time",
              "type": "string",
              "value": "={{ $('Book for Duhr').first().json.end.dateTime }}"
            },
            {
              "id": "4d10d9da-e202-47aa-900a-f2a8296cdee8",
              "name": "Duhr id",
              "type": "string",
              "value": "={{ $('Book for Duhr').first().json.id }}"
            },
            {
              "id": "f9a34d8e-62f3-454a-a7ef-16e24a431a3a",
              "name": "Asr start time",
              "type": "string",
              "value": "={{ $('Book for Asr').first().json.start.dateTime }}"
            },
            {
              "id": "48ab9fed-463c-452f-8945-f00f546e9d30",
              "name": "Asr end time",
              "type": "string",
              "value": "={{ $('Book for Asr').first().json.end.dateTime }}"
            },
            {
              "id": "c2b265d8-6e5a-4f35-a28b-626b9f72d158",
              "name": "Asr id",
              "type": "string",
              "value": "={{ $('Book for Asr').first().json.id }}"
            },
            {
              "id": "d8936ba6-ed38-4c64-9aad-002dab19499a",
              "name": "Maghrib start time",
              "type": "string",
              "value": "={{ $('Book for Maghrib').first().json.start.dateTime }}"
            },
            {
              "id": "3b73f8a2-f6a9-49ba-94e2-633f2da0a81a",
              "name": "Maghrib end time",
              "type": "string",
              "value": "={{ $('Book for Maghrib').first().json.end.dateTime }}"
            },
            {
              "id": "ec00c6b4-47cb-4d18-a8a4-c47ce4bf71ed",
              "name": "Maghrib id",
              "type": "string",
              "value": "={{ $('Book for Maghrib').first().json.id }}"
            },
            {
              "id": "1e073de5-a667-4fdc-9bda-ad690485e853",
              "name": "Isha start time",
              "type": "string",
              "value": "={{ $json.start.dateTime }}"
            },
            {
              "id": "26372940-3a1b-4a08-a0b3-736c7c404b3a",
              "name": "Isha end time",
              "type": "string",
              "value": "={{ $json.end.dateTime }}"
            },
            {
              "id": "b7a0cc43-ddff-46f3-a57a-754cef5df4a8",
              "name": "Isha id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "8a09b785-8882-4dd5-8789-633a51111a6e",
              "name": "Time zone",
              "type": "string",
              "value": "={{ $json.start.timeZone }}"
            },
            {
              "id": "80bc21b2-a718-4ed4-8971-e713bf75449e",
              "name": "Today",
              "type": "string",
              "value": "={{ $now.toFormat('EEEE') }}"
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 3.4
    },
    {
      "id": "71b5762a-d815-4820-a825-e60a64619b37",
      "name": "Store Prayer Bookings",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        320,
        400
      ],
      "parameters": {
        "columns": {
          "value": {
            "Day": "={{ $now.toFormat('EEEE') }}",
            "Date": "={{ $now.format('dd LLL yy') }}",
            "Hijri": "=\u064a\u0648\u0645 {{ $('Get prayer times').item.json.data.date.hijri.weekday.ar }} \u0645\u0646 {{ $('Get prayer times').item.json.data.date.hijri.month.ar }} \u0639\u0627\u0645 {{ $('Get prayer times').item.json.data.date.hijri.year }} - {{ $('Get prayer times').item.json.data.date.hijri.date }}",
            "Asr id": "={{ $json['Asr id'] }}",
            "Duhr ID": "={{ $json['Duhr id'] }}",
            "Fajr id": "={{ $json['Fajr id'] }}",
            "Isha id": "={{ $json['Isha id'] }}",
            "Time Zone": "={{ $json['Time zone'] }}",
            "maghrib id": "={{ $json['Maghrib id'] }}",
            "Asr end time": "={{ $json['Asr end time'] }}",
            "Duhr end time": "={{ $json['Duhr end time'] }}",
            "Fajr end time": "={{ $json['Fajr end time'] }}",
            "Isha end time": "={{ $json['Isha end time'] }}",
            "Asr strat time": "={{ $json['Asr start time'] }}",
            "Duhr start time": "={{ $json['Duhr start time'] }}",
            "Fajr start time": "={{ $json['Fajr start time'] }}",
            "Isha start time": "={{ $json['Isha start time'] }}",
            "Maghrib end time": "={{ $json['Maghrib end time'] }}",
            "Maghrib start time": "={{ $json['Maghrib start time'] }}"
          },
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Hijri",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Hijri",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Day",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Day",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Fajr start time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Fajr start time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Fajr end time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Fajr end time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Fajr id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Fajr id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Duhr start time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Duhr start time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Duhr end time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Duhr end time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Duhr ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Duhr ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Asr strat time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Asr strat time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Asr end time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Asr end time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Asr id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Asr id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Maghrib start time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Maghrib start time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Maghrib end time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Maghrib end time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "maghrib id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "maghrib id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Isha start time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Isha start time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Isha end time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Isha end time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Isha id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Isha id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Time Zone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14sfzXXN1WjAc96RYFjoeoD7xcCNh7HbYC-BjcTp0u0o/edit#gid=0",
          "cachedResultName": "Books"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "14sfzXXN1WjAc96RYFjoeoD7xcCNh7HbYC-BjcTp0u0o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14sfzXXN1WjAc96RYFjoeoD7xcCNh7HbYC-BjcTp0u0o/edit?usp=drivesdk",
          "cachedResultName": "Prayer Bookings"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "47591143-a01c-4827-96d1-6c8611eaf385",
      "name": "Send the message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        560,
        400
      ],
      "parameters": {
        "text": "={{ $('Map outputs').item.json.Message }}",
        "chatId": "[You chat ID]",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "996eee83-c761-43f1-901d-712110ecbd79",
      "name": "Send an action",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -112,
        176
      ],
      "parameters": {
        "chatId": "[You chat ID]",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "509f22b8-2ea0-4048-a550-ff12ddfd17d3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        96
      ],
      "parameters": {
        "width": 224,
        "content": "## Receive message"
      },
      "typeVersion": 1
    },
    {
      "id": "f2bb3bf6-9742-4b78-8ebc-09a83b774382",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        96
      ],
      "parameters": {
        "content": "## Validate Sender"
      },
      "typeVersion": 1
    },
    {
      "id": "62b97a91-70c9-41b9-b7f7-384065550426",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        96
      ],
      "parameters": {
        "content": "## Check if it's text input"
      },
      "typeVersion": 1
    },
    {
      "id": "5f12ff2e-11d5-457e-8194-9271b75015eb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        96
      ],
      "parameters": {
        "content": "## Look for triggers\n**Use /salah as the trigger**"
      },
      "typeVersion": 1
    },
    {
      "id": "64c4a11e-98dc-4dc0-a9c5-178a39235963",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        96
      ],
      "parameters": {
        "content": "## Send typing action"
      },
      "typeVersion": 1
    },
    {
      "id": "f60a19b5-320e-4e1a-83ac-be1b06b56640",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        96
      ],
      "parameters": {
        "content": "## Get prayer times"
      },
      "typeVersion": 1
    },
    {
      "id": "3a80667f-0eff-4183-b394-930ac7c738da",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        96
      ],
      "parameters": {
        "content": "## Map content"
      },
      "typeVersion": 1
    },
    {
      "id": "892b82e9-c8b1-4cc6-9dee-40f74a0039c4",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        96
      ],
      "parameters": {
        "content": "## Output the times that should be booked"
      },
      "typeVersion": 1
    },
    {
      "id": "67926025-51d5-45f1-bea1-04c322d77561",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        352
      ],
      "parameters": {
        "color": 4,
        "width": 1088,
        "height": 192,
        "content": "## Book it"
      },
      "typeVersion": 1
    },
    {
      "id": "a0348800-73c2-4b95-a40e-cc17a624746c",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        352
      ],
      "parameters": {
        "content": "## Prepare outputs"
      },
      "typeVersion": 1
    },
    {
      "id": "db6dfe25-e495-4533-b05c-d69a7aa556d6",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        352
      ],
      "parameters": {
        "color": 6,
        "content": "## Store data"
      },
      "typeVersion": 1
    },
    {
      "id": "d3b1207f-f676-4d12-b800-9fcaf7681f74",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        352
      ],
      "parameters": {
        "color": 7,
        "content": "## Send the message"
      },
      "typeVersion": 1
    },
    {
      "id": "46186a38-ba7a-432a-b983-b31c41bf436c",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        560
      ],
      "parameters": {
        "color": 3,
        "width": 736,
        "height": 288,
        "content": "# On Error"
      },
      "typeVersion": 1
    },
    {
      "id": "8b10f163-6cc4-4e16-b477-3206b8c0e851",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        -976,
        656
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "49e8eac8-7e25-4a31-8787-2143b679047c",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -752,
        656
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $now.format('yyyy-MM-dd') }}",
            "Workflow ld": "={{ $json.workflow.id }}",
            "Execution id": "={{ $json.execution.id }}",
            "Workflow Link": "={{ $json.execution.url }}",
            "Workflow name": "={{ $json.workflow.name }}",
            "error message": "={{ $json.execution.error.message }}",
            "Execution link": "={{ $json.execution.url }}"
          },
          "schema": [
            {
              "id": "Workflow name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Workflow name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Workflow Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Workflow Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "error message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "error message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Execution link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Execution link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Workflow ld",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Workflow ld",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Execution id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Execution id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-OSU4d7hkM0vRjITBmoR5esOscgWcFC5bV6YEnuX-zU/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1-OSU4d7hkM0vRjITBmoR5esOscgWcFC5bV6YEnuX-zU",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-OSU4d7hkM0vRjITBmoR5esOscgWcFC5bV6YEnuX-zU/edit?usp=drivesdk",
          "cachedResultName": "Errors on workflow"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "646873c3-4bbc-458b-a266-cc334be9d20f",
      "name": "Send The error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -528,
        656
      ],
      "parameters": {
        "text": "=I got an error **{{ $json['error message'] }}** please fix it: {{ $json['Execution link'] }}",
        "chatId": "[You chat ID]",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ea7e265f-f5da-4ef8-8efd-d220b4a7579a",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        96
      ],
      "parameters": {
        "width": 480,
        "height": 928,
        "content": "## Prayer Calendar Blocker\n## [Created by Gurey AI](https://gurey-ai.vercel.app/contact)\n\n## How it Works\n### - Send /salah to the bot \u2192 Telegram Trigger fires\n### - Sender and message type are validated \u2014 only the owner can run this\n### - IslamicAPI fetches today's prayer times for Cairo by coordinates\n### - JavaScript calculates a realistic time window for each of the 5 prayers\n### - Five Google Calendar events are created sequentially, one per prayer\n### - Booking details and event IDs are logged to Google Sheets\n### - A formatted Telegram message confirms all five windows back to you\n### - If anything fails, the error is logged to a second sheet and sent to you via Telegram\n\n## APIs Needed\n### - [IslamicAPI](https://islamicapi.com/signup/) \u2014 free account, get API key from dashboard\n### - [Google Calendar OAuth2 \u2014 n8n Docs](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/)\n### - [Google Sheets OAuth2 \u2014 n8n Docs](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/)\n### - [Telegram Bot Token \u2014 n8n Docs](https://docs.n8n.io/integrations/builtin/credentials/telegram/)\n\n## Resources\n### - [IslamicAPI Prayer Time Docs](https://islamicapi.com/doc/prayer-time/)\n### - [n8n Google Calendar Node Docs](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlecalendar/)\n### - [n8n Telegram Node Docs](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/)\n### - [n8n Google Sheets Node Docs](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/)\n\n## Costs per Run\n### - IslamicAPI: free\n### - Google Calendar API: free\n### - Google Sheets API: free\n### - Telegram Bot API: free\n### - Total per run: $0.00\n\n---\n\n## About the Creator\n\n**Abdullahi Osman** \u2014 AI Automation Engineer\n\ni'm an AI automation engineer, and i specialize in building AI automations.\ni've been building AI automations for a year now.\nfor any details visit our website.\n\n* \ud83c\udf10 [Gurey AI](https://gurey-ai.vercel.app/)\n* \ud83d\udce7 [gureyai2006@gmail.com](mailto:gureyai2006@gmail.com)\n\n*for questions, feedback, or custom workflow requests \u2014 reach out.*"
      },
      "typeVersion": 1
    },
    {
      "id": "20523268-012a-481d-93a0-8fff78bdc58f",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        1056
      ],
      "parameters": {
        "width": 480,
        "height": 176,
        "content": "\u26a0\ufe0f replace [Your chat ID] in two nodes before activating\n\nthe `Validate the Sender` node and the send message nodes use [Your chat ID] as a placeholder. if you activate without replacing it, the workflow will either block all messages or send confirmations to nobody. get your Chat ID from @userinfobot on Telegram, then update all three nodes before you turn this on."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Map outputs": {
      "main": [
        [
          {
            "node": "Store Prayer Bookings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Book for Asr": {
      "main": [
        [
          {
            "node": "Book for Maghrib",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Book for Duhr": {
      "main": [
        [
          {
            "node": "Book for Asr",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Book for Fajr": {
      "main": [
        [
          {
            "node": "Book for Duhr",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Book for Isha": {
      "main": [
        [
          {
            "node": "Map outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send an action": {
      "main": [
        [
          {
            "node": "Get prayer times",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Prayer data": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Book for Maghrib": {
      "main": [
        [
          {
            "node": "Book for Isha",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get prayer times": {
      "main": [
        [
          {
            "node": "Map Prayer data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Validate the sender",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for triggers": {
      "main": [
        [
          {
            "node": "Send an action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if it's Text": {
      "main": [
        [
          {
            "node": "Check for triggers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Book for Fajr",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Send The error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate the sender": {
      "main": [
        [
          {
            "node": "Check if it's Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Prayer Bookings": {
      "main": [
        [
          {
            "node": "Send the message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}