{
  "id": "s2ucjAukkvRz8P1W",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Flight Price Drop Indicator",
  "tags": [],
  "nodes": [
    {
      "id": "758fdc37-1f36-4d00-b402-d9731f1efce8",
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "position": [
        -400,
        -96
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 8
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f12725fa-a814-452c-bfda-44dfa72f8a52",
      "name": "Fetch Price - SerpAPI",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -176,
        -96
      ],
      "parameters": {
        "url": "https://serpapi.com/search?engine=google_flights",
        "options": {},
        "authentication": "predefinedCredentialType",
        "queryParametersUi": {
          "parameter": [
            {
              "name": "departure_id",
              "value": "BLR"
            },
            {
              "name": "arrival_id",
              "value": "DEL"
            },
            {
              "name": "outbound_date",
              "value": "2025-09-06"
            },
            {
              "name": "currency",
              "value": "INR"
            },
            {
              "name": "type",
              "value": "2"
            }
          ]
        },
        "nodeCredentialType": "serpApi"
      },
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9a29e1f9-e22f-4a3c-8e60-73ddaa661f6e",
      "name": "Check Price Drop",
      "type": "n8n-nodes-base.function",
      "position": [
        48,
        -96
      ],
      "parameters": {
        "functionCode": "const result = items[0].json;\nlet price = null;\n\ntry {\n  price = result.best_flights[0].price;\n} catch (e) {\n  price = 999999; // fallback if no price found\n}\n\nconst threshold = 4000; // you can update this\n\nreturn [{\n  json: {\n    priceDrop: price < threshold,\n    currentPrice: price\n  }\n}];"
      },
      "typeVersion": 1
    },
    {
      "id": "2240c223-c9c9-428d-85cd-d56ad11eb728",
      "name": "IF Price Dropped?",
      "type": "n8n-nodes-base.if",
      "position": [
        272,
        -96
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json[\"priceDrop\"] }}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "65fb8b03-8fab-45a4-b24a-21b3c692ea7a",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        480,
        -96
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hi Yash,\n\nThe Flight price to Delhi dropped to  {{ $json.currentPrice }}.\n\nYou can book the flight now\n\nRegards\nTeam Yash Choudhary",
        "options": {},
        "subject": "Hi Yashi! Flight price to Delhi Dropped",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2d3fa3e6-8ddf-4f7a-b92f-0d08af430239",
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Fetch Price - SerpAPI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Price Drop": {
      "main": [
        [
          {
            "node": "IF Price Dropped?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Price Dropped?": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Price - SerpAPI": {
      "main": [
        [
          {
            "node": "Check Price Drop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}