{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "c96208f6-6159-4a2d-bda6-8e45964a1b37",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        280,
        0
      ],
      "parameters": {
        "options": {
          "systemMessage": "=You are a helpful and intelligent AI travel assistant. Your job is to guide users through booking flights by collecting essential travel details step-by-step, and then using the attached SerpAPI Tool to search for real-time flight options.\n\nCurrent Date Time is: {{ $now }}\n\nBefore using the tool, you must collect the following:\n- `departure_id`: IATA code for departure airport (e.g., ISB)\n- `arrival_id`: IATA code for arrival airport (e.g., DXB)\n- `outbound_date`: Date of departure in YYYY-MM-DD format\n- `type`: Either \"one-way\" or \"round-trip\"\n- `return_date`: Only required if the trip is \"round-trip\"\n\nIf any of these fields are missing, ask the user politely and clearly to provide the missing information. Do not proceed to search until all required fields are available.\n\nOnce all fields are collected:\n1. Call the attached **SerpAPI Tool** to search for available flights.\n2. Summarize the top 3 options in the following format:\n\n---\n\u2708\ufe0f *Flights from ISB to DXB on 2025-07-25*\n\n1. Emirates \u2013 $420 \u2013 3h 40m \u2013 Nonstop  \n2. Qatar Airways \u2013 $390 \u2013 6h \u2013 1 stop (via Doha)  \n3. FlyDubai \u2013 $350 \u2013 4h 20m \u2013 Nonstop  \n\nWould you like to book one of these?\n---\n\nIf the user provided a return date, add:\n\ud83d\udeec *Return on 2025-08-01*\n\nIf no flights are found, say:\n> \u201cSorry, I couldn\u2019t find any flights for that route and date. Try a different date or nearby airport?\u201d\n\nIf the user selects a specific flight (e.g., \"book the second one\" or \"I want FlyDubai\"), respond with the corresponding **booking link** from the tool results.\n\nBe conversational, clear, and concise. Never assume \u2014 always confirm missing information before searching. Your tone should be helpful, friendly, and professional."
        }
      },
      "typeVersion": 2
    },
    {
      "id": "a9171c94-e59e-4120-9de9-7c98f1bf20c2",
      "name": "DeepSeek Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "position": [
        160,
        224
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "deepSeekApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "eab49a45-bd0d-4073-ad37-0ccde982aab9",
      "name": "Google_flights search in SerpApi",
      "type": "n8n-nodes-serpapi.serpApiTool",
      "position": [
        592,
        208
      ],
      "parameters": {
        "operation": "google_flights",
        "arrival_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Arrival_airport_code___location_kgmid__arrival_id_', ``, 'string') }}",
        "return_date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_Date__return_date_', ``, 'string') }}",
        "departure_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Departure_airport_code___location_kgmid__departure_id_', ``, 'string') }}",
        "outbound_date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Outbound_Date__outbound_date_', ``, 'string') }}",
        "requestOptions": {},
        "descriptionType": "manual",
        "toolDescription": "Search for live flights from one city to another using Google Flights data",
        "additionalFields": {}
      },
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7f867f93-235a-46ba-8c9c-13c52e0c5945",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        368,
        224
      ],
      "parameters": {
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "299b9f43-ba5f-4bd0-9fb6-e16e64a40e76",
      "name": "Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {}
      },
      "typeVersion": 1.1
    }
  ],
  "connections": {
    "Chat": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "DeepSeek Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google_flights search in SerpApi": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}