{
  "name": "AI Agent - ผู้ช่วยเช็กอากาศกรุงเทพฯ (Open-Meteo + Z.AI GLM-4.5-Flash)",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "61a55a1c-3920-4227-af84-34c47b21e2c0",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "webhookId": "33c57f10-8d23-47af-bec1-2af25c02a163"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "คุณคือ “ผู้ช่วยเช็กอากาศกรุงเทพฯ” ตอบเป็นภาษาไทยที่สุภาพ กระชับ และเข้าใจง่าย\n\nขอบเขตของระบบ:\n- เครื่องมือ Open-Meteo ในระบบนี้ให้ “ข้อมูลอากาศปัจจุบันของกรุงเทพมหานคร” เท่านั้น\n- พิกัดที่ใช้คือ latitude 13.7563, longitude 100.5018 และเวลา Asia/Bangkok\n- ไม่สามารถพยากรณ์วันอื่น ชั่วโมงถัดไป หรือสถานที่อื่นได้จากเครื่องมือนี้\n\nขั้นตอนการทำงาน:\n1. เมื่อผู้ใช้ถามเรื่องอากาศ อุณหภูมิ ความชื้น ฝน ฟ้าจะขมุกขมัว หรือควรพกร่มไหม ให้เรียกเครื่องมือ “Open-Meteo Current Weather Bangkok” ก่อนตอบเสมอ\n2. ห้ามแต่งข้อมูลหรือเดาตัวเลขเอง และใช้เฉพาะข้อมูลที่ได้จากเครื่องมือในครั้งนั้น\n3. อ่านค่าเฉพาะจาก current ดังนี้:\n   - เวลา = current.time\n   - อุณหภูมิ = current.temperature_2m หน่วย °C\n   - ความชื้นสัมพัทธ์ = current.relative_humidity_2m หน่วย %\n   - รหัสสภาพอากาศ = current.weather_code\n4. แปล weather_code ตาม WMO Weather Interpretation Codes:\n   - 0 = ท้องฟ้าแจ่มใส\n   - 1 = มีเมฆเล็กน้อย\n   - 2 = มีเมฆเป็นบางส่วน\n   - 3 = เมฆมาก / ครึ้ม\n   - 45, 48 = มีหมอก\n   - 51, 53, 55 = ฝนปรอย\n   - 56, 57 = ฝนปรอยเยือกแข็ง\n   - 61, 63, 65 = ฝนตก\n   - 66, 67 = ฝนเยือกแข็ง\n   - 71, 73, 75, 77 = หิมะ\n   - 80, 81, 82 = ฝนซู่ / ฝนตกหนักเป็นช่วง ๆ\n   - 85, 86 = หิมะซู่\n   - 95 = ฟ้าคะนอง\n   - 96, 99 = ฟ้าคะนองร่วมกับลูกเห็บ\n5. คำตอบมาตรฐานควรมี: เวลาของข้อมูล, อุณหภูมิ, ความชื้น, และสภาพอากาศ\n6. หากผู้ใช้ถามว่า “ควรพกร่มไหม” ให้ตอบอย่างระมัดระวังจากสภาพอากาศปัจจุบันเท่านั้น:\n   - ถ้ารหัสเสี่ยงฝนตกหรือฟ้าคะนอง ให้แนะนำพกร่ม\n   - ถ้าไม่มีฝน ให้บอกว่า “ตอนนี้ยังไม่มีสัญญาณฝนจากข้อมูลปัจจุบัน แต่ API นี้ไม่ได้ให้พยากรณ์ล่วงหน้า”\n7. หากผู้ใช้ถามเมืองอื่นหรือวัน/เวลาล่วงหน้า ให้ตอบตรงๆ ว่า Workflow ตัวอย่างนี้ตั้งไว้เฉพาะตรวจอากาศปัจจุบันของกรุงเทพฯ เท่านั้น\n8. หากผลลัพธ์ไม่มี current ให้ตอบว่าไม่สามารถอ่านข้อมูลอากาศปัจจุบันได้ และห้ามแต่งข้อมูลเพิ่ม"
        }
      },
      "id": "73e47d63-b746-47a8-8e94-2e1ba441c548",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        330,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "glm-4.5-flash",
          "mode": "id",
          "cachedResultName": "glm-4.5-flash"
        },
        "options": {}
      },
      "id": "52b134e3-a1e0-453b-a418-3f84716966e3",
      "name": "Z.AI GLM-4.5-Flash Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        330,
        230
      ]
    },
    {
      "parameters": {
        "toolDescription": "ใช้เครื่องมือนี้เมื่อผู้ใช้ถามอากาศปัจจุบันของกรุงเทพฯ เช่น ตอนนี้กี่องศา ความชื้นเท่าไร ฝนตกไหม อากาศเป็นอย่างไร หรือควรพกร่มไหม เครื่องมือนี้จะดึงข้อมูลปัจจุบันใน current ได้แก่ current.time, current.temperature_2m, current.relative_humidity_2m และ current.weather_code ตาม WMO Weather Interpretation Codes",
        "method": "GET",
        "url": "https://api.open-meteo.com/v1/forecast?latitude=13.7563&longitude=100.5018&current=temperature_2m,relative_humidity_2m,weather_code&timezone=Asia%2FBangkok",
        "options": {}
      },
      "id": "15d04a77-14cf-464a-9cc5-eb7d15aa440b",
      "name": "Open-Meteo Current Weather Bangkok",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.3,
      "position": [
        650,
        230
      ]
    },
    {
      "parameters": {
        "content": "### ตัวอย่าง AI Agent: ผู้ช่วยเช็กอากาศกรุงเทพฯ\n\nโครงสร้าง Workflow\n\n`Chat Trigger → AI Agent → Z.AI GLM-4.5-Flash + Open-Meteo HTTP Request Tool`\n\n**สิ่งที่นักศึกษาจะได้ฝึก**\n- ให้ AI Agent อ่านคำถามของผู้ใช้\n- ใช้ Tool description เพื่อเลือกเรียก HTTP Request\n- อ่าน JSON จาก Open-Meteo ใน `current`\n- แปลรหัส `weather_code` เป็นภาษาคน\n- สรุปอุณหภูมิ ความชื้น และสภาพอากาศเป็นภาษาไทย\n\n**ตั้งค่า GLM หลัง Import**\n- Credential: OpenAI API / Z.AI API Key ของผู้ใช้\n- Base URL: `https://api.z.ai/api/paas/v4`\n- Model mode: `By ID`\n- Model: `glm-4.5-flash`\n\n**คำถามทดสอบ**\n- `ตอนนี้กรุงเทพฯ อากาศเป็นอย่างไร`\n- `กรุงเทพฯ ตอนนี้กี่องศา`\n- `ตอนนี้ควรพกร่มไหม`\n- `ความชื้นกรุงเทพฯ ตอนนี้เท่าไร`\n\n> API ตัวอย่างนี้ให้เฉพาะอากาศปัจจุบันของกรุงเทพฯ ไม่ใช่พยากรณ์หลายวันหรือหลายเมือง",
        "height": 460,
        "width": 780,
        "color": 5
      },
      "id": "7d6a14c1-9658-4251-a816-f7a38350df17",
      "name": "วิธีใช้และเปลี่ยนพิกัด",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -70,
        -470
      ]
    }
  ],
  "connections": {
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Z.AI GLM-4.5-Flash Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Open-Meteo Current Weather Bangkok": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e1d87f73-c31e-48d2-954c-485554e4f9cc",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
