{
  "schema_version": "1.0",
  "journey": {
    "key": "order_tracking",
    "name": "پیگیری سفارش WooCommerce",
    "description": "پیگیری امن سفارش با شماره سفارش و موبایل ثبت‌شده در صورتحساب",
    "start": "start"
  },
  "variables": {
    "order_id": {"type": "string"},
    "customer_phone": {"type": "string"},
    "order": {"type": "object"}
  },
  "nodes": [
    {"id": "start", "type": "start", "next": "intro"},
    {
      "id": "intro",
      "type": "message",
      "text": "برای پیگیری امن سفارش، شماره سفارش و موبایلی که هنگام خرید ثبت کردید لازم است.",
      "next": "order_id"
    },
    {
      "id": "order_id",
      "type": "question",
      "text": "شماره سفارش را بدون علامت اضافی وارد کنید.",
      "input_type": "text",
      "placeholder": "مثلاً 1460469",
      "save_to": "order_id",
      "next": "customer_phone"
    },
    {
      "id": "customer_phone",
      "type": "question",
      "text": "شماره موبایل ثبت‌شده در همان سفارش را وارد کنید.",
      "input_type": "text",
      "placeholder": "مثلاً 09123456789",
      "save_to": "customer_phone",
      "next": "get_order"
    },
    {
      "id": "get_order",
      "type": "action",
      "name": "دریافت سفارش از WooCommerce",
      "action": "woocommerce.get_order",
      "input": {
        "order_id": "{{order_id}}",
        "phone": "{{customer_phone}}"
      },
      "save_result": "order",
      "on_success": "order_found",
      "on_error": "order_not_found"
    },
    {
      "id": "order_found",
      "type": "message",
      "text": "{{order.summary}}",
      "next": "end"
    },
    {
      "id": "order_not_found",
      "type": "message",
      "text": "سفارشی با این شماره و موبایل پیدا نشد یا سرویس فروشگاه موقتاً در دسترس نیست.",
      "next": "retry_options"
    },
    {
      "id": "retry_options",
      "type": "buttons",
      "text": "می‌خواهید دوباره تلاش کنید؟",
      "options": [
        {"label": "تلاش مجدد", "value": "retry", "next": "order_id"},
        {"label": "پایان", "value": "end", "next": "end"}
      ]
    },
    {"id": "end", "type": "end"}
  ],
  "layout": {
    "start": {"x": 470, "y": 40},
    "intro": {"x": 470, "y": 160},
    "order_id": {"x": 470, "y": 300},
    "customer_phone": {"x": 470, "y": 440},
    "get_order": {"x": 470, "y": 580},
    "order_found": {"x": 250, "y": 740},
    "order_not_found": {"x": 690, "y": 740},
    "retry_options": {"x": 690, "y": 890},
    "end": {"x": 470, "y": 1050}
  }
}
