{
  "name": "AI News Research Automation with n8n - Public Sanitized",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ai-news-research-assignment-10",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1280,
        -240
      ],
      "id": "f288b6c6-63d1-4027-bcff-1fde3f85b10a",
      "name": "Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ddfc71ab-7fcf-4f30-bbf3-26f9bc394302",
              "name": "topic",
              "value": "={{$json.body.topic}}",
              "type": "string"
            },
            {
              "id": "b8722b21-0e39-4cef-97d0-7c246f48dc5c",
              "name": "articles",
              "value": "={{$json.body.articles}}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1104,
        -240
      ],
      "id": "9f48fcdc-d6c9-4a90-af7d-4f1ac4f19fdf",
      "name": "Validate Input"
    },
    {
      "parameters": {
        "url": "https://gnews.io/api/v4/search",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "={{$json.topic}}"
            },
            {
              "name": "lang",
              "value": "en"
            },
            {
              "name": "max",
              "value": "={{$json.articles}}"
            },
            {
              "name": "apikey",
              "value": "YOUR_GNEWS_API_KEY"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        -928,
        -240
      ],
      "id": "feba2c8d-7ee6-4acf-b861-8c7291455984",
      "name": "Fetch News",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "fieldToSplitOut": "articles",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -736,
        -240
      ],
      "id": "740d2e9d-b36d-4e0c-a46e-d8a0df804ca3",
      "name": "Split Out Articles"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "47ca1bdb-7958-43df-b572-181db577c36b",
              "name": "title",
              "value": "={{$json.title}}",
              "type": "string"
            },
            {
              "id": "74e2d9e1-f895-437b-a60e-09df15ab6918",
              "name": "source",
              "value": "={{$json.source.name}}",
              "type": "string"
            },
            {
              "id": "ceade662-41b5-42e1-9584-3f29eefe1112",
              "name": "published_date",
              "value": "={{$json.publishedAt}}",
              "type": "string"
            },
            {
              "id": "9ed90f73-dfc5-4168-a8aa-e6628e8cd93f",
              "name": "article_url",
              "value": "={{$json.url}}",
              "type": "string"
            },
            {
              "id": "43e657e7-de6d-45d7-b744-a9daad686c9b",
              "name": "description",
              "value": "={{$json.description}}",
              "type": "string"
            },
            {
              "id": "c44260ac-c855-4305-964f-a2fd2e536f92",
              "name": "content",
              "value": "={{$json.content}}",
              "type": "string"
            },
            {
              "id": "369245d9-ae93-4478-a8cf-5e1def3c22c9",
              "name": "topic",
              "value": "={{ $('Validate Input').item.json.topic }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -544,
        -240
      ],
      "id": "8dcb8b4c-02d5-40aa-ba55-dca41efb63b6",
      "name": "Normalize Article Data"
    },
    {
      "parameters": {
        "model": "anthropic/claude-3-haiku",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        -432,
        16
      ],
      "id": "d3e03f6a-f286-439c-aed9-598d7c784ad3",
      "name": "OpenRouter Chat Model"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Analyze this AI news article.\n\nTopic:\n{{ $json.topic }}\n\nTitle:\n{{ $json.title }}\n\nSource:\n{{ $json.source }}\n\nPublished Date:\n{{ $json.published_date }}\n\nArticle URL:\n{{ $json.article_url }}\n\nDescription:\n{{ $json.description }}\n\nContent:\n{{ $json.content }}\n\nTasks:\n1. Generate a 2-3 sentence summary.\n2. Extract one clear key takeaway.\n3. Assign exactly one category:\nAI Product, AI Research, Funding, Open Source, Business.\n4. Give a LinkedIn Worthiness Score from 1 to 10.\n\nScoring guide:\n- 9-10: Highly relevant, timely, strong LinkedIn discussion potential.\n- 7-8: Useful and relevant for AI/business audience.\n- 5-6: Interesting but not very strong for LinkedIn.\n- 1-4: Low relevance or weak business value.",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "=You are an expert AI news research analyst and LinkedIn content strategist.\n\nYour job is to analyze AI news articles for a startup founder who publishes daily LinkedIn posts about AI.\n\nYou must:\n- Summarize the article in 2\u20133 clear sentences.\n- Extract one practical key takeaway.\n- Classify the article into exactly one category:\n  AI Product, AI Research, Funding, Open Source, or Business.\n- Give a LinkedIn Worthiness Score from 1 to 10.\n- Prefer business relevance, founder usefulness, novelty, timeliness, and discussion potential when scoring.\n- Return only valid JSON.\n- Do not use markdown.\n- Do not add explanations outside the JSON.\n- Do not invent facts that are not supported by the article."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        -352,
        -240
      ],
      "id": "1ca347b4-590a-4aca-afa4-d495e5d82a5e",
      "name": "AI News Research",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "={\n  \"type\": \"object\",\n  \"properties\": {\n    \"summary\": {\n      \"type\": \"string\",\n      \"description\": \"A 2-3 sentence summary of the article\"\n    },\n    \"key_takeaway\": {\n      \"type\": \"string\",\n      \"description\": \"One clear practical takeaway from the article\"\n    },\n    \"category\": {\n      \"type\": \"string\",\n      \"enum\": [\n        \"AI Product\",\n        \"AI Research\",\n        \"Funding\",\n        \"Open Source\",\n        \"Business\"\n      ],\n      \"description\": \"The category that best fits the article\"\n    },\n    \"linkedin_worthiness_score\": {\n      \"type\": \"number\",\n      \"minimum\": 1,\n      \"maximum\": 10,\n      \"description\": \"A score from 1 to 10 showing how suitable this article is for a LinkedIn post\"\n    }\n  },\n  \"required\": [\n    \"summary\",\n    \"key_takeaway\",\n    \"category\",\n    \"linkedin_worthiness_score\"\n  ]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -160,
        16
      ],
      "id": "e8dd6270-3525-4bac-872e-e7ff177f24c0",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c241293c-357c-463c-81d4-a621ea96a19f",
              "name": "Title",
              "value": "={{ $('Normalize Article Data').item.json.title }}",
              "type": "string"
            },
            {
              "id": "4ec39262-5e5d-4542-93bf-c07cc5f3de07",
              "name": "Source",
              "value": "={{ $('Normalize Article Data').item.json.source }}",
              "type": "string"
            },
            {
              "id": "9c9204f5-829e-40b0-989f-ec61aa9afee8",
              "name": "Published Date",
              "value": "={{ $('Normalize Article Data').item.json.published_date }}",
              "type": "string"
            },
            {
              "id": "3cb78ebd-328d-4bcd-b92e-fb4717aa56b1",
              "name": "Summary",
              "value": "={{ $json.output.summary }}",
              "type": "string"
            },
            {
              "id": "3a28d2e2-eee3-46da-81b8-d7e31a37b468",
              "name": "Key Takeaway",
              "value": "={{ $json.output.key_takeaway }}",
              "type": "string"
            },
            {
              "id": "f775e6e4-c758-452b-a472-fa2c438b22ba",
              "name": "Category",
              "value": "={{ $json.output.category }}",
              "type": "string"
            },
            {
              "id": "d29a3144-45c2-42d3-bddb-7857ba44661c",
              "name": "LinkedIn Worthiness Score",
              "value": "={{ $json.output.linkedin_worthiness_score }}",
              "type": "number"
            },
            {
              "id": "0873e064-a826-4443-806f-bd94effe64bc",
              "name": "Article URL",
              "value": "={{ $('Normalize Article Data').item.json.article_url }}",
              "type": "string"
            },
            {
              "id": "6233f8b2-c22e-4dae-8903-16eaa9851a3f",
              "name": "Topic",
              "value": "={{ $('Normalize Article Data').item.json.topic }}",
              "type": "string"
            },
            {
              "id": "fcfa7d81-b6bd-4688-9b52-239da735c945",
              "name": "Processed At",
              "value": "={{ $now }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -32,
        -240
      ],
      "id": "f33e3d3e-a5bb-460f-8259-817dab84f7b6",
      "name": "Prepare Sheet Row"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "News Results",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Title": "={{ $json.Title }}",
            "Source": "={{ $json.Source }}",
            "Published Date": "={{ $json['Published Date'] }}",
            "Summary": "={{ $json.Summary }}",
            "Key Takeaway": "={{ $json['Key Takeaway'] }}",
            "Category": "={{ $json.Category }}",
            "LinkedIn Worthiness Score": "={{ $json['LinkedIn Worthiness Score'] }}",
            "Article URL": "={{ $json['Article URL'] }}",
            "Topic": "={{ $json.Topic }}",
            "Processed At": "={{ $json['Processed At'] }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "displayName": "Source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Published Date",
              "displayName": "Published Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Summary",
              "displayName": "Summary",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Key Takeaway",
              "displayName": "Key Takeaway",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn Worthiness Score",
              "displayName": "LinkedIn Worthiness Score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Article URL",
              "displayName": "Article URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Topic",
              "displayName": "Topic",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Processed At",
              "displayName": "Processed At",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        192,
        -240
      ],
      "id": "db897334-605b-4d44-9eb2-e7d28c6bc154",
      "name": "Save to Google Sheets",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const inputItems = $input.all();\n\nconst articles = [];\n\nfor (const item of inputItems) {\n  const row = item.json;\n\n  articles.push({\n    title: row.Title || \"\",\n    source: row.Source || \"\",\n    published_date: row[\"Published Date\"] || \"\",\n    summary: row.Summary || \"\",\n    key_takeaway: row[\"Key Takeaway\"] || \"\",\n    category: row.Category || \"\",\n    linkedin_worthiness_score: Number(row[\"LinkedIn Worthiness Score\"] || 0),\n    article_url: row[\"Article URL\"] || \"\",\n    topic: row.Topic || \"\",\n    processed_at: row[\"Processed At\"] || \"\"\n  });\n}\n\n// Sort logic:\n// 1. Higher LinkedIn Worthiness Score first\n// 2. If scores are same, newer Published Date first\narticles.sort((a, b) => {\n  const scoreDiff = b.linkedin_worthiness_score - a.linkedin_worthiness_score;\n\n  if (scoreDiff !== 0) {\n    return scoreDiff;\n  }\n\n  const dateA = new Date(a.published_date || 0).getTime();\n  const dateB = new Date(b.published_date || 0).getTime();\n\n  return dateB - dateA;\n});\n\nconst top3 = articles.slice(0, 3);\n\nreturn [\n  {\n    json: {\n      success: true,\n      message: \"AI news research completed successfully\",\n      total_articles_processed: articles.length,\n      sorting_logic: \"Sorted by LinkedIn Worthiness Score. If scores are tied, the most recent Published Date is prioritized.\",\n      top_3_articles: top3\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        432,
        -240
      ],
      "id": "e821bb8b-fd22-4e05-b540-65c485b02c67",
      "name": "Sort Top 3 Articles"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        656,
        -240
      ],
      "id": "029a1a27-f892-4afe-9972-428614b59317",
      "name": "Return Top 3 Articles"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Validate Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Input": {
      "main": [
        [
          {
            "node": "Fetch News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch News": {
      "main": [
        [
          {
            "node": "Split Out Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Articles": {
      "main": [
        [
          {
            "node": "Normalize Article Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Article Data": {
      "main": [
        [
          {
            "node": "AI News Research",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI News Research",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI News Research": {
      "main": [
        [
          {
            "node": "Prepare Sheet Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI News Research",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Sheet Row": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Sort Top 3 Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort Top 3 Articles": {
      "main": [
        [
          {
            "node": "Return Top 3 Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Return Top 3 Articles": {
      "main": [
        []
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "timeSavedMode": "fixed",
    "timezone": "Asia/Dhaka",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "65cbfe22-9d0b-4ea8-a3b1-ec1a10c46496",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodeGroups": [],
  "id": "cOuM1uhxGHbK69qP",
  "tags": [
    {
      "updatedAt": "2026-04-19T10:36:06.995Z",
      "createdAt": "2026-04-19T10:36:06.995Z",
      "id": "qINUxDoUTgKfZG2J",
      "name": "OSTAD"
    },
    {
      "updatedAt": "2026-07-06T18:46:13.942Z",
      "createdAt": "2026-07-06T18:46:13.942Z",
      "id": "z2sCe7JGfPfVJrD0",
      "name": "Assignment-10 Module-10"
    }
  ]
}