8
n8n 中文网amn8n.com

航班价格下降指示器

初级

这是一个Personal Productivity领域的自动化工作流,包含 5 个节点。主要使用 If, Cron, Gmail, Function, HttpRequest 等节点。 监控航班价格下降并通过SerpAPI和Gmail发送邮件提醒

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "s2ucjAukkvRz8P1W",
  "meta": {
    "instanceId": "321893e66e29566d2dc224295f17b402e8c39ace8a5702398bdb6adc518e9626",
    "templateCredsSetupCompleted": true
  },
  "name": "航班价格下降指示器",
  "tags": [],
  "nodes": [
    {
      "id": "758fdc37-1f36-4d00-b402-d9731f1efce8",
      "name": "定时任务",
      "type": "n8n-nodes-base.cron",
      "position": [
        -400,
        -96
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 8
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f12725fa-a814-452c-bfda-44dfa72f8a52",
      "name": "获取价格 - 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": {
          "id": "r6DlikH84CvIRQG1",
          "name": "SerpAPI account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9a29e1f9-e22f-4a3c-8e60-73ddaa661f6e",
      "name": "检查价格下降",
      "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": "价格是否下降?",
      "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": "发送消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        480,
        -96
      ],
      "webhookId": "b13712ed-aeb0-4b7c-bb10-be2a99c1f4c2",
      "parameters": {
        "sendTo": "x22yashc@iima.ac.in",
        "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": {
          "id": "H3TyD6TZqsyZNtVi",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": true,
  "pinData": {},
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

初级 - 个人效率

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
初级
节点数量5
分类1
节点类型5
难度说明

适合 n8n 新手,包含 1-5 个节点的简单工作流

外部链接
在 n8n.io 查看

分享此工作流