{
  "id": "bmuzhJcQ1L5ZD6TH",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automatically Add Daily Prayer & Sunnah Fasting Reminders to Google Calendar (n8n)",
  "tags": [],
  "nodes": [
    {
      "id": "63df3eed-52ff-4705-b393-0037aed6deee",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -624,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 1
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2891ea9a-c612-4ea4-a9c6-bc6fa78d0a01",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2256,
        16
      ],
      "parameters": {
        "end": "={{ $json.end }}",
        "start": "={{ $json.start }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {
          "summary": "={{ $json.title }}"
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "11f57159-2766-4fce-be5e-597538882b2a",
      "name": "reformat prayer",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        -16
      ],
      "parameters": {
        "jsCode": "return [{\n  fajr: $json.data.timings.Fajr,\n  dhuhr: $json.data.timings.Dhuhr,\n  asr: $json.data.timings.Asr,\n  maghrib: $json.data.timings.Maghrib,\n  isha: $json.data.timings.Isha,\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "fe467792-a8cc-4b39-803c-030ff00064b3",
      "name": "merge",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        -16
      ],
      "parameters": {
        "jsCode": "const prayer = $items(\"reformat prayer\")[0].json;\n\nconst events = [];\n\nevents.push({title: \"Shalat Subuh\", time: prayer.fajr});\nevents.push({title: \"Shalat Dzuhur\", time: prayer.dhuhr});\nevents.push({title: \"Shalat Ashar\", time: prayer.asr});\nevents.push({title: \"Shalat Maghrib\", time: prayer.maghrib});\nevents.push({title: \"Shalat Isya\", time: prayer.isha});\n\n// Doa\nevents.push({title: \"Doa Pagi\", time: prayer.fajr});\nevents.push({title: \"Doa Petang\", time: prayer.asr});\n\n// Ayamul Bidh\nif ($json.isAyamulBidh) {\n  events.push({title: \"Puasa Sunnah Ayamul Bidh\", time: \"04:30\"});\n}\n\nconst today = $now.setZone(\"Asia/Jakarta\").toFormat(\"yyyy-MM-dd\");\n\nreturn events.map(e => {\n  const cleanTime = e.time.split(\" \")[0];\n\n  // \ud83d\udd25 tambah durasi 10 menit\n  const endTime = $moment(`${today} ${cleanTime}`)\n    .add(10, 'minutes')\n    .format('HH:mm:ss');\n\n  return {\n    json: {\n      title: `${e.title} - ${today}`,\n      start: `${today}T${cleanTime}:00`,\n      end: `${today}T${endTime}`\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "0d2c7791-9dcf-4e34-8fa4-b9f2a26f503a",
      "name": "Set City and Country",
      "type": "n8n-nodes-base.set",
      "position": [
        -288,
        -16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "25ef6d6e-9072-436f-bf0a-ab93c3f8aafe",
              "name": "city",
              "type": "string",
              "value": "Bandung"
            },
            {
              "id": "b39259d8-b024-4964-b14e-da319ac9499f",
              "name": "country",
              "type": "string",
              "value": "Indonesia"
            },
            {
              "id": "e63e90c6-8438-40b9-ba02-fbb1ba347399",
              "name": "end_day",
              "type": "string",
              "value": "={{$now.setZone(\"Asia/Jakarta\").endOf(\"day\")}}"
            },
            {
              "id": "544bb871-e62a-4154-be8f-3012a5e86581",
              "name": "start_day",
              "type": "string",
              "value": "={{$now.setZone(\"Asia/Jakarta\").startOf(\"day\")}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "79a6c56c-579a-4484-87ad-64e66cfc8c27",
      "name": "Get Today Event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        -80,
        800
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ $json.end_day }}",
        "timeMin": "={{ $json.start_day }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "operation": "getAll"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.3
    },
    {
      "id": "7eb04827-4d40-4f3e-bc2f-3a144b5fad6c",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1616,
        32
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "joinMode": "enrichInput1",
        "mergeByFields": {
          "values": [
            {
              "field1": "title",
              "field2": "summary"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "90090881-b224-4744-834d-5bc0bd64730c",
      "name": "IF Event Do not Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        1904,
        32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8fb4a9c3-fb5d-431f-bf03-12cacb5fa6a0",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.summary }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6200b683-0b08-4280-9713-d747071207e6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 560,
        "content": "## Schedule Trigger & Location Setup\n- This workflow runs daily and allows you to configure your city and country.\n\n- Modify the \"Set City and Country\" node to match your location.\n- Default: Bandung, Indonesia\n- Change this to your own location"
      },
      "typeVersion": 1
    },
    {
      "id": "2b8ba2ff-68fd-4fd5-a1fa-2f6548486992",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Fetch Prayer Times from API\nThis section retrieves daily prayer times based on the configured location."
      },
      "typeVersion": 1
    },
    {
      "id": "a22ddae1-b5d5-47cf-84c3-038ca11d9491",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Reformat Prayer\nCleans and formats prayer time data into a simpler structure for further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "aa5c922d-c838-4627-987c-89046ba00071",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Get Date (Hijri API)\n\nFetches today's Hijri date using Aladhan API."
      },
      "typeVersion": 1
    },
    {
      "id": "3e0a0491-ca44-416d-9bac-88265534d19b",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Hijri Date & Sunnah Logic\n\nChecks if today is 13, 14, or 15 Hijri.\nIf true, adds a sunnah fasting reminder event."
      },
      "typeVersion": 1
    },
    {
      "id": "2dee38f8-1b4f-4199-9f72-65ae343e9970",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Generate Events\n- Creates a list of events with title, start time, and end time.\n- Each item represents one calendar event."
      },
      "typeVersion": 1
    },
    {
      "id": "b782dba2-57ff-4a84-aeb4-fbb656a21f1f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Check Existing Events\n- Matches new events with existing ones using title comparison.\n- Used to detect duplicates"
      },
      "typeVersion": 1
    },
    {
      "id": "ed8d287d-9405-495d-ab34-02b558170283",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## IF Event Do Not Exist\n\n- Checks if the event already exists in the calendar.\n- If not found \u2192 proceed to create event.\n- If found \u2192 skip."
      },
      "typeVersion": 1
    },
    {
      "id": "e34c45e3-18c7-4dc4-a1ef-c566f8a16742",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Create an Event\nCreates events only if they do not already exist.\n\nDont forget to Set up your google calendar account"
      },
      "typeVersion": 1
    },
    {
      "id": "d421a0b2-a385-48a6-b59e-c57b76dd541d",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        512
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 560,
        "content": "## Get Today's Existing Events\n\n- Retrieve all events scheduled for today (00:00\u201323:59).\n- Used to prevent duplicate events from being created.\n\n\nDont forget to Set up your google calendar account"
      },
      "typeVersion": 1
    },
    {
      "id": "70b0c7e4-19e7-4176-bb70-9f617c0cc0be",
      "name": "Fetch Prayer Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        -16
      ],
      "parameters": {
        "url": "=https://api.aladhan.com/v1/timingsByCity?city={{ $json.city }}&country={{ $json.country }}&method=2",
        "options": {}
      },
      "typeVersion": 4.4
    },
    {
      "id": "8a83ce6b-9244-4fee-bc60-b138af6ac1e7",
      "name": "get hijri date",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        656,
        -16
      ],
      "parameters": {
        "url": "https://api.aladhan.com/v1/gToH",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "date",
              "value": "={{$now.toFormat(\"dd-MM-yyyy\")}}"
            }
          ]
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "c287435e-4be9-453a-865b-a76e9ab5b4b4",
      "name": "detect ayamul bidh date",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        -16
      ],
      "parameters": {
        "jsCode": "const day = parseInt($input.first().json.data.hijri.day);\n\nreturn [{\n  json: {\n    isAyamulBidh: [13,14,15].includes(day)\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "4223f56a-188e-4859-a0cd-c4e9462216c4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -192
      ],
      "parameters": {
        "width": 944,
        "height": 1888,
        "content": "\ud83d\udd4c Smart Prayer & Sunnah Reminder (Google Calendar + Hijri + n8n)\n\nThis workflow automatically creates daily Islamic reminders in your Google Calendar:\n\t\u2022\t\ud83d\udd4c Daily prayer times (Subuh, Dzuhur, Ashar, Maghrib, Isya)\n\t\u2022\t\ud83c\udf05 Morning & evening dhikr (Doa Pagi & Petang)\n\t\u2022\t\ud83c\udf19 Sunnah fasting reminder (Ayamul Bidh \u2013 13, 14, 15 Hijri)\n\nPrayer times are dynamically fetched based on your location, and Hijri dates are used to determine sunnah fasting days.\n\n\u2e3b\n\n\ud83d\udd01 Flow\n\nSchedule Trigger\n\u2192 Set City & Country\n\u2192 Get Prayer Times (API)\n\u2192 Format Data\n\u2192 Get Hijri Date\n\u2192 Detect Ayamul Bidh\n\u2192 Generate Events\n\u2192 Get Today\u2019s Events (Google Calendar)\n\u2192 Compare (Anti-Duplicate)\n\u2192 Create Event (if not exists)\n\n\u2e3b\n\n\u2699\ufe0f Setup Guide\n\n1\ufe0f\u20e3 Configure Location\n\nOpen node: Set City and Country\n\nReplace:\ncity: Bandung\ncountry: Indonesia\n\nWith your own location.\n\n\u2e3b\n\n2\ufe0f\u20e3 Google Calendar Credential\n\t1.\tAdd Google Calendar OAuth2 in n8n\n\t2.\tConnect your Google account\n\t3.\tSelect your calendar in the \u201cCreate Event\u201d node\n\n\u2e3b\n\n3\ufe0f\u20e3 Set Schedule\n\nOpen: Schedule Trigger\n\nRecommended:\nRun once daily (e.g., 00:05 AM)\n\n\u2e3b\n\n4\ufe0f\u20e3 Activate Workflow\n\t\u2022\tSave workflow\n\t\u2022\tClick \u201cActivate\u201d\n\t\u2022\tDone \ud83c\udf89\n\n\u2e3b\n\n\u26a0\ufe0f Important Notes\n\n\ud83d\udd01 Anti-Duplicate Protection\n\nThis workflow:\n\t\u2022\tChecks existing events for today\n\t\u2022\tCompares events by title\n\t\u2022\tOnly creates new events if they do not already exist\n\n\u2e3b\n\n\ud83d\udd52 Timezone\n\nMake sure your n8n timezone is set to:\nAsia/Jakarta\n\n\u2e3b\n\n\ud83d\udcc5 Event Format\n\nEvents are created using:\n\t\u2022\tSummary (title)\n\t\u2022\tStart time\n\t\u2022\tEnd time\n\n\u2e3b\n\n\ud83d\udca1 Customization Ideas\n\nYou can extend this workflow by:\n\t\u2022\tSending reminders via Telegram / WhatsApp\n\t\u2022\tUsing latitude & longitude instead of city\n\t\u2022\tSupporting multiple users\n\t\u2022\tAdding notification reminders\n\t\u2022\tIntegrating AI for Islamic content\n\n\u2e3b\n\n\ud83c\udfc6 Use Case\n\nPerfect for:\n\t\u2022\tDaily ibadah reminders\n\t\u2022\tBuilding consistent habits\n\t\u2022\tLearning n8n automation with real use case\n\n\u2e3b\n\n\ud83d\ude80 Tips\n\nIf events are not created:\n\t\u2022\tCheck Google Calendar credentials\n\t\u2022\tEnsure workflow is active\n\t\u2022\tVerify city & country input\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "aeaa06b0-b690-4bc1-9ec4-6584984c2f89",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "IF Event Do not Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "merge": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get hijri date": {
      "main": [
        [
          {
            "node": "detect ayamul bidh date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        []
      ]
    },
    "Get Today Event": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "reformat prayer": {
      "main": [
        [
          {
            "node": "get hijri date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set City and Country",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Prayer Data": {
      "main": [
        [
          {
            "node": "reformat prayer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set City and Country": {
      "main": [
        [
          {
            "node": "Fetch Prayer Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Today Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Event Do not Exist": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "detect ayamul bidh date": {
      "main": [
        [
          {
            "node": "merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}