{
  "name": "Send sales forecast charts and answer Q&A on WhatsApp with OpenAI",
  "nodes": [
    {
      "id": "6a05f550-9612-4ecc-9439-92194df42c22",
      "name": "Monthly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -928,
        784
      ]
    },
    {
      "id": "1d400ae4-4b7f-4ec0-b8fb-51675e94521c",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        384,
        976
      ]
    },
    {
      "id": "f884c524-4a97-45fa-ad2f-bf21592b63b6",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -752,
        784
      ]
    },
    {
      "id": "63b081c2-8a77-48e7-988d-dea5183162cf",
      "name": "Forecast Engine",
      "type": "n8n-nodes-base.code",
      "position": [
        -128,
        784
      ]
    },
    {
      "id": "492ffd7e-204b-4efc-9504-8c881b15e808",
      "name": "Data Cleaning",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        784
      ]
    },
    {
      "id": "91e7c95e-b0c3-432b-9a1e-c1ce95ab28ef",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        160,
        976
      ]
    },
    {
      "id": "f513b665-26c8-4297-988e-368a8883a1e2",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        464,
        1632
      ]
    },
    {
      "id": "c484ca60-b162-4bc1-bba9-e65fa0299236",
      "name": "Q&A AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        496,
        1376
      ]
    },
    {
      "id": "d920386c-40b1-4f80-9ee4-ffb7a0aba30c",
      "name": "Normalize Whatsapp Input",
      "type": "n8n-nodes-base.set",
      "position": [
        -144,
        1376
      ]
    },
    {
      "id": "8878ba94-af04-4331-80a1-e86da10aa423",
      "name": "Q&A Message",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        800,
        1376
      ]
    },
    {
      "id": "ad26c654-567d-4f12-b2ac-ee08dfaef020",
      "name": "Get Sales Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -560,
        784
      ]
    },
    {
      "id": "15859013-73a8-40ce-9a19-23b2ad67bdc0",
      "name": "QuickChart",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        784
      ]
    },
    {
      "id": "2d969ee0-70f1-467d-bb25-55fb58ea6f76",
      "name": "Upsert Latest Forecast",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1248,
        672
      ]
    },
    {
      "id": "ccfe9476-d0d9-44b7-bea9-fd1912ae9ea7",
      "name": "Get Latest Forecast",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        80,
        1376
      ]
    },
    {
      "id": "a4ef98c6-2055-49a4-ae4e-0d99fbe5040b",
      "name": "Parsing Input",
      "type": "n8n-nodes-base.code",
      "position": [
        304,
        1376
      ]
    },
    {
      "id": "96ad6de4-4551-4f14-8f00-cd88e1033bb4",
      "name": "WhatsApp Trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -528,
        1392
      ]
    },
    {
      "id": "86c29b81-b78d-4fb8-b2a7-ec5905dff0bb",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        -112
      ],
      "parameters": {
        "width": 1376,
        "height": 608,
        "content": "## How It Works \n***Top Branch Workflow***\n\n**1. The Data Scientist:** \n   - **Ingest:** Pulls historical sales data from Google Sheets.\n   - **Math Engine:** Runs 7 statistical algorithms (e.g., Seas"
      }
    },
    {
      "id": "6d5564ae-4e40-4a02-8b06-278cb7ddea86",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        336
      ],
      "parameters": {
        "width": 368,
        "height": 96,
        "content": "## Prerequisites\nData: At least 12 periods of historical sales data."
      }
    },
    {
      "id": "81dd5053-bbca-4b21-8757-844d770d0af6",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -112
      ],
      "parameters": {
        "width": 992,
        "height": 416,
        "content": "## Use Cases & Benefits\n**Business Owners:** \nGain enterprise-grade forecasting on autopilot. Always have a sophisticated financial outlook running in the background 24/7.\n\n**Sales Leaders:** \nGet imm"
      }
    },
    {
      "id": "594c9672-202b-4b4b-921e-20251df60552",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        528
      ],
      "parameters": {
        "width": 736,
        "height": 656,
        "content": "## 1. Data Pipeline\n**ETL & Normalization** Fetches raw Google Sheets data and normalizes formats to ensure the statistical engine receives clean inputs."
      }
    },
    {
      "id": "6e719e61-b625-477f-ac99-464bf192d377",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        528
      ],
      "parameters": {
        "width": 288,
        "height": 656,
        "content": "## 2. Forecasting\n**Statistical Tournament** Runs 7 distinct models (Seasonal Regression, Exp Smoothing, Moving Avg, etc.). It performs a rolling backtest to calculate RMSE & MAPE, strictly selecting "
      }
    },
    {
      "id": "eda9e598-4b70-4793-a08b-092a933bb820",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        528
      ],
      "parameters": {
        "width": 1008,
        "height": 656,
        "content": "## 3. AI Intelligence & Visualization\n**Synthesis & Rendering** The AI interprets the math into a business narrative, while QuickChart renders the data points into a visual trend graph PNG."
      }
    },
    {
      "id": "84485933-8556-442e-ad7b-209bf8350ed0",
      "name": "Analyst AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        208,
        784
      ]
    },
    {
      "id": "dec6aeb6-ae13-4abf-a4b1-4884ebf755a6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        528
      ],
      "parameters": {
        "width": 288,
        "height": 656,
        "content": "## 4. Delivery & Storage\n**Notification System** Saves the forecast context to the database for future reference and pushes the final Report + Chart to WhatsApp."
      }
    },
    {
      "id": "9425a977-d1cd-42a1-bd46-aa2d06a0d262",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        1248
      ],
      "parameters": {
        "width": 1664,
        "height": 560,
        "content": "## 5. Follow-Up Q&A with Sales Forecast AI Agent \n**Data Consultant** Retrieves the stored forecast data to answer user questions, acting as an on-demand analyst with full knowledge of the report."
      }
    },
    {
      "id": "6d207b4b-4960-4a4e-ac45-4c05b75f37bf",
      "name": "Format AI Output",
      "type": "n8n-nodes-base.set",
      "position": [
        528,
        784
      ]
    },
    {
      "id": "9497eaf3-d9ef-42ab-873b-4305daadf8ee",
      "name": "Filter Text Messages",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        1392
      ]
    },
    {
      "id": "824dbfe8-bfb1-4083-9268-9817dcc73397",
      "name": "Combine Data for Chart",
      "type": "n8n-nodes-base.merge",
      "position": [
        640,
        976
      ]
    },
    {
      "id": "b3597f68-b5d2-406b-b87b-bc6b2e3f3f7a",
      "name": "Send WhatsApp Report",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1248,
        928
      ]
    },
    {
      "id": "5fafef97-73b1-400c-a397-fef285ef9046",
      "name": "Prepare Chart Config",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        784
      ]
    },
    {
      "id": "29b1ae06-e5f4-464f-9ff7-f08c52acfae2",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        624,
        1632
      ]
    }
  ],
  "connections": {
    "QuickChart": {
      "main": [
        [
          {
            "node": "Upsert Latest Forecast",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send WhatsApp Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Q&A AI Agent": {
      "main": [
        [
          {
            "node": "Q&A Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Cleaning": {
      "main": [
        [
          {
            "node": "Combine Data for Chart",
            "type": "main",
            "index": 1
          },
          {
            "node": "Forecast Engine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parsing Input": {
      "main": [
        [
          {
            "node": "Q&A AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Q&A AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Get Sales Data": {
      "main": [
        [
          {
            "node": "Data Cleaning",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Forecast Engine": {
      "main": [
        [
          {
            "node": "Analyst AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyst AI Agent": {
      "main": [
        [
          {
            "node": "Format AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Output": {
      "main": [
        [
          {
            "node": "Combine Data for Chart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly Schedule": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Filter Text Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Analyst AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Q&A AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Latest Forecast": {
      "main": [
        [
          {
            "node": "Parsing Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Text Messages": {
      "main": [
        [
          {
            "node": "Normalize Whatsapp Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Chart Config": {
      "main": [
        [
          {
            "node": "QuickChart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Data for Chart": {
      "main": [
        [
          {
            "node": "Prepare Chart Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Latest Forecast": {
      "main": [
        []
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Get Sales Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Whatsapp Input": {
      "main": [
        [
          {
            "node": "Get Latest Forecast",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyst AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}