{
  "name": "News Agent",
  "nodes": [
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "id": "c055762a-8fe7-4141-a639-df2372f30060",
      "typeVersion": 1.1,
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        224,
        352
      ]
    },
    {
      "parameters": {
        "url": "https://rss.app/feeds/rNKraHS1woRZdob6.xml",
        "options": {}
      },
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1.2,
      "position": [
        448,
        352
      ],
      "id": "b1a3be3c-0df4-4d68-9979-75f320a52155",
      "name": "BBC RSS Read"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9f165a78-40bb-4642-bde3-9ee157a085cb",
              "name": "url",
              "value": "={{ $json.link }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        672,
        352
      ],
      "id": "89caa6fa-86a0-4e3d-94f6-f9659eca3af6",
      "name": "Extract URLs"
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "triggerCollectionByUrl",
        "dataset_id": {
          "__rl": true,
          "value": "gd_ly5lkfzd1h8c85feyh",
          "mode": "list",
          "cachedResultName": "BBC news"
        },
        "urls": "={{ $json.data.toJsonString() }}",
        "requestOptions": {}
      },
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "typeVersion": 1,
      "position": [
        1136,
        352
      ],
      "id": "99f60b01-d6df-4bd2-9982-66f9be7534c6",
      "name": "Initiate batch extraction from URL",
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        928,
        352
      ],
      "id": "859dfe27-7af9-4845-922b-b410820015f5",
      "name": "Aggregate URLs to Single Object"
    },
    {
      "parameters": {
        "options": {
          "reset": true
        }
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1344,
        352
      ],
      "id": "771536a7-75fb-4136-8233-4b2c0c183325",
      "name": "Loop Over Items"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "name": "Check Snapshot Again for Success",
      "typeVersion": 1,
      "position": [
        2576,
        512
      ],
      "id": "0e8fbf99-c03b-4c80-bf1d-e4ff4ee46136"
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "monitorProgressSnapshot",
        "snapshot_id": "={{ $json.snapshot_id }}",
        "requestOptions": {}
      },
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "typeVersion": 1,
      "position": [
        1632,
        448
      ],
      "id": "c9e4e68c-9937-46d4-a8b5-a9dfef9adf96",
      "name": "Check the status of a batch extraction",
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c5b87e28-315a-4ac5-a30d-44b47de2c528",
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1920,
        448
      ],
      "id": "81b224dd-5188-4be3-87f6-bd7586ed0cdb",
      "name": "Check if Batch Ready"
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "downloadSnapshot",
        "snapshot_id": "={{ $json.snapshot_id }}",
        "requestOptions": {}
      },
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "typeVersion": 1,
      "position": [
        2256,
        288
      ],
      "id": "ef5d5334-c1b6-443a-b379-dd667f3d8c1b",
      "name": "Download the snapshot content",
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## BBC news Data\n** Timestamp is present here",
        "height": 272,
        "width": 288
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        192
      ],
      "typeVersion": 1,
      "id": "497c9544-6065-487c-b040-3e59b83443b9",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4fabcded-c3b7-465c-8204-0901e5720e56",
              "name": "headline",
              "value": "={{ $json.headline }}",
              "type": "string"
            },
            {
              "id": "51619bc0-036b-4591-b968-c47208857774",
              "name": "content",
              "value": "={{ $json.content }}",
              "type": "string"
            },
            {
              "id": "8bc62f80-06d0-4000-803a-451dd0e3f3e7",
              "name": "url",
              "value": "={{ $json.url }}",
              "type": "string"
            },
            {
              "id": "40340ee0-7009-4974-89e2-1decee725702",
              "name": "id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "3202cc27-58a1-4aba-893e-86ba325d5c6c",
              "name": "timestamp",
              "value": "={{ $json.timestamp }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2576,
        288
      ],
      "id": "8546d846-c424-4658-862d-c39e52b4567c",
      "name": "Extract Essential Data"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "211d2d0e-d7f7-4e2d-85ca-45c3c4ed46b4",
              "name": "postdata",
              "value": "=Headline:  {{ $json.headline }}\nContent: {{ $json.content }}\nURL: {{ $json.url }}\nTimestamp: {{ $json.timestamp }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2784,
        288
      ],
      "id": "65cb00a9-6162-4dff-a9df-48cf63a92f2e",
      "name": "Reduce Objects to 1"
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "postdata"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        2992,
        288
      ],
      "id": "adde66b3-9b7b-4fbf-991d-5c16f359f08e",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.postdata.join('\\n\\n') }}",
        "options": {
          "systemMessage": "You are an expert newsletter editor tasked with transforming BBC news posts into a witty, engaging, and concise \"Morning Brew\"\u2013style daily email newsletter.  \n\n### Goals:\n- Summarize each BBC post into a **2\u20134 sentence punchy blurb**.  \n- Add light personality, wit, or conversational tone (like Morning Brew).  \n- Ensure summaries are factual but not overly formal.  \n- Always include the **headline** as a clickable link to the original BBC article.  \n- Organize the newsletter into sections (e.g., \"\u26bd Sports\", \"\ud83c\udf0d World\", \"\ud83d\udcc8 Business\", \"\ud83c\udfad Culture\") depending on article content.  \n- Use **HTML email-safe formatting** (simple tables, inline styles, no external CSS/JS).  \n- Add a short **intro paragraph** (\"Good morning! Here\u2019s your BBC news brew \u2615\") and a closing line (\"That\u2019s your brew for today \u2014 see you tomorrow!\").  \n\n### Input:\nYou will receive an array of JSON objects. Each object contains:\n- `Headline`\n- `Content`\n- `URL`\n- `Timestamp`\n\n### Output:\nReturn **two things**:\n1. **Subject line** (plain text) \u2192 e.g., `Subject: Liverpool's \u00a335m Bid + Djokovic Survives`\n2. **HTML email body** \u2192 use the template below with clean, modern styling.  \n\nReturn the output in the following JSON format:  \n\n```json\n{\n  \"subject\": \"<subject line here>\",\n  \"html_content\": \"<full HTML email body here>\"\n}\n\n### HTML requirements:\n1. Start with a friendly greeting + date.  \n2. Group articles by topic (detect from headline/content).  \n3. For each article:  \n   - Show the **headline as a hyperlink**.  \n   - Below it, show a 2\u20134 sentence witty summary.  \n   - End with a \"Read more\" link.  \n4. Clean, minimal inline HTML styling (max 600px width for readability).  \n5. Do not include backticks and \"html\" for the HTML code which you will return.  \n\n### Example Output (shortened):\nSubject: Israeli Strike, Ukraine Tensions & Sudan Siege\n\n### Example Output (shortened):\n<!DOCTYPE html>\n<html>\n  <body style=\"margin:0;padding:0;font-family:Arial,Helvetica,sans-serif;background-color:#f9f9f9;color:#333;\">\n    <table role=\"presentation\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" width=\"100%\" style=\"max-width:600px;background:#ffffff;margin:20px auto;border-radius:12px;overflow:hidden;box-shadow:0 2px 6px rgba(0,0,0,0.08);\">\n      <tr>\n        <td style=\"padding:24px;\">\n          <!-- Header -->\n          <h2 style=\"margin:0;font-size:22px;\">\u2615 Your BBC Morning Brew \u2014 August 31, 2025</h2>\n          <p style=\"margin:8px 0 20px;font-size:14px;color:#666;\">Good morning! Here\u2019s your quick, witty roundup of today\u2019s BBC headlines.</p>\n\n          <!-- Section -->\n          <h3 style=\"font-size:16px;margin:20px 0 10px;\">\ud83c\udf0d World</h3>\n\n          <!-- Article -->\n          <div style=\"margin-bottom:18px;\">\n            <a href=\"https://www.bbc.com/link1\" style=\"font-size:15px;font-weight:bold;color:#1a73e8;text-decoration:none;\">Houthis confirm their prime minister killed in Israeli strike</a>\n            <p style=\"margin:6px 0 0;font-size:14px;line-height:1.5;color:#444;\">Yemen's Houthi rebel movement confirms a hefty blow as their self-proclaimed Prime Minister is killed in an Israeli air strike. The conflict deepens international entanglements and rising tensions. <a href=\"https://www.bbc.com/link1\" style=\"color:#1a73e8;text-decoration:none;\">Read more \u2192</a></p>\n          </div>\n\n          <div style=\"margin-bottom:18px;\">\n            <a href=\"https://www.bbc.com/link2\" style=\"font-size:15px;font-weight:bold;color:#1a73e8;text-decoration:none;\">Prominent Ukrainian politician Andriy Parubiy shot dead in Lviv</a>\n            <p style=\"margin:6px 0 0;font-size:14px;line-height:1.5;color:#444;\">Former Ukrainian parliament speaker Andriy Parubiy was gunned down in Lviv. President Zelensky condemned the \"terrible murder\" as authorities launch a manhunt. <a href=\"https://www.bbc.com/link2\" style=\"color:#1a73e8;text-decoration:none;\">Read more \u2192</a></p>\n          </div>\n\n          <div style=\"margin-bottom:18px;\">\n            <a href=\"https://www.bbc.com/link3\" style=\"font-size:15px;font-weight:bold;color:#1a73e8;text-decoration:none;\">El Fasher: Barrier being built around besieged Sudan city</a>\n            <p style=\"margin:6px 0 0;font-size:14px;line-height:1.5;color:#444;\">El Fasher is now encircled by an earthen wall, trapping civilians inside as conflict rages and humanitarian access stalls. <a href=\"https://www.bbc.com/link3\" style=\"color:#1a73e8;text-decoration:none;\">Read more \u2192</a></p>\n          </div>\n\n          <!-- Footer -->\n          <p style=\"margin-top:30px;font-size:13px;color:#888;text-align:center;\">That\u2019s your brew for today. See you tomorrow \ud83d\udc4b</p>\n        </td>\n      </tr>\n    </table>\n  </body>\n</html>\n\n "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        3200,
        288
      ],
      "id": "524c3553-2bb5-415e-9fff-11bd1483a0bf",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        3056,
        512
      ],
      "id": "3e9f2177-85c5-47d7-9a8b-893aae4374c5",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "victorvance23@gmail.com",
        "subject": "={{ $json.output.subject }}",
        "message": "={{ $json.output.html_content }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        3552,
        704
      ],
      "id": "15a3d4ea-4c0c-4500-9084-2eb0b204553f",
      "name": "Send a message",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "de979df5-36c2-4e51-95b5-5a05d6ebe9a0",
              "name": "output",
              "value": "={{ $json.output.toJsonString().parseJson() }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        3552,
        464
      ],
      "id": "92fb5f47-4c34-4183-b31d-fce5fe756464",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "amount": 15
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2256,
        512
      ],
      "id": "5dd0c1fd-aa86-4a12-8c04-84e6f659d9ec",
      "name": "Wait 15 seconds"
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "BBC RSS Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BBC RSS Read": {
      "main": [
        [
          {
            "node": "Extract URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URLs": {
      "main": [
        [
          {
            "node": "Aggregate URLs to Single Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate URLs to Single Object": {
      "main": [
        [
          {
            "node": "Initiate batch extraction from URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initiate batch extraction from URL": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Check the status of a batch extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Snapshot Again for Success": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the status of a batch extraction": {
      "main": [
        [
          {
            "node": "Check if Batch Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Batch Ready": {
      "main": [
        [
          {
            "node": "Download the snapshot content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 15 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the snapshot content": {
      "main": [
        [
          {
            "node": "Extract Essential Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Essential Data": {
      "main": [
        [
          {
            "node": "Reduce Objects to 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reduce Objects to 1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 15 seconds": {
      "main": [
        [
          {
            "node": "Check Snapshot Again for Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1596ade0-c9ce-4222-b247-aae32a849244",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "PIuV1ibEw6iiyao0",
  "tags": []
}