{
  "name": "Jack & Blaze \u2014 Sunday Review",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 18 * * 0"
            }
          ]
        }
      },
      "name": "Sunday 6pm UTC",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://slack.com/api/conversations.history",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "json",
        "body": {
          "channel": "C0ASCP8L398",
          "oldest": "={{ Math.floor((Date.now() - 7 * 24 * 60 * 60 * 1000) / 1000) }}",
          "limit": 100
        }
      },
      "name": "Fetch Slack History",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        400
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const messages = $input.item.json.messages || [];\n\n// Extract approval signals from reactions\nconst signals = messages.map(m => ({\n  text: (m.text || '').slice(0, 200),\n  reactions: (m.reactions || []).map(r => r.name),\n  replies: m.reply_count || 0,\n  edited: !!m.edited\n}));\n\nconst approved = signals.filter(m => m.reactions.includes('white_check_mark')).length;\nconst rejected = signals.filter(m => m.reactions.includes('x')).length;\nconst edited   = signals.filter(m => m.edited).length;\n\nreturn {\n  total_messages: messages.length,\n  approved,\n  rejected,\n  edited,\n  auto_approved: Math.max(0, 7 - approved - rejected),\n  signals_json: JSON.stringify(signals.slice(0, 20))\n};"
      },
      "name": "Parse Approval Signals",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.anthropic.com/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            },
            {
              "name": "x-api-key",
              "value": "={{$credentials.httpHeaderAuth.value}}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "body": {
          "model": "claude-sonnet-4-20250514",
          "max_tokens": 2000,
          "messages": [
            {
              "role": "user",
              "content": "={{ 'You are the Sunday Reviewer for Leslie W.E. Walters\\' Jack & Blaze author pipeline.\\n\\nAnalyze this week\\'s performance and write specific guidance for next week.\\n\\nWEEK STATS:\\n- Posts sent to Slack: ' + $json.total_messages + '\\n- Approved by Leslie: ' + $json.approved + '\\n- Rejected: ' + $json.rejected + '\\n- Edited: ' + $json.edited + '\\n- Auto-approved (no response): ' + $json.auto_approved + '\\n\\nSLACK MESSAGE SIGNALS (what was posted/discussed):\\n' + $json.signals_json + '\\n\\nAUTHOR CONTEXT:\\n- Leslie W.E. Walters, YA Fantasy & poetry author\\n- Book: Jack and Blaze (payhip.com/LeslieweWalters)\\n- Handles: @leswalters_ (IG/TikTok), @elmo086 (Twitter/X), @lesliew.e.walters (YouTube)\\n- Voice: fierce, warm, emotionally deep\\n\\nWrite a Sunday review with:\\n1. What worked this week (be specific)\\n2. What did not work (rejections/edits signal this)\\n3. Guidance for next week\\'s content-generator (what angle, tone, themes)\\n4. Guidance for blog posts (which topics to cover)\\n5. Visual direction for images (which design style to lean into)\\n6. Friday post type to use next week\\n7. Hashtag refresh suggestions\\n\\nBe specific and actionable. This review feeds directly into Monday\\'s content generation.' }}"
            }
          ]
        }
      },
      "name": "Claude Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        400
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://slack.com/api/chat.postMessage",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "json",
        "body": {
          "channel": "C0ASCP8L398",
          "text": "={{ '\ud83d\udcca *Sunday Review \u2014 Week of ' + new Date().toISOString().split('T')[0] + '*\\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\\n\u2705 Approved: ' + $('Parse Approval Signals').item.json.approved + ' \u00b7 \u274c Rejected: ' + $('Parse Approval Signals').item.json.rejected + ' \u00b7 \ud83e\udd16 Auto-approved: ' + $('Parse Approval Signals').item.json.auto_approved + '\\n\\n' + $json.content[0].text + '\\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\\nAll agents briefed for Monday. See you then! \ud83d\udd25' }}"
        }
      },
      "name": "Post Review to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        400
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Sunday 6pm UTC": {
      "main": [
        [
          {
            "node": "Fetch Slack History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Slack History": {
      "main": [
        [
          {
            "node": "Parse Approval Signals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Approval Signals": {
      "main": [
        [
          {
            "node": "Claude Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Analysis": {
      "main": [
        [
          {
            "node": "Post Review to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "jack-and-blaze"
    },
    {
      "name": "sunday"
    }
  ]
}