{
  "name": "Mawidi Daily SEO Intelligence Workflow",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24,
              "triggerAtHour": 7
            }
          ]
        }
      },
      "name": "Schedule Trigger (7 AM Daily)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [250, 300]
    },
    {
      "parameters": {
        "url": "https://www.google.com/search?q=google+algorithm+update+{{$now.format('MMMM')}}+{{$now.format('YYYY')}}",
        "options": {}
      },
      "name": "Fetch Algorithm News",
      "type": "n8n-nodes-base.httpRequest",
      "position": [450, 200]
    },
    {
      "parameters": {
        "url": "https://www.google.com/search?q=healthcare+seo+trends+{{$now.format('YYYY')}}",
        "options": {}
      },
      "name": "Fetch Healthcare SEO News",
      "type": "n8n-nodes-base.httpRequest",
      "position": [450, 400]
    },
    {
      "parameters": {
        "command": "cd /Users/Asim/Desktop/mawidi_codex/mawidi-site && npx lighthouse http://localhost:9000/en --output=json --chrome-flags=\"--headless\" | jq '.categories.seo.score'"
      },
      "name": "Run Lighthouse SEO Audit",
      "type": "n8n-nodes-base.executeCommand",
      "position": [650, 300]
    },
    {
      "parameters": {
        "command": "cd /Users/Asim/Desktop/mawidi_codex && claude --print '/seo-monitor trends'"
      },
      "name": "Run Claude SEO Agent",
      "type": "n8n-nodes-base.executeCommand",
      "position": [850, 300]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": "YOUR_GOOGLE_SHEET_ID",
        "sheetName": "SEO Tracking",
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "date": "={{$now.format('YYYY-MM-DD')}}",
            "lighthouse_score": "={{$node['Run Lighthouse SEO Audit'].json.score}}",
            "algorithm_updates": "={{$node['Fetch Algorithm News'].json.summary}}",
            "actions_taken": "={{$node['Run Claude SEO Agent'].json.output}}"
          }
        }
      },
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [1050, 200]
    },
    {
      "parameters": {
        "channel": "#seo-alerts",
        "text": "=Daily SEO Report\n\nDate: {{$now.format('YYYY-MM-DD')}}\nLighthouse Score: {{$node['Run Lighthouse SEO Audit'].json.score}}\n\nAlgorithm Updates: {{$node['Fetch Algorithm News'].json.summary}}\n\nRecommended Actions:\n{{$node['Run Claude SEO Agent'].json.output}}"
      },
      "name": "Slack Notification",
      "type": "n8n-nodes-base.slack",
      "position": [1050, 400]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$node['Run Lighthouse SEO Audit'].json.score}}",
              "operation": "smaller",
              "value2": 0.7
            }
          ]
        }
      },
      "name": "Check Score Threshold",
      "type": "n8n-nodes-base.if",
      "position": [850, 500]
    },
    {
      "parameters": {
        "fromEmail": "seo-bot@mawidi.com",
        "toEmail": "team@mawidi.com",
        "subject": "SEO ALERT: Score Below Threshold",
        "text": "SEO score has dropped below 70%. Immediate attention required.\n\nCurrent Score: {{$node['Run Lighthouse SEO Audit'].json.score}}\n\nPlease review the daily report in Google Sheets."
      },
      "name": "Send Alert Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [1050, 550]
    }
  ],
  "connections": {
    "Schedule Trigger (7 AM Daily)": {
      "main": [
        [
          {"node": "Fetch Algorithm News", "type": "main", "index": 0},
          {"node": "Fetch Healthcare SEO News", "type": "main", "index": 0},
          {"node": "Run Lighthouse SEO Audit", "type": "main", "index": 0}
        ]
      ]
    },
    "Run Lighthouse SEO Audit": {
      "main": [
        [
          {"node": "Run Claude SEO Agent", "type": "main", "index": 0},
          {"node": "Check Score Threshold", "type": "main", "index": 0}
        ]
      ]
    },
    "Run Claude SEO Agent": {
      "main": [
        [
          {"node": "Log to Google Sheets", "type": "main", "index": 0},
          {"node": "Slack Notification", "type": "main", "index": 0}
        ]
      ]
    },
    "Check Score Threshold": {
      "main": [
        [
          {"node": "Send Alert Email", "type": "main", "index": 0}
        ]
      ]
    }
  },
  "settings": {
    "timezone": "Asia/Riyadh",
    "saveExecutionProgress": true,
    "saveManualExecutions": true
  }
}
