{
  "name": "Send AI-parsed restaurant orders and status updates via Telegram and Google Sheets",
  "nodes": [
    {
      "id": "b7299a4b-43b0-4f92-bad4-fb1dfa8bb206",
      "name": "Customer Bot Listener",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        7040,
        3552
      ]
    },
    {
      "id": "e492c4f7-a371-40fb-9d0d-b6f17f2fc063",
      "name": "Route Message",
      "type": "n8n-nodes-base.code",
      "position": [
        7296,
        3552
      ]
    },
    {
      "id": "604a199d-c32f-4eed-a5a1-82ed3d9abba5",
      "name": "Message Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        7552,
        3456
      ]
    },
    {
      "id": "c2920056-7417-479a-aead-cbda24afc2ff",
      "name": "Send Welcome",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8144,
        3152
      ]
    },
    {
      "id": "0f8cb239-b193-44a2-aaea-71cf82027ca8",
      "name": "Send Help",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8144,
        3312
      ]
    },
    {
      "id": "57c9c3eb-27c1-47d1-89fc-8d1a662f06c6",
      "name": "AI Parse Order",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        8144,
        3504
      ]
    },
    {
      "id": "969199f6-771c-4662-a5a4-dd223ed9798b",
      "name": "Claude Haiku",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        8032,
        3680
      ]
    },
    {
      "id": "9660e8dd-aacd-418d-b941-f9caecccbc94",
      "name": "Build Order Response",
      "type": "n8n-nodes-base.code",
      "position": [
        8448,
        3504
      ]
    },
    {
      "id": "9d2a106c-6e29-4ee3-85ff-97a31610581e",
      "name": "Save Order",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        8624,
        3504
      ]
    },
    {
      "id": "486eb607-db75-4ef5-b5dc-9d73b4e9c7e1",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8864,
        3504
      ]
    },
    {
      "id": "8263cbdb-1615-4eb6-aca4-be09ed515d54",
      "name": "Find Order to Cancel",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        8144,
        3792
      ]
    },
    {
      "id": "40e8a6e7-9c83-4fbe-8cd5-5a5f7a9a009b",
      "name": "Validate Cancel",
      "type": "n8n-nodes-base.code",
      "position": [
        8384,
        3792
      ]
    },
    {
      "id": "cdd711a0-62c7-4502-bf33-0bc8a153d279",
      "name": "Can Cancel?",
      "type": "n8n-nodes-base.if",
      "position": [
        8624,
        3792
      ]
    },
    {
      "id": "20d2f37c-e3f2-4287-99d3-e9455c6f5ad2",
      "name": "Mark as Cancelled",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        8864,
        3712
      ]
    },
    {
      "id": "49a0e6bc-c4dc-4e81-ae52-f842ba6a3e5c",
      "name": "Send Cancel Reply",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8864,
        3920
      ]
    },
    {
      "id": "0922b378-6b25-4657-8f07-5d6966d7fd74",
      "name": "Find Order Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        8144,
        4032
      ]
    },
    {
      "id": "f2a8feb2-7bcd-4df2-b10b-ef6dc8dd1cf6",
      "name": "Build Status Reply",
      "type": "n8n-nodes-base.code",
      "position": [
        8384,
        4032
      ]
    },
    {
      "id": "63503809-fd44-4f47-9e30-4d925f834750",
      "name": "Send Status",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8624,
        4032
      ]
    },
    {
      "id": "e57c63eb-94ba-48e9-922f-fb1f3a73b23e",
      "name": "Send Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8144,
        4240
      ]
    },
    {
      "id": "ace66359-2499-4716-8405-85252b0e51c4",
      "name": "Read All Orders",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        8144,
        4400
      ]
    },
    {
      "id": "45aadc39-9aae-4166-b100-76924bcb09b4",
      "name": "Build My Orders",
      "type": "n8n-nodes-base.code",
      "position": [
        8384,
        4400
      ]
    },
    {
      "id": "f1dbb23a-aa98-40f0-b41b-b5cb7edfb421",
      "name": "Send My Orders",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8624,
        4400
      ]
    },
    {
      "id": "2cd124c8-cefa-4bad-abac-d149ecbde775",
      "name": "Send Blocked Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8144,
        4560
      ]
    },
    {
      "id": "ff90e51e-be1b-46e6-8ac1-7bd40e993c7b",
      "name": "Every 1 Minute",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        7072,
        5072
      ]
    },
    {
      "id": "6645a964-f1a8-48c3-9613-d731670735d9",
      "name": "Read All Rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        7520,
        5072
      ]
    },
    {
      "id": "18387888-c225-4294-b150-b1f7fc5a296b",
      "name": "Detect Changed Row",
      "type": "n8n-nodes-base.code",
      "position": [
        7712,
        5072
      ]
    },
    {
      "id": "9a0f7416-4e20-432c-aada-f32e197c73cb",
      "name": "Build Message",
      "type": "n8n-nodes-base.code",
      "position": [
        8048,
        5072
      ]
    },
    {
      "id": "d76b83de-7bfb-4826-a0ea-f15e70c90e32",
      "name": "Send to Customer",
      "type": "n8n-nodes-base.telegram",
      "position": [
        8320,
        5072
      ]
    },
    {
      "id": "7103c954-2c79-4f25-b504-ada9c87b5cbd",
      "name": "Prep Sheet Update",
      "type": "n8n-nodes-base.code",
      "position": [
        8624,
        5072
      ]
    },
    {
      "id": "f77ce233-ea53-4ac2-8996-7f99007fb981",
      "name": "Save Last Status Sent",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8880,
        5072
      ]
    },
    {
      "id": "e054be03-1337-432d-bd9e-bd2c846efd1c",
      "name": "W1 Title",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6496,
        3120
      ],
      "parameters": {
        "width": 804,
        "height": 300,
        "content": "## 🍕 WORKFLOW 1 — Customer Bot\n**Telegram bot for customers to place and manage orders**\n\n**Bot:** @new_nirav_restaurant_bot\n**Sheet:** Restaurant Orders (1_XaI7z844...)\n\n**How it works:**\nCustomer te"
      }
    },
    {
      "id": "a5449eb9-3145-420e-8bb2-b2e0797ab403",
      "name": "Entry Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6496,
        3520
      ],
      "parameters": {
        "width": 972,
        "height": 228,
        "content": "## 📥 Entry Point\nListens to ALL messages from the customer bot.\n\nExtracts: chat_id, text, first_name\nDetects commands: /start, /help, /menu, /myorders, STATUS, CANCEL\nDefault route = **order** (food o"
      }
    },
    {
      "id": "b38ffb11-4d73-4bb8-905e-b590eceb7a8a",
      "name": "Switch Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7504,
        3184
      ],
      "parameters": {
        "width": 260,
        "height": 620,
        "content": "## 🔀 Message Router\nRoutes to one of 8 paths:\n0. /start → Welcome message\n1. /help → Help message\n2. order → AI Parse Order\n3. cancel → Cancel flow\n4. status → Status check\n5. /menu → Menu\n6. /myorder"
      }
    },
    {
      "id": "f5f89365-aeab-4733-9a8c-a9d810d482a1",
      "name": "AI Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7824,
        3440
      ],
      "parameters": {
        "width": 580,
        "height": 328,
        "content": "## 🤖 AI Order Parsing\nUses **Claude Haiku** to parse natural language orders.\n\nInput: \"2 pizza + 1 coke\"\nOutput: \n`{\n\"items\": \"2 Margherita Pizza + 1 Coke\", \n\"valid\": true\n}`\n\nIf not a food order → re"
      }
    },
    {
      "id": "98c8c7aa-2136-40b3-ab1d-ce7615191312",
      "name": "Save Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8592,
        3264
      ],
      "parameters": {
        "width": 476,
        "height": 388,
        "content": "## 💾 Save Order\nAppends new order to Google Sheet with:\n- Queue Number (auto-generated)\n- Chat ID (for later notifications)\n- Name, Order, Status=Pending\n- Order Time, Order Date\n\n⚠️ Column H (Last St"
      }
    },
    {
      "id": "a40ee7cf-998d-4e1a-883a-8896b6cfd8c7",
      "name": "Cancel Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9040,
        3664
      ],
      "parameters": {
        "width": 300,
        "height": 396,
        "content": "## ❌ Cancel Flow\nValidation rules:\n✅ Pending → can cancel\n🚫 Preparing → cannot cancel\n🚫 Ready → cannot cancel\n🚫 Completed → cannot cancel\n🚫 Cancelled → already cancelled\n🚫 Other person's order → block"
      }
    },
    {
      "id": "af8df331-4b48-4e85-a69e-19ab93bd7258",
      "name": "Status Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7584,
        3984
      ],
      "parameters": {
        "width": 1208,
        "height": 176,
        "content": "## 📊 Order Status Check\nCustomer types: STATUS 6771\n→ Looks up Queue Number in sheet\n→ Returns current status with emoji:\n⏳ Pending  👨‍🍳 Preparing\n🍕 Ready   ✅ Completed  ❌ Cancelled"
      }
    },
    {
      "id": "ec51a4e6-05d4-46c7-916a-bfa2ed0472d6",
      "name": "MyOrders Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7584,
        4384
      ],
      "parameters": {
        "width": 1220,
        "height": 178,
        "content": "## 📋 My Orders\nShows last 5 orders for this customer.\nFilters all sheet rows by Chat ID.\nDisplays: queue number, order, status, date"
      }
    },
    {
      "id": "d9f18bfc-369e-47d8-9729-64a4aae7dec3",
      "name": "W2 Title",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6512,
        4752
      ],
      "parameters": {
        "width": 800,
        "height": 220,
        "content": "## 👨‍🍳 WORKFLOW 2 — Staff Status Notifier\n**Auto-notifies customers when staff changes order status in Google Sheet**\n\n**How it works:**\nRuns every minute → reads all rows → compares Status vs Last St"
      }
    },
    {
      "id": "4935ce86-66b7-49b9-8bf5-6251c640adec",
      "name": "Schedule Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6512,
        5024
      ],
      "parameters": {
        "width": 804,
        "height": 236,
        "content": "## ⏱️ Schedule Trigger\nRuns **every 1 minute**.\n\nCannot use Google Sheets trigger\n\nbecause it cannot detect which specific row changed — it always returns row 1."
      }
    },
    {
      "id": "091c7f32-fada-488c-9d5e-b61ce334e276",
      "name": "Detect Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7392,
        4832
      ],
      "parameters": {
        "width": 540,
        "height": 492,
        "content": "## 🔍 Detect Changed Row\n**runOnceForEachItem** — processes every row independently.\n\nLogic per row:\n1. Skip if no Queue Number or Chat ID\n2. Skip if Status = Pending (not notifiable)\n3. Skip if Status"
      }
    },
    {
      "id": "a7cda7e8-8935-4796-8179-c83e77944c66",
      "name": "MsgBuild Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7984,
        4832
      ],
      "parameters": {
        "width": 532,
        "height": 496,
        "content": "## 💬 Message Templates\nBuilds message based on new status:\n👨‍🍳 Preparing → \"Being prepared!\"\n🍕 Ready → \"READY for collection!\"\n✅ Completed → \"Thank you!\"\n❌ Cancelled → \"Order cancelled\""
      }
    },
    {
      "id": "5344c139-6ee8-40d7-83fe-5a53b17fd82d",
      "name": "UpdateH Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8560,
        4832
      ],
      "parameters": {
        "width": 540,
        "height": 488,
        "content": "## 📝 Update Last Status Sent\nWrites current Status into **column H** (Last Status Sent) of the exact row using Google Sheets HTTP API.\n\nThis prevents duplicate notifications — next minute this row wil"
      }
    }
  ],
  "connections": {
    "Save Order": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Can Cancel?": {
      "main": [
        [
          {
            "node": "Mark as Cancelled",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Cancel Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Haiku": {
      "ai_languageModel": [
        [
          {
            "node": "AI Parse Order",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Build Message": {
      "main": [
        [
          {
            "node": "Send to Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read All Rows": {
      "main": [
        [
          {
            "node": "Detect Changed Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Message": {
      "main": [
        [
          {
            "node": "Message Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Parse Order": {
      "main": [
        [
          {
            "node": "Build Order Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every 1 Minute": {
      "main": [
        [
          {
            "node": "Read All Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message Switch": {
      "main": [
        [
          {
            "node": "Send Welcome",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Help",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Parse Order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Find Order to Cancel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Find Order Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Read All Orders",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Blocked Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build My Orders": {
      "main": [
        [
          {
            "node": "Send My Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read All Orders": {
      "main": [
        [
          {
            "node": "Build My Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Cancel": {
      "main": [
        [
          {
            "node": "Can Cancel?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Customer": {
      "main": [
        [
          {
            "node": "Prep Sheet Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Order Status": {
      "main": [
        [
          {
            "node": "Build Status Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark as Cancelled": {
      "main": [
        [
          {
            "node": "Send Cancel Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prep Sheet Update": {
      "main": [
        [
          {
            "node": "Save Last Status Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Status Reply": {
      "main": [
        [
          {
            "node": "Send Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Changed Row": {
      "main": [
        [
          {
            "node": "Build Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Order Response": {
      "main": [
        [
          {
            "node": "Save Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Order to Cancel": {
      "main": [
        [
          {
            "node": "Validate Cancel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Customer Bot Listener": {
      "main": [
        [
          {
            "node": "Route Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}