{
 "name": "Weekly newsletter draft from blog RSS with AI, left unsent in Mailchimp (AutomateRecipes)",
 "nodes": [
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "field": "cronExpression",
       "expression": "0 9 * * 1"
      }
     ]
    }
   },
   "id": "e0855dae-3fb2-5cfd-a3b1-a7ff6222f362",
   "name": "Every Monday 9:00",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    0,
    0
   ]
  },
  {
   "parameters": {
    "url": "https://YOUR_BLOG/feed",
    "options": {}
   },
   "id": "37b05585-56d9-5da7-acad-7f334c8aca67",
   "name": "RSS: read blog feed",
   "type": "n8n-nodes-base.rssFeedRead",
   "typeVersion": 1.1,
   "position": [
    220,
    0
   ]
  },
  {
   "parameters": {
    "jsCode": "const since=Date.now()-7*864e5;\nconst posts=$input.all().map(i=>i.json).filter(p=>new Date(p.isoDate||p.pubDate).getTime()>=since);\nif(!posts.length) return [];\nreturn [{json:{posts:posts.map(p=>`- ${p.title}\\n  ${p.link}\\n  ${(p.contentSnippet||'').slice(0,300)}`).join('\\n')}}];"
   },
   "id": "751423e2-ac66-5683-8e8d-1a9cf002cbe0",
   "name": "Last 7 days, combined",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    440,
    0
   ]
  },
  {
   "parameters": {
    "method": "POST",
    "url": "https://api.openai.com/v1/chat/completions",
    "authentication": "predefinedCredentialType",
    "nodeCredentialType": "openAiApi",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify({model:'gpt-4o-mini',messages:[{role:'system',content:'Write a short friendly newsletter in simple HTML: an intro paragraph, then one 2-sentence blurb with link per post. Use only the posts given.'},{role:'user',content:$json.posts}]}) }}",
    "options": {}
   },
   "id": "559190f6-c18c-56fb-b5b8-f5ff3b4500a2",
   "name": "OpenAI: write newsletter",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    660,
    0
   ],
   "credentials": {
    "openAiApi": {
     "id": "",
     "name": "YOUR_OPENAIAPI_CREDENTIAL"
    }
   }
  },
  {
   "parameters": {
    "method": "POST",
    "url": "https://YOUR_DC.api.mailchimp.com/3.0/campaigns",
    "authentication": "predefinedCredentialType",
    "nodeCredentialType": "mailchimpApi",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify({type:'regular',recipients:{list_id:'YOUR_AUDIENCE_ID'},settings:{subject_line:'This week on the blog',from_name:'YOUR_NAME',reply_to:'YOUR_EMAIL@example.com'}}) }}",
    "options": {}
   },
   "id": "c42c1350-2c7a-5104-8ae6-0ec126b3d335",
   "name": "Mailchimp: create campaign",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    880,
    0
   ],
   "credentials": {
    "mailchimpApi": {
     "id": "",
     "name": "YOUR_MAILCHIMPAPI_CREDENTIAL"
    }
   }
  },
  {
   "parameters": {
    "method": "PUT",
    "url": "=https://YOUR_DC.api.mailchimp.com/3.0/campaigns/{{ $json.id }}/content",
    "authentication": "predefinedCredentialType",
    "nodeCredentialType": "mailchimpApi",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify({html:$('OpenAI: write newsletter').item.json.choices[0].message.content}) }}",
    "options": {}
   },
   "id": "fce7c336-3ca4-5dee-a1e1-9aa4545fe326",
   "name": "Mailchimp: set content (unsent)",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    1100,
    0
   ],
   "credentials": {
    "mailchimpApi": {
     "id": "",
     "name": "YOUR_MAILCHIMPAPI_CREDENTIAL"
    }
   }
  }
 ],
 "connections": {
  "Every Monday 9:00": {
   "main": [
    [
     {
      "node": "RSS: read blog feed",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "RSS: read blog feed": {
   "main": [
    [
     {
      "node": "Last 7 days, combined",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Last 7 days, combined": {
   "main": [
    [
     {
      "node": "OpenAI: write newsletter",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "OpenAI: write newsletter": {
   "main": [
    [
     {
      "node": "Mailchimp: create campaign",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Mailchimp: create campaign": {
   "main": [
    [
     {
      "node": "Mailchimp: set content (unsent)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "active": false,
 "pinData": {},
 "meta": {
  "note": "Replace YOUR_* placeholders and attach your own credentials. Not tested on real services."
 }
}