Project: Order-to-Invoice Automation Objective: Automate wholesale packaging orders via WhatsApp, utilizing AI for parsing and Xero for financial management, with a strict human-in-the-loop approval process. Step 1: The Intake & Selection (WhatsApp) Trigger: WhatsApp Business Webhook. Working Hours Filter: Checks if the time is within Mon-Fri 10am–6pm or Sat 10am–4pm. If Outside: Auto-reply with warehouse opening hours. If Inside: Proceed. Interactive Menu (The "Catalog"): * n8n sends a List Message (e.g., Polymailers, Boxes, Tapes). n8n follows up with Reply Buttons for specific sizes (e.g., 25x35cm, 32x45cm). n8n asks for Quantity. Step 2: The AI Processing & Xero Draft AI Agent Node: Takes the customer selections and identifies the correct Xero Item Code and Contact ID. Xero Node (Action): Create Quotation. Status: Draft. Data: Line items, quantities, and customer details. PDF Generation: n8n calls Xero API to fetch the Quotation PDF as binary data. Step 3: Management Approval (Human-in-the-Loop) Notification: n8n sends the Quotation PDF to the Management WhatsApp. Wait Node: Workflow pauses for a reply. Logic Branching: A. Management says "Yes": * n8n converts Quote to Invoice in Xero. n8n sends the Invoice PDF to the customer via WhatsApp. B. Management says "No" + Feedback: AI Agent parses feedback (e.g., "Give 5% discount" or "Change size to 17x30cm"). Xero Node updates the Quotation. Loop: n8n sends the new PDF back to Management for approval. C. Vague "No": n8n alerts staff that manual intervention is required. Critical Safety Rules Fresh Data Check: The AI must check the current Xero invoice status seconds before sending a payment reminder to avoid "false" nagging. Product Sync: The n8n "List" items must match the Item Codes inside Xero exactly to prevent sync errors. Renaming PDFs: All files sent via WhatsApp should be renamed to Quote_[No].pdf for professionalism.