{
  "name": "Recipe Labs - Daily Briefing (8AM)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "id": "cron-8am",
      "name": "Every Day 8AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "http://localhost:3004/api/pipeline-stats",
        "options": {}
      },
      "id": "get-stats",
      "name": "Get Pipeline Stats",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "http://localhost:3004/api/leads?status=new&limit=5",
        "options": {}
      },
      "id": "get-new-leads",
      "name": "Get New Leads",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        450
      ]
    },
    {
      "parameters": {
        "mode": "combine",
        "mergeByFields": {
          "values": []
        },
        "options": {}
      },
      "id": "merge-data",
      "name": "Merge Data",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        650,
        375
      ]
    },
    {
      "parameters": {
        "jsCode": "// Build daily briefing message\nconst stats = $input.first().json;\nconst leads = $input.all().slice(1);\n\nconst today = new Date().toLocaleDateString('en-US', { \n  weekday: 'long', \n  year: 'numeric', \n  month: 'long', \n  day: 'numeric' \n});\n\nconst newLeadsList = leads.length > 0 \n  ? leads.map(l => `\u2022 ${l.json.name} (${l.json.company || 'N/A'})`).join('\\n')\n  : '\u2022 No new leads yesterday';\n\nconst briefing = {\n  text: `\u2600\ufe0f Recipe Labs Daily Briefing - ${today}`,\n  attachments: [{\n    color: '#f39c12',\n    blocks: [\n      {\n        type: 'header',\n        text: {\n          type: 'plain_text',\n          text: `\u2600\ufe0f Daily Briefing - ${today}`\n        }\n      },\n      {\n        type: 'section',\n        fields: [\n          {\n            type: 'mrkdwn',\n            text: `*\ud83d\udcca Pipeline Total*\\n${stats.total || 0} leads`\n          },\n          {\n            type: 'mrkdwn',\n            text: `*\ud83c\udd95 New Leads*\\n${stats.byStatus?.new || 0}`\n          },\n          {\n            type: 'mrkdwn',\n            text: `*\ud83d\udcde Contacted*\\n${stats.byStatus?.contacted || 0}`\n          },\n          {\n            type: 'mrkdwn',\n            text: `*\u2705 Qualified*\\n${stats.byStatus?.qualified || 0}`\n          }\n        ]\n      },\n      {\n        type: 'section',\n        text: {\n          type: 'mrkdwn',\n          text: `*\ud83d\udd25 Hot Leads (Score 80+)*\\n${stats.highScoreCount || 0} leads ready for outreach`\n        }\n      },\n      {\n        type: 'divider'\n      },\n      {\n        type: 'section',\n        text: {\n          type: 'mrkdwn',\n          text: `*\ud83d\udce5 Recent New Leads*\\n${newLeadsList}`\n        }\n      },\n      {\n        type: 'context',\n        elements: [{\n          type: 'mrkdwn',\n          text: '\ud83e\udd16 Generated by Recipe Labs AI | <http://72.61.72.94:3004|Open Dashboard>'\n        }]\n      }\n    ]\n  }]\n};\n\nreturn [{ json: briefing }];"
      },
      "id": "build-briefing",
      "name": "Build Briefing Message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        850,
        375
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.SLACK_WEBHOOK_DAILY_BRIEFING }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json }}",
        "options": {}
      },
      "id": "send-briefing",
      "name": "Send to #daily-briefing",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1050,
        375
      ]
    }
  ],
  "connections": {
    "Every Day 8AM": {
      "main": [
        [
          {
            "node": "Get Pipeline Stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get New Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Pipeline Stats": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get New Leads": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Data": {
      "main": [
        [
          {
            "node": "Build Briefing Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Briefing Message": {
      "main": [
        [
          {
            "node": "Send to #daily-briefing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/New_York"
  },
  "tags": [
    "daily",
    "briefing",
    "slack",
    "scheduled"
  ]
}