{ "name": "Check the news on any topic, score it with AI and post to Slack", "nodes": [ { "name": "Twice a day", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.3, "position": [ 0, 112 ], "parameters": { "rule": { "interval": [ { "field": "hours", "hoursInterval": 12 } ] } } }, { "name": "Set the topic, search terms and companies", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 224, 112 ], "parameters": { "mode": "manual", "includeOtherFields": false, "assignments": { "assignments": [ { "id": "topic", "name": "topic", "value": "memory and storage chips", "type": "string" }, { "id": "q", "name": "search_queries", "value": "NAND flash pricing 2026, SSD supply shortage, memory supercycle, AI storage demand", "type": "string" }, { "id": "c", "name": "companies", "value": "SNDK, MU, WDC, STX, POET", "type": "string" } ] } } }, { "name": "Fetch the Google News feed", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 448, 112 ], "parameters": { "method": "GET", "url": "https://news.google.com/rss/search", "sendQuery": true, "specifyQuery": "keypair", "queryParameters": { "parameters": [ { "name": "q", "value": "={{ $json.search_queries.split(\",\").map(s => \"(\" + s.trim() + \")\").join(\" OR \") }}" }, { "name": "hl", "value": "en-US" }, { "name": "gl", "value": "US" }, { "name": "ceid", "value": "US:en" } ] }, "options": { "timeout": 20000, "response": { "response": { "responseFormat": "text", "outputPropertyName": "data" } } } }, "retryOnFail": true }, { "name": "Pull out the latest headlines", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 672, 112 ], "parameters": { "mode": "runOnceForAllItems", "language": "javaScript", "jsCode": "const xml = String($input.first().json.data || '');\nconst items = xml.split('').slice(1, 26);\nconst clean = s => s.replace(//g, '').replace(/&/g, '&').replace(/"/g, '\"').replace(/'/g, \"'\").trim();\nconst headlines = items.map((block, i) => {\n const title = clean((block.match(/([\\s\\S]*?)<\\/title>/) || [])[1] || '');\n const date = clean((block.match(/<pubDate>([\\s\\S]*?)<\\/pubDate>/) || [])[1] || '');\n return (i + 1) + '. ' + title + (date ? ' (' + date.slice(5, 16) + ')' : '');\n}).filter(line => line.length > 4);\nconst settings = $('Set the topic, search terms and companies').first().json;\nreturn [{ json: { topic: settings.topic, companies: settings.companies, headlineCount: headlines.length, headlines: headlines.join('\\n') } }];" } }, { "name": "Analyse the headlines with AI", "type": "@n8n/n8n-nodes-langchain.chainLlm", "typeVersion": 1.9, "position": [ 896, 112 ], "parameters": { "promptType": "define", "text": "=Analyze these headlines about {{ $json.topic }}:\n\n{{ $json.headlines }}", "hasOutputParser": true, "messages": { "messageValues": [ { "type": "SystemMessagePromptTemplate", "message": "=You are an analyst who covers {{ $json.topic }}. Analyze these headlines for: 1) Pricing trends (bullish/bearish), 2) Supply-demand signals, 3) Key company moves, 4) Investment implications. Return a brief JSON summary with 'sentiment' (1-10), 'key_signal', and 'action_item'." } ] } }, "retryOnFail": true }, { "name": "OpenAI Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.3, "position": [ 912, 336 ], "parameters": { "model": { "__rl": true, "mode": "id", "value": "gpt-6-luna" }, "options": {} } }, { "name": "Return sentiment, signal and action", "type": "@n8n/n8n-nodes-langchain.outputParserStructured", "typeVersion": 1.3, "position": [ 1040, 336 ], "parameters": { "schemaType": "fromJson", "jsonSchemaExample": "{ \"sentiment\": 7, \"key_signal\": \"Prices rose again this week as supply stays tight\", \"action_item\": \"Watch for supplier earnings guidance\" }" } }, { "name": "Is sentiment 7 or higher?", "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1248, 112 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose" }, "conditions": [ { "leftValue": "={{ $json.output.sentiment }}", "operator": { "type": "number", "operation": "gte" }, "rightValue": 7 } ], "combinator": "and" } } }, { "name": "Post a Slack alert", "type": "n8n-nodes-base.slack", "typeVersion": 2.4, "position": [ 1472, 16 ], "parameters": { "resource": "message", "operation": "post", "select": "channel", "channelId": { "__rl": true, "mode": "name", "value": "#news-alerts" }, "messageType": "text", "text": "=📈 *News alert: {{ $(\"Pull out the latest headlines\").first().json.topic }}*\n\nSentiment: {{ $json.output.sentiment }}/10\nKey Signal: {{ $json.output.key_signal }}\nAction: {{ $json.output.action_item }}\n\nCompanies: {{ $(\"Pull out the latest headlines\").first().json.companies }}", "otherOptions": { "includeLinkToWorkflow": false } } }, { "name": "Post a Slack update", "type": "n8n-nodes-base.slack", "typeVersion": 2.4, "position": [ 1472, 208 ], "parameters": { "resource": "message", "operation": "post", "select": "channel", "channelId": { "__rl": true, "mode": "name", "value": "#news-alerts" }, "messageType": "text", "text": "=📊 *No major movement: {{ $(\"Pull out the latest headlines\").first().json.topic }}*\nSentiment: {{ $json.output.sentiment }}/10\nKey Signal: {{ $json.output.key_signal }}", "otherOptions": { "includeLinkToWorkflow": false } } } ], "connections": { "Twice a day": { "main": [ [ { "node": "Set the topic, search terms and companies", "type": "main", "index": 0 } ] ] }, "Fetch the Google News feed": { "main": [ [ { "node": "Pull out the latest headlines", "type": "main", "index": 0 } ] ] }, "Pull out the latest headlines": { "main": [ [ { "node": "Analyse the headlines with AI", "type": "main", "index": 0 } ] ] }, "Analyse the headlines with AI": { "main": [ [ { "node": "Is sentiment 7 or higher?", "type": "main", "index": 0 } ] ] }, "OpenAI Chat Model": { "ai_languageModel": [ [ { "node": "Analyse the headlines with AI", "type": "ai_languageModel", "index": 0 } ] ] }, "Return sentiment, signal and action": { "ai_outputParser": [ [ { "node": "Analyse the headlines with AI", "type": "ai_outputParser", "index": 0 } ] ] }, "Is sentiment 7 or higher?": { "main": [ [ { "node": "Post a Slack alert", "type": "main", "index": 0 } ], [ { "node": "Post a Slack update", "type": "main", "index": 0 } ] ] }, "Set the topic, search terms and companies": { "main": [ [ { "node": "Fetch the Google News feed", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" } }