{
  "name": "Build a WhatsApp AI shopping bot with virtual try-on using Gemini and GPT",
  "nodes": [
    {
      "id": "4f63a844-6f93-4880-a74f-aa40787aace6",
      "name": "📌 Main overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4608,
        736
      ],
      "parameters": {
        "width": 516,
        "height": 620,
        "content": "## WhatsApp AI shopping bot for Bytez\n\n## How it works\n1. User sends a WhatsApp message (text, button tap, or image).\n2. GPT-5-nano classifies the intent and routes to the correct flow.\n3. Product sea"
      }
    },
    {
      "id": "271c0200-b2e1-4830-abd0-22a1994bb404",
      "name": "📌 Group: Entry & Router",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5184,
        736
      ],
      "parameters": {
        "width": 580,
        "height": 460,
        "content": "## 📥 Entry & Message Router\nReceives all incoming WhatsApp messages. Routes button taps and image uploads to the interactive handler. Routes plain text messages to the validation pipeline.\n"
      }
    },
    {
      "id": "2c5fe6ef-414d-4184-9593-d373815ac389",
      "name": "📌 Group: Validation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5856,
        2160
      ],
      "parameters": {
        "width": 760,
        "height": 476,
        "content": "## ✅ Text Message Validation\nValidates incoming text for empty input, spam, XSS, and unsupported types. Invalid messages are rejected with a user-friendly error reply before entering the session pipel"
      }
    },
    {
      "id": "d6513e3e-c805-4987-afce-dd7db7a5f739",
      "name": "📌 Group: Session Management",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6656,
        2064
      ],
      "parameters": {
        "width": 492,
        "height": 396,
        "content": "## 💾 Session Management (Redis)\nLoads or creates a per-user Redis session (TTL: 1 hr). Appends user and assistant messages. Keeps the last 20 messages using a sliding window."
      }
    },
    {
      "id": "44cad1fa-b280-4824-9f37-ced7823009c5",
      "name": "📌 Group: AI Classification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7296,
        1856
      ],
      "parameters": {
        "width": 1496,
        "height": 828,
        "content": "## 🧠 AI Classification & Routing\nBytezBot classifies intent using GPT-5-nano. Returns JSON for product_search or recommend, or plain text for all other queries. Routes to the product pipeline or a dir"
      }
    },
    {
      "id": "590a85d0-ed0d-4afe-ac0a-e35761a58356",
      "name": "📌 Group: Cache & Vector Search",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8864,
        1600
      ],
      "parameters": {
        "width": 2508,
        "height": 732,
        "content": "## ⚡ Product Search (Cache + Vector)\nChecks Redis cache first (TTL: 1 hr). On a miss, runs MongoDB Atlas vector search using OpenAI embeddings. \nDownloads product images from Drive and stores results "
      }
    },
    {
      "id": "ffbd2a6d-6185-4a9e-b665-be92ffa2731c",
      "name": "📌 Group: Product Sender",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11424,
        1664
      ],
      "parameters": {
        "width": 1148,
        "height": 460,
        "content": "## 📤 Product Message Sender\nLoops through each matched product. Uploads image to WhatsApp media API. \nSends an interactive message with Order Now and Virtual Try-On buttons."
      }
    },
    {
      "id": "8b304693-991b-49d1-899c-b9a53c5a48c0",
      "name": "📌 Group: Order Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6960,
        -112
      ],
      "parameters": {
        "width": 1148,
        "height": 588,
        "content": "## 🛒 Order Flow\nTriggered when user taps Order Now. AI agent fetches product, creates an order document, saves to MongoDB and Google Sheets, then sends a confirmation message via WhatsApp."
      }
    },
    {
      "id": "5b487497-fb35-46f4-8b51-b7e3677608e0",
      "name": "📌 Group: VTO Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6752,
        -560
      ],
      "parameters": {
        "width": 872,
        "height": 360,
        "content": "## 👗 Virtual Try-On (VTO) Flow\nStores product ID in Redis (TTL: 10 min) and prompts the user for a selfie. Gemini validates exactly one person, generates the try-on image, sends it via WhatsApp, then "
      }
    },
    {
      "id": "42252d26-19e1-4359-872b-94c2ce3a9ea2",
      "name": "Check Redis cache",
      "type": "n8n-nodes-base.redis",
      "position": [
        9104,
        1872
      ]
    },
    {
      "id": "493b1ea1-356f-461a-b6fa-bdfc0c39be03",
      "name": "Store products in cache",
      "type": "n8n-nodes-base.redis",
      "position": [
        11024,
        1984
      ]
    },
    {
      "id": "cc9a90f4-db40-4498-960a-e590a43376fc",
      "name": "Save session to Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        8208,
        2176
      ]
    },
    {
      "id": "dcc659e3-24d9-40ab-b06e-ea7412a0642e",
      "name": "Validate incoming message",
      "type": "n8n-nodes-base.code",
      "position": [
        5984,
        2304
      ]
    },
    {
      "id": "2ec6a4c2-06eb-4ab9-b0e5-09b779ecd7b8",
      "name": "Send validation error to user",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        6432,
        2400
      ]
    },
    {
      "id": "05cfe114-d777-4c15-9e33-495b376860db",
      "name": "Get user session from Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        6704,
        2224
      ]
    },
    {
      "id": "2497bfb1-6cc9-4243-996d-25f91f7e57de",
      "name": "GPT-5-nano (intent classifier)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        7312,
        2432
      ]
    },
    {
      "id": "1117d593-3437-4e96-9e31-448b090062c9",
      "name": "Set VTO context in Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        6816,
        -432
      ]
    },
    {
      "id": "26f4dfd0-95c5-4af1-b0d1-213991fbf947",
      "name": "GPT-4o (order agent)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        7120,
        272
      ]
    },
    {
      "id": "4c10f728-35e4-44e0-93b4-356c389cc63b",
      "name": "Create order in MongoDB",
      "type": "n8n-nodes-base.mongoDbTool",
      "position": [
        7392,
        272
      ]
    },
    {
      "id": "3f3518a8-c956-43ba-9d06-f3c221b1ff23",
      "name": "Get product info from MongoDB",
      "type": "n8n-nodes-base.mongoDbTool",
      "position": [
        7520,
        272
      ]
    },
    {
      "id": "0c5258dc-ab79-4e54-afa9-9ca3e104c42b",
      "name": "Order orchestration AI agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        7296,
        48
      ]
    },
    {
      "id": "6528994a-08f3-415c-8c83-4f134a3505e8",
      "name": "Log order to Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        7648,
        272
      ]
    },
    {
      "id": "62b212a7-9298-4135-9ec1-caf2a9fe1685",
      "name": "Send order confirmation",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        7920,
        144
      ]
    },
    {
      "id": "f10c9a50-4a13-4697-91c7-fe2e71f94671",
      "name": "AI shopping agent (BytezBot)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        7392,
        2176
      ]
    },
    {
      "id": "c0a06cba-4eb1-4d0d-9972-c48467fa6fc4",
      "name": "MongoDB Atlas vector search",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        9552,
        1984
      ]
    },
    {
      "id": "5b799fdc-3a3f-4a55-a29b-7cfb1f6a40c6",
      "name": "OpenAI embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        9616,
        2208
      ]
    },
    {
      "id": "17c1b430-eb95-4059-b658-7d572dac8838",
      "name": "Get product image from MongoDB",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        7968,
        720
      ]
    },
    {
      "id": "71738df2-3d3d-489c-95c0-417f4dec9cbf",
      "name": "Resize product image to 1024px",
      "type": "n8n-nodes-base.editImage",
      "position": [
        8416,
        720
      ]
    },
    {
      "id": "0c55a6ff-a1ca-4a97-b862-dd97acc9c974",
      "name": "Extract product image as base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        8640,
        720
      ]
    },
    {
      "id": "9f838541-b2ab-4627-bec1-9c9054c887ba",
      "name": "Resize user selfie to 1024px",
      "type": "n8n-nodes-base.editImage",
      "position": [
        8416,
        912
      ]
    },
    {
      "id": "755658dd-37eb-492a-a2a7-c76b5dd20bd4",
      "name": "Extract user selfie as base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        8640,
        912
      ]
    },
    {
      "id": "19574e9a-3276-405e-9bc2-7ad1a75c10cd",
      "name": "Generate VTO with Gemini API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        9536,
        1008
      ]
    },
    {
      "id": "130fa21d-dd0e-4580-bad8-13a00956cfda",
      "name": "Delete VTO context from Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        10432,
        1008
      ]
    },
    {
      "id": "3339b281-64a3-497b-9653-b84f73841e2d",
      "name": "Get VTO context from Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        7296,
        1104
      ]
    },
    {
      "id": "8bbb9949-4661-4696-ade9-7cd702e8c0b4",
      "name": "Get WhatsApp media URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        7968,
        1104
      ]
    },
    {
      "id": "8003ff1b-ac5d-4f23-8b39-d7a54c32bfcf",
      "name": "Download user selfie",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8192,
        1104
      ]
    },
    {
      "id": "0c89b60a-8bc7-4aed-b0c6-aed6ab7991cc",
      "name": "Download product image from Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        9904,
        2064
      ]
    },
    {
      "id": "5a8a8d84-4c55-44fb-af66-234d0d10be22",
      "name": "Convert product image to base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        10128,
        2064
      ]
    },
    {
      "id": "937723b2-490b-426a-bb1b-fc38873546c8",
      "name": "Upload product image to WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        12144,
        1792
      ]
    },
    {
      "id": "c296c374-7c20-4346-9ec3-c12820a33ad0",
      "name": "Send product message with buttons",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        12368,
        1872
      ]
    },
    {
      "id": "6a7462e4-7038-4b3f-bf0f-11bb81403d8c",
      "name": "Loop through products",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        11472,
        1872
      ]
    },
    {
      "id": "c044e979-26c4-43e2-b869-4260e384feec",
      "name": "Download product image from Drive (VTO)",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        8192,
        720
      ]
    },
    {
      "id": "11937477-4aec-47c3-a613-e3f59d256722",
      "name": "Ask user to send correct photo",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        7744,
        1200
      ]
    },
    {
      "id": "d436178b-d025-428e-8e88-35d1e0dd3b91",
      "name": "Prompt user to upload selfie",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        7360,
        -432
      ]
    },
    {
      "id": "5e8c9f77-39c7-409a-ac8a-4f17abd77112",
      "name": "Upload VTO result to WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        9984,
        1008
      ]
    },
    {
      "id": "cb15a9f3-766a-4cfd-87f7-e0f123b1eef8",
      "name": "Send VTO result to user",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        10208,
        1008
      ]
    },
    {
      "id": "dd950826-591a-43f6-b56e-8d3fc1e33779",
      "name": "Convert Gemini response to image file",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        9760,
        1008
      ]
    },
    {
      "id": "d1c50b63-deee-47c0-ad1f-af1a413ac084",
      "name": "Analyze user selfie with Gemini",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        8416,
        1104
      ]
    },
    {
      "id": "6dcebd94-f7a0-4455-8c2a-0470cbbac32a",
      "name": "Send text response to user",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        8656,
        2192
      ]
    },
    {
      "id": "b8e70696-1f3e-49f2-82d1-6e0da5467d0b",
      "name": "Ask user to resend valid photo",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        9312,
        1200
      ]
    },
    {
      "id": "50f03b72-dede-45a6-b110-d1c64f542dc6",
      "name": "Notify user VTO is processing",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        9312,
        816
      ]
    },
    {
      "id": "c449500b-2303-498a-9d9d-d6c7115a78b6",
      "name": "Parse button and user data",
      "type": "n8n-nodes-base.code",
      "position": [
        6016,
        80
      ]
    },
    {
      "id": "1de08af7-976a-482b-8ffc-bd121a557769",
      "name": "📌 Group: Entry & Router1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5632,
        -48
      ],
      "parameters": {
        "width": 956,
        "height": 608,
        "content": "## 📥 Entry & Message Router\nReceives all incoming WhatsApp messages.\nRoutes traffic by type:\n- Button/image → interactive handler\n- Text → validation pipeline"
      }
    },
    {
      "id": "78e04d36-5352-4bc3-8419-5d82c93b7449",
      "name": "WhatsApp message trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        5296,
        1024
      ]
    },
    {
      "id": "448fed6d-99a9-47fb-9073-fc14f23046f7",
      "name": "Group: VTO Context Check",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7072,
        880
      ],
      "parameters": {
        "width": 848,
        "height": 492,
        "content": "## 🔴 VTO Context Check\nGETs `vto_context_{waId}` from Redis. If a product ID is stored (user previously tapped Try-On), proceed to image processing. If not found, ask user to tap the Try-On button on "
      }
    },
    {
      "id": "0ec56bf9-33a5-44ef-bcc7-2d8154f09c85",
      "name": "Group: Image Preparation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7936,
        544
      ],
      "parameters": {
        "width": 1056,
        "height": 780,
        "content": "## 🖼️ Image Download & Preparation\nFetches product image from MongoDB → downloads from Google Drive → resizes to 1024×1024. In parallel, fetches the user selfie from WhatsApp media API → downloads → r"
      }
    },
    {
      "id": "d42de00f-749e-4c6d-8971-c64b66c60937",
      "name": "Group: Validate Generate Send",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9024,
        688
      ],
      "parameters": {
        "width": 1600,
        "height": 716,
        "content": "## 🤖 Validate, Generate & Send\n\nGemini checks if exactly one real person is in the selfie. If valid, both images are sent to Gemini 2.5 Flash to generate the try-on result. Output is uploaded to Whats"
      }
    },
    {
      "id": "8a0ef9cf-6ebc-4d52-b25f-ac3f71364385",
      "name": "Check if message is button or image",
      "type": "n8n-nodes-base.if",
      "position": [
        5584,
        1024
      ]
    },
    {
      "id": "8180e0b1-eb66-415f-a60c-20728897d6ed",
      "name": "Route interactive vs image message",
      "type": "n8n-nodes-base.switch",
      "position": [
        5824,
        368
      ]
    },
    {
      "id": "805b97d3-2874-43ff-b2d6-8a5a5b1b284e",
      "name": "Route VTO vs order button tap",
      "type": "n8n-nodes-base.switch",
      "position": [
        6240,
        80
      ]
    },
    {
      "id": "13be1098-b721-40ba-8518-76250f54f965",
      "name": "Route JSON intent vs plain text reply",
      "type": "n8n-nodes-base.if",
      "position": [
        8432,
        2176
      ]
    },
    {
      "id": "eabef4a8-9a42-45a3-b4bd-e30b0311d358",
      "name": "Route product search vs recommend",
      "type": "n8n-nodes-base.switch",
      "position": [
        8656,
        1936
      ]
    },
    {
      "id": "c1bba81c-3a96-4a10-827b-bf9e27a2c7c2",
      "name": "Is product cached in Redis?",
      "type": "n8n-nodes-base.if",
      "position": [
        9328,
        1872
      ]
    },
    {
      "id": "87239b9b-7596-4016-aab6-3d1d30007d63",
      "name": "Pass valid messages, block invalid",
      "type": "n8n-nodes-base.if",
      "position": [
        6208,
        2304
      ]
    },
    {
      "id": "32da4b15-461c-481e-9f0e-566c7e9d20b3",
      "name": "Is VTO product ID stored in Redis?",
      "type": "n8n-nodes-base.if",
      "position": [
        7520,
        1104
      ]
    },
    {
      "id": "d4fc7939-1fa9-4a2e-a991-c1a61b0f1e5d",
      "name": "Gemini: confirm exactly one person",
      "type": "n8n-nodes-base.if",
      "position": [
        8640,
        1104
      ]
    },
    {
      "id": "10b63728-4769-415c-b1de-c53c892f9cad",
      "name": "Validate merged selfie before try-on",
      "type": "n8n-nodes-base.if",
      "position": [
        9088,
        912
      ]
    },
    {
      "id": "e8b3f8b9-44f3-4de6-a299-b960d51a9d29",
      "name": "Parse cached product JSON array",
      "type": "n8n-nodes-base.code",
      "position": [
        11248,
        1744
      ]
    },
    {
      "id": "bfce07d0-b484-43ff-a031-4cee473a67e8",
      "name": "Unpack products from cache result",
      "type": "n8n-nodes-base.code",
      "position": [
        11248,
        1984
      ]
    },
    {
      "id": "5fd38a9a-15df-4d86-91cd-2f351891c938",
      "name": "Build Redis cache key from search query",
      "type": "n8n-nodes-base.code",
      "position": [
        8880,
        1872
      ]
    },
    {
      "id": "24ee484d-e390-4d40-a1b7-9754042e99dc",
      "name": "Extract image ID, waId, and product ID",
      "type": "n8n-nodes-base.code",
      "position": [
        7744,
        1008
      ]
    },
    {
      "id": "e4d2709c-95b3-493c-9fd0-32fc5bc7374d",
      "name": "Combine products with base64 images",
      "type": "n8n-nodes-base.code",
      "position": [
        10800,
        1984
      ]
    },
    {
      "id": "257e7891-8b5f-4718-855f-4e23794031e2",
      "name": "Load session and append user message",
      "type": "n8n-nodes-base.code",
      "position": [
        6928,
        2224
      ]
    },
    {
      "id": "08d0b3f8-c5c9-4274-8ee5-c0c810e65a6b",
      "name": "Append AI reply to session history",
      "type": "n8n-nodes-base.code",
      "position": [
        7984,
        2176
      ]
    },
    {
      "id": "ce62ffc8-679b-4eca-a604-9640b2f2889f",
      "name": "Detect JSON intent or plain text reply",
      "type": "n8n-nodes-base.code",
      "position": [
        7760,
        2176
      ]
    },
    {
      "id": "e0470c00-81e8-4578-8d74-926907833d45",
      "name": "Build product card message body",
      "type": "n8n-nodes-base.code",
      "position": [
        11696,
        1792
      ]
    },
    {
      "id": "19a1c507-9071-4706-8e0c-262ba992797e",
      "name": "Convert product image base64 to binary",
      "type": "n8n-nodes-base.code",
      "position": [
        11920,
        1792
      ]
    },
    {
      "id": "2603eb03-479f-4b89-8476-463d04461c7c",
      "name": "Merge product, selfie, and validation result",
      "type": "n8n-nodes-base.merge",
      "position": [
        8864,
        896
      ]
    },
    {
      "id": "6011710c-a123-4309-8c04-5e81cc6f9557",
      "name": "Combine vector search results with images",
      "type": "n8n-nodes-base.merge",
      "position": [
        10576,
        1984
      ]
    },
    {
      "id": "b62fd56d-b942-414d-937a-4545d062a128",
      "name": "Aggregate all product base64 images",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        10352,
        2064
      ]
    },
    {
      "id": "a4901b1e-a1b8-419d-9d2d-b0cbb4870799",
      "name": "Build Gemini image generation API payload",
      "type": "n8n-nodes-base.code",
      "position": [
        9312,
        1008
      ]
    },
    {
      "id": "c3988767-bb62-4381-8d53-658266957f9f",
      "name": "Session memory for shopping agent",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        7552,
        2528
      ]
    },
    {
      "id": "699e8b08-66b0-4c2c-94b6-4b4f641ccc33",
      "name": "Session memory for order agent",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        7248,
        272
      ]
    }
  ],
  "connections": {
    "Check Redis cache": {
      "main": [
        [
          {
            "node": "Is product cached in Redis?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI embeddings": {
      "ai_embedding": [
        [
          {
            "node": "MongoDB Atlas vector search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Download user selfie": {
      "main": [
        [
          {
            "node": "Analyze user selfie with Gemini",
            "type": "main",
            "index": 0
          },
          {
            "node": "Resize user selfie to 1024px",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o (order agent)": {
      "ai_languageModel": [
        [
          {
            "node": "Order orchestration AI agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop through products": {
      "main": [
        [],
        [
          {
            "node": "Build product card message body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save session to Redis": {
      "main": [
        [
          {
            "node": "Route JSON intent vs plain text reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get WhatsApp media URL": {
      "main": [
        [
          {
            "node": "Download user selfie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create order in MongoDB": {
      "ai_tool": [
        [
          {
            "node": "Order orchestration AI agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send VTO result to user": {
      "main": [
        [
          {
            "node": "Delete VTO context from Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store products in cache": {
      "main": [
        [
          {
            "node": "Unpack products from cache result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set VTO context in Redis": {
      "main": [
        [
          {
            "node": "Prompt user to upload selfie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp message trigger": {
      "main": [
        [
          {
            "node": "Check if message is button or image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate incoming message": {
      "main": [
        [
          {
            "node": "Pass valid messages, block invalid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get VTO context from Redis": {
      "main": [
        [
          {
            "node": "Is VTO product ID stored in Redis?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log order to Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "Order orchestration AI agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Parse button and user data": {
      "main": [
        [
          {
            "node": "Route VTO vs order button tap",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get user session from Redis": {
      "main": [
        [
          {
            "node": "Load session and append user message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is product cached in Redis?": {
      "main": [
        [
          {
            "node": "Parse cached product JSON array",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "MongoDB Atlas vector search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MongoDB Atlas vector search": {
      "main": [
        [
          {
            "node": "Download product image from Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Combine vector search results with images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI shopping agent (BytezBot)": {
      "main": [
        [
          {
            "node": "Detect JSON intent or plain text reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate VTO with Gemini API": {
      "main": [
        [
          {
            "node": "Convert Gemini response to image file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order orchestration AI agent": {
      "main": [
        [
          {
            "node": "Send order confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resize user selfie to 1024px": {
      "main": [
        [
          {
            "node": "Extract user selfie as base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract user selfie as base64": {
      "main": [
        [
          {
            "node": "Merge product, selfie, and validation result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get product info from MongoDB": {
      "ai_tool": [
        [
          {
            "node": "Order orchestration AI agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Route VTO vs order button tap": {
      "main": [
        [
          {
            "node": "Set VTO context in Redis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Order orchestration AI agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload VTO result to WhatsApp": {
      "main": [
        [
          {
            "node": "Send VTO result to user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-5-nano (intent classifier)": {
      "ai_languageModel": [
        [
          {
            "node": "AI shopping agent (BytezBot)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get product image from MongoDB": {
      "main": [
        [
          {
            "node": "Download product image from Drive (VTO)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resize product image to 1024px": {
      "main": [
        [
          {
            "node": "Extract product image as base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Session memory for order agent": {
      "ai_memory": [
        [
          {
            "node": "Order orchestration AI agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Analyze user selfie with Gemini": {
      "main": [
        [
          {
            "node": "Gemini: confirm exactly one person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build product card message body": {
      "main": [
        [
          {
            "node": "Convert product image base64 to binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert product image to base64": {
      "main": [
        [
          {
            "node": "Aggregate all product base64 images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract product image as base64": {
      "main": [
        [
          {
            "node": "Merge product, selfie, and validation result",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Parse cached product JSON array": {
      "main": [
        [
          {
            "node": "Loop through products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload product image to WhatsApp": {
      "main": [
        [
          {
            "node": "Send product message with buttons",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download product image from Drive": {
      "main": [
        [
          {
            "node": "Convert product image to base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route product search vs recommend": {
      "main": [
        [
          {
            "node": "Build Redis cache key from search query",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Redis cache key from search query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send product message with buttons": {
      "main": [
        [
          {
            "node": "Loop through products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Session memory for shopping agent": {
      "ai_memory": [
        [
          {
            "node": "AI shopping agent (BytezBot)",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Unpack products from cache result": {
      "main": [
        [
          {
            "node": "Loop through products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append AI reply to session history": {
      "main": [
        [
          {
            "node": "Save session to Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini: confirm exactly one person": {
      "main": [
        [
          {
            "node": "Merge product, selfie, and validation result",
            "type": "main",
            "index": 2
          }
        ],
        [
          {
            "node": "Merge product, selfie, and validation result",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Is VTO product ID stored in Redis?": {
      "main": [
        [
          {
            "node": "Extract image ID, waId, and product ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ask user to send correct photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pass valid messages, block invalid": {
      "main": [
        [
          {
            "node": "Get user session from Redis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send validation error to user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route interactive vs image message": {
      "main": [
        [
          {
            "node": "Parse button and user data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get VTO context from Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate all product base64 images": {
      "main": [
        [
          {
            "node": "Combine vector search results with images",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check if message is button or image": {
      "main": [
        [
          {
            "node": "Route interactive vs image message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate incoming message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine products with base64 images": {
      "main": [
        [
          {
            "node": "Store products in cache",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load session and append user message": {
      "main": [
        [
          {
            "node": "AI shopping agent (BytezBot)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate merged selfie before try-on": {
      "main": [
        [
          {
            "node": "Build Gemini image generation API payload",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify user VTO is processing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ask user to resend valid photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Gemini response to image file": {
      "main": [
        [
          {
            "node": "Upload VTO result to WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route JSON intent vs plain text reply": {
      "main": [
        [
          {
            "node": "Route product search vs recommend",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send text response to user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert product image base64 to binary": {
      "main": [
        [
          {
            "node": "Upload product image to WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect JSON intent or plain text reply": {
      "main": [
        [
          {
            "node": "Append AI reply to session history",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract image ID, waId, and product ID": {
      "main": [
        [
          {
            "node": "Get product image from MongoDB",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get WhatsApp media URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Redis cache key from search query": {
      "main": [
        [
          {
            "node": "Check Redis cache",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download product image from Drive (VTO)": {
      "main": [
        [
          {
            "node": "Resize product image to 1024px",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Gemini image generation API payload": {
      "main": [
        [
          {
            "node": "Generate VTO with Gemini API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine vector search results with images": {
      "main": [
        [
          {
            "node": "Combine products with base64 images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge product, selfie, and validation result": {
      "main": [
        [
          {
            "node": "Validate merged selfie before try-on",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}