{
  "name": "[Growth] Goal Agent",
  "nodes": [
    {
      "parameters": {
        "content": "## [Growth] Goal Agent Cycle\n\n**WHAT IT IS**\nDaily 9 AM proactive experiment loop. 4 phases: HYPOTHESIZE (generate ideas) \u2192 EXPERIMENT (select cohorts, queue SMS) \u2192 MEASURE (check 72h conversions) \u2192 HARVEST (proven experiments \u2192 discovered_signals).\n\n**WHAT IT SOLVES**\nAutomates the full A/B testing cycle for contact engagement. Without this, experiment design and measurement would require manual SQL and analysis. Goal: 100% repeat order rate.\n\n**WHAT'S NEXT**\n- Auto-pause experiments showing negative conversion lift early\n- Publish weekly harvest summary to Slack",
        "height": 340,
        "width": 600,
        "color": 4
      },
      "id": "workflow-overview-note",
      "name": "\ud83d\udccb Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        80,
        -100
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Daily at 9 AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        100,
        300
      ],
      "notes": "Cron: runs after daily reports (8:30 AM) so fresh data is available for measurement."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://dabbahwala-latest.onrender.com/api/goal-agent/run",
        "options": {
          "timeout": 300000
        }
      },
      "id": "run-goal-agent",
      "name": "Run Goal Agent Full Cycle",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        320,
        300
      ],
      "notes": "POST /api/agents/goal-cycle \u2014 4-phase HYPOTHESIZE\u2192EXPERIMENT\u2192MEASURE\u2192HARVEST loop; returns experiment stats and new signals."
    },
    {
      "parameters": {
        "jsCode": "// Log the result summary\nconst result = $('Run Goal Agent Full Cycle').first().json;\nreturn [{\n  json: {\n    timestamp: result.timestamp,\n    phase: result.phase,\n    experiments_created: result.experiments_created,\n    experiments_started: result.experiments_started,\n    contacts_enrolled: result.contacts_enrolled,\n    experiments_concluded: result.experiments_concluded,\n    signals_discovered: result.signals_discovered,\n    orders_attributed: result.orders_attributed,\n    summary: `Goal Agent: +${result.experiments_created} new experiments, ${result.contacts_enrolled} contacts enrolled, ${result.experiments_concluded} concluded, ${result.signals_discovered} signals discovered`\n  }\n}];"
      },
      "id": "log-result",
      "name": "Log Result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        540,
        300
      ],
      "notes": "JS: logs phase-by-phase stats (hypotheses generated, experiments launched, conversions measured, signals harvested)."
    }
  ],
  "connections": {
    "Daily at 9 AM": {
      "main": [
        [
          {
            "node": "Run Goal Agent Full Cycle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Goal Agent Full Cycle": {
      "main": [
        [
          {
            "node": "Log Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  }
}