{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "753aecfd-7a3e-4b43-be0e-a944b66300f1",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 550,
        "content": "## Hora Muhurat Tracker\n\nChecks the day's planetary Hora schedule three times a day and delivers Sun Hora timings directly to Telegram for manifestation and focused action.\n\n### How it works\n1. Workflow triggers at 8 AM, 2 PM, and 5 PM IST\n2. It scrapes daily panchang data from drikpanchang.com\n3. The code extracts all 24 planetary hour blocks\n4. It isolates the Sun (Surya) Hora blocks\n5. It sends a formatted Markdown message to Telegram\n\n### Setup\n- [ ] Create a Telegram bot via @BotFather and add credentials to n8n\n- [ ] Enter your Telegram Chat ID in the `Send Telegram Alert` node\n- [ ] (Optional) Change the `geoname-id` in the HTTP node to match your city\n\n### How to Use\nWhen the Telegram notification arrives, pause during that 60-minute window to visualize goals, affirm intentions, or take inspired action."
      },
      "typeVersion": 1
    },
    {
      "id": "eca27fe7-0590-4680-9d57-9ecd78da6aca",
      "name": "Sec1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        176
      ],
      "parameters": {
        "width": 196,
        "height": 260,
        "content": "## 1. Schedule\nTriggers multiple times a day."
      },
      "typeVersion": 1
    },
    {
      "id": "da973afb-1b8b-44c5-a814-de63a83de456",
      "name": "Sec2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        176
      ],
      "parameters": {
        "width": 416,
        "height": 260,
        "content": "## 2. Fetch & Parse Data\nScrapes HTML and extracts all 24 Horas."
      },
      "typeVersion": 1
    },
    {
      "id": "5a84b214-1025-425a-9c2f-decc87a57b3b",
      "name": "Sec3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        176
      ],
      "parameters": {
        "width": 416,
        "height": 260,
        "content": "## 3. Filter & Send\nIsolates Sun Horas and sends to Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "b6deaa77-91bd-4e8f-a1dd-57f0fef52f46",
      "name": "Daily Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        496,
        272
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            },
            {
              "triggerAtHour": 14
            },
            {
              "triggerAtHour": 17
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9d15ab59-14d1-4afd-9922-cb798ea790bc",
      "name": "Fetch Panchang Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        272
      ],
      "parameters": {
        "url": "https://www.drikpanchang.com/muhurat/hora.html?geoname-id=1279233&date=",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "9d770f36-f6e8-422e-9567-53294ae96d22",
      "name": "Extract Hora Timings",
      "type": "n8n-nodes-base.code",
      "position": [
        912,
        272
      ],
      "parameters": {
        "jsCode": "// Extract the HTML data from input\nconst inputData = $input.all()[0].json.data;\n\n// Define planet information\nconst planetInfo = {\n  'Jupiter': { sanskrit: 'Guru', nature: 'Fruitful' },\n  'Mars': { sanskrit: 'Mangal', nature: 'Aggressive' },\n  'Sun': { sanskrit: 'Surya', nature: 'Vigorous' },\n  'Venus': { sanskrit: 'Shukra', nature: 'Beneficial' },\n  'Mercury': { sanskrit: 'Budh', nature: 'Quick' },\n  'Moon': { sanskrit: 'Chandra', nature: 'Gentle' },\n  'Saturn': { sanskrit: 'Shani', nature: 'Sluggish' }\n};\n\n// Initialize result structure\nconst horaByPlanet = {};\nObject.keys(planetInfo).forEach(planet => {\n  horaByPlanet[planet] = {\n    name: planet,\n    sanskrit: planetInfo[planet].sanskrit,\n    nature: planetInfo[planet].nature,\n    timings: []\n  };\n});\n\n// Extract date from HTML\nconst dateMatch = inputData.match(/January\\s+\\d{1,2},\\s+\\d{4}/);\nconst extractedDate = dateMatch ? dateMatch[0] : 'Not found';\n\n// Pattern to match: Planet - Nature followed by time range\n// Example: \"Jupiter - Fruitful</span></div></div><div class=\\\"dpMuhurtaTime dpFlexEqual\\\"><span class=\\\"dpVerticalMiddleText\\\">07:14 <span class=\\\"dpTimeStamp\\\">AM</span>\"\nconst horaPattern = /(Jupiter|Mars|Sun|Venus|Mercury|Moon|Saturn)\\s*-\\s*(Fruitful|Aggressive|Vigorous|Beneficial|Quick|Gentle|Sluggish)[^>]*>[\\s\\S]*?(\\d{1,2}:\\d{2})\\s*<span[^>]*>(\\w+)<\\/span>[^>]*>[^<]*<[^>]*>[^<]*<[^>]*>(\\d{1,2}:\\d{2})\\s*<span[^>]*>(\\w+)<\\/span>/gi;\n\nlet match;\nlet horaNumber = 1;\n\nwhile ((match = horaPattern.exec(inputData)) !== null) {\n  const planet = match[1];\n  const nature = match[2];\n  const startHour = match[3];\n  const startPeriod = match[4];\n  const endHour = match[5];\n  const endPeriod = match[6];\n  \n  const startTime = `${startHour} ${startPeriod}`;\n  const endTime = `${endHour} ${endPeriod}`;\n  \n  // Determine if day or night hora\n  const period = horaNumber <= 12 ? 'Day' : 'Night';\n  \n  horaByPlanet[planet].timings.push({\n    horaNumber: horaNumber,\n    period: period,\n    startTime: startTime,\n    endTime: endTime,\n    planetNature: nature\n  });\n  \n  horaNumber++;\n}\n\n// Generate summary\nconst summary = {};\nObject.keys(horaByPlanet).forEach(planet => {\n  const timings = horaByPlanet[planet].timings;\n  summary[planet] = {\n    totalOccurrences: timings.length,\n    dayHoras: timings.filter(t => t.period === 'Day').length,\n    nightHoras: timings.filter(t => t.period === 'Night').length\n  };\n});\n\n// Return formatted result\nreturn [{\n  json: {\n    date: extractedDate,\n    location: 'New Delhi, NCT, India',\n    totalHoras: horaNumber - 1,\n    planets: horaByPlanet,\n    summary: summary\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "98774c4a-0450-47ee-848b-11d66441d818",
      "name": "Filter Sun Horas",
      "type": "n8n-nodes-base.set",
      "position": [
        1120,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f7910617-cb22-4e78-ba4c-12f729979ce0",
              "name": "planets.Sun",
              "type": "object",
              "value": "={{ $json.planets.Sun }}"
            },
            {
              "id": "b5dff28b-73a8-43d5-ad24-340db8fb3ff0",
              "name": "date",
              "type": "string",
              "value": "={{ $json.date }}"
            },
            {
              "id": "b5798a7f-1f7e-4813-898c-4758854a2432",
              "name": "city_name",
              "type": "string",
              "value": "Ahmedabad"
            },
            {
              "id": "aa5a168f-5be2-452f-8174-30992840e180",
              "name": "date",
              "type": "string",
              "value": "={{ $('Daily Schedule Trigger').item.json[\"Day of month\"] }} {{ $('Daily Schedule Trigger').item.json.Month }} {{ $('Daily Schedule Trigger').item.json.Year }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cc5741b2-95b2-4b16-9881-fd7f4712d671",
      "name": "Send Telegram Alert",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1296,
        272
      ],
      "parameters": {
        "text": "={{ \"\ud83c\udf1e *\" + $json.planets.Sun.name + \" Hora Schedule*\\n\ud83d\udcc5 _\" + $json.date + \"_\\n\ud83d\udccd _\" + $json.city_name + \"_\\n\\n\u2728 Vigorous Planet: \" + $json.planets.Sun.name + \" (\" + $json.planets.Sun.sanskrit + \")\\n\\n\u23f0 *Favorable Timings:*\\n\\n\" + $json.planets.Sun.timings.map((t, i) => {\n  const emoji = t.period === 'Day' ? (i === 0 ? '\ud83c\udf05' : '\u2600\ufe0f') : (i === 2 ? '\ud83c\udf19' : '\ud83c\udf03');\n  return emoji + \" Hora \" + t.horaNumber + \" (\" + t.period + \")\\n\" + t.startTime + \" - \" + t.endTime;\n}).join('\\n\\n') + \"\\n\\n\ud83d\udcab Nature: \" + $json.planets.Sun.nature }}",
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "additionalFields": {
          "parse_mode": "Markdown",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Filter Sun Horas": {
      "main": [
        [
          {
            "node": "Send Telegram Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Panchang Data": {
      "main": [
        [
          {
            "node": "Extract Hora Timings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Hora Timings": {
      "main": [
        [
          {
            "node": "Filter Sun Horas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch Panchang Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}