[
  {
    "id": "855a8dd4776456c9",
    "type": "aiwk-in",
    "z": "73394bf33c3e3369",
    "name": "N1 aiwk_ping 수신",
    "server": "18af01daa1a16f24",
    "inputEndpoint": "node-red",
    "filterAction": "aiwk_ping",
    "allowAnyEndpoint": false,
    "x": 190,
    "y": 820,
    "wires": [
      [
        "4fdc1c42a0444270"
      ]
    ]
  },
  {
    "id": "4fdc1c42a0444270",
    "type": "function",
    "z": "73394bf33c3e3369",
    "name": "aiwk_ping →  HOST1 aiwk_pong",
    "func": "const p = msg.aiwk || msg.payload || {};\nconst sent = Number(p.client_ts || p.sent_at_ms || (p.args && p.args.client_ts) || (p.payload && p.payload.client_ts) || Date.now());\nconst replyTo = p.from || p.from_client || \"HOST1\";\nmsg.aiwk_type = \"result\";\nmsg.aiwk_action = \"aiwk_pong\";\nmsg.aiwk_to = replyTo;\nmsg.aiwk_from = \"N1\";\nmsg.aiwk_msg_id = \"pong_\" + Date.now();\nmsg.aiwk_reply_to = p.message_id || p.msg_id || \"\";\nmsg.aiwk_reply_to_message_id = msg.aiwk_reply_to;\nmsg.chat_id = p.chat_id || \"home.IG_CRM\";\nmsg.message_id = msg.aiwk_msg_id;\nmsg.reply_to_message_id = msg.aiwk_reply_to_message_id;\nmsg.client_ts = sent;\nmsg.sent_at_ms = Date.now();\nmsg.payload = { kind:\"pong\", from:\"N1\", to:replyTo, reply_to_message_id:msg.reply_to_message_id, client_ts:sent, node_red_ms:Date.now(), received_action:p.action || p.type || \"\" };\nmsg.result = msg.payload;\nnode.status({ fill:\"green\", shape:\"dot\", text:\"PONG → \" + replyTo });\nreturn msg;",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 360,
    "y": 900,
    "wires": [
      [
        "55e4ab1fcc055985"
      ]
    ]
  },
  {
    "id": "55e4ab1fcc055985",
    "type": "aiwk-out",
    "z": "73394bf33c3e3369",
    "name": "aiwk_pong 회신",
    "server": "18af01daa1a16f24",
    "fromEndpoint": "node-red",
    "to": "",
    "action": "aiwk_pong",
    "needAck": false,
    "needResult": false,
    "timeoutMs": 10000,
    "x": 520,
    "y": 820,
    "wires": [
      [
        "1637ac906fd3c0e8"
      ]
    ]
  },
  {
    "id": "1637ac906fd3c0e8",
    "type": "function",
    "z": "73394bf33c3e3369",
    "name": "PONG 송신 상태",
    "func": "node.status({ fill: msg.aiwk_sent ? \"green\" : \"red\", shape: \"ring\", text: JSON.stringify({sent:msg.aiwk_sent,to:msg.aiwk_to,reply_to:msg.reply_to_message_id}) });\nreturn msg;",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 680,
    "y": 880,
    "wires": [
      []
    ]
  },
  {
    "id": "aiwk_chat_in_v058",
    "type": "aiwk-in",
    "z": "73394bf33c3e3369",
    "name": "N1 aiwk_chat 수신",
    "server": "18af01daa1a16f24",
    "inputEndpoint": "node-red",
    "filterAction": "aiwk_chat",
    "allowAnyEndpoint": false,
    "x": 190,
    "y": 980,
    "wires": [
      [
        "aiwk_chat_reply_v058"
      ]
    ]
  },
  {
    "id": "aiwk_chat_reply_v058",
    "type": "function",
    "z": "73394bf33c3e3369",
    "name": "aiwk_chat → from에게 ack",
    "func": "const p = msg.aiwk || msg.payload || {};\nconst text = (p.payload && p.payload.text) || (msg.payload && msg.payload.text) || JSON.stringify(msg.payload || {});\nconst replyTo = p.from || p.from_client || 'HOST1';\nmsg.aiwk_type = 'result';\nmsg.aiwk_action = 'aiwk_chat_ack';\nmsg.aiwk_to = replyTo;\nmsg.aiwk_from = 'N1';\nmsg.aiwk_msg_id = 'chat_ack_' + Date.now();\nmsg.aiwk_reply_to = p.message_id || p.msg_id || '';\nmsg.aiwk_reply_to_message_id = msg.aiwk_reply_to;\nmsg.payload = { ok:1, kind:'chat_ack', from:'N1', to:replyTo, text:text, node_red_ms:Date.now() };\nnode.status({fill:'green',shape:'dot',text:'CHAT ACK → ' + replyTo});\nreturn msg;",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 380,
    "y": 1040,
    "wires": [
      [
        "aiwk_chat_out_v058"
      ]
    ]
  },
  {
    "id": "aiwk_chat_out_v058",
    "type": "aiwk-out",
    "z": "73394bf33c3e3369",
    "name": "aiwk_chat_ack 회신",
    "server": "18af01daa1a16f24",
    "fromEndpoint": "node-red",
    "to": "",
    "action": "aiwk_chat_ack",
    "needAck": false,
    "needResult": false,
    "timeoutMs": 10000,
    "x": 550,
    "y": 980,
    "wires": [
      []
    ]
  }
]
