{
  "name": "Weekly Sales Report Generator",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "daysOfTheWeek": [
                1
              ],
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "878af667-b549-4ee2-a79a-d5750e4a9dba",
      "name": "Every Monday 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://{{$env.SHOPIFY_STORE}}.myshopify.com/admin/api/2024-01/orders.json?status=any&created_at_min={{$today.minus(7,'days').toISO()}}",
        "authentication": "genericCredentialType"
      },
      "id": "01f82cec-2882-43bb-8055-205cefd928a3",
      "name": "Get Shopify Orders",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        460,
        220
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://graph.facebook.com/v18.0/act_{{$env.META_ACCOUNT_ID}}/insights?fields=spend,impressions,clicks&date_preset=last_7d",
        "authentication": "genericCredentialType"
      },
      "id": "c90f1215-c354-453e-9eaf-f11e7490a7d5",
      "name": "Get Ad Spend",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        460,
        380
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "report_html",
              "value": "<h2>Weekly Report</h2><p>Orders: {{$node['Get Shopify Orders'].json.orders.length}}</p><p>Ad Spend: ${{$node['Get Ad Spend'].json.data[0].spend}}</p>"
            }
          ]
        }
      },
      "id": "282bfbe5-7d61-4aac-ab18-22fc79dceaad",
      "name": "Build Report",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "operation": "send",
        "to": "={{$env.REPORT_RECIPIENTS}}",
        "subject": "Weekly Report \u2014 {{$today.toFormat('dd MMM yyyy')}}",
        "message": "={{$json.report_html}}"
      },
      "id": "7b4cb540-b053-4f2d-bc1b-074f04bc9ce5",
      "name": "Email Report",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    }
  ],
  "connections": {
    "Every Monday 7am": {
      "main": [
        [
          {
            "node": "Get Shopify Orders",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Ad Spend",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Shopify Orders": {
      "main": [
        [
          {
            "node": "Build Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ad Spend": {
      "main": [
        [
          {
            "node": "Build Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Report": {
      "main": [
        [
          {
            "node": "Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}