{
  "name": "AI News Competitive Intelligence Digest",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "c9f2cfbf-f93e-4d29-abaa-b61a81536172",
      "name": "Every Monday 9am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        96
      ]
    },
    {
      "parameters": {
        "url": "https://www.artificialintelligence-news.com/feed/",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "36c99276-b99e-4935-b029-d4a3e75d57c7",
      "name": "Fetch AI News (RSS)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        224,
        0
      ],
      "retryOnFail": true,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "url": "https://feeds.feedburner.com/venturebeat/SZYF",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "b9f0ca03-662f-4aa0-be2b-a980be20e23b",
      "name": "Fetch VentureBeat (RSS)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        224,
        192
      ],
      "retryOnFail": true,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {},
      "id": "6431b476-393f-4af9-b975-e2c0a5dd9504",
      "name": "Merge Feeds",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        448,
        96
      ]
    },
    {
      "parameters": {
        "jsCode": "const clean = (s) =>\n  s ? s.replace(/<!\\[CDATA\\[/g, '').replace(/\\]\\]>/g, '').replace(/<[^>]+>/g, '').replace(/\\s+/g, ' ').trim() : '';\n\nconst articles = [];\n\nfor (const item of $input.all()) {\n  const xml = item.json.data || '';\n  const feedTitleMatch = xml.match(/<channel>[\\s\\S]*?<title>([\\s\\S]*?)<\\/title>/);\n  const feedTitle = feedTitleMatch ? clean(feedTitleMatch[1]) : 'Unknown Feed';\n  const blocks = xml.match(/<item[\\s\\S]*?<\\/item>/g) || [];\n  for (const block of blocks.slice(0, 10)) {\n    const t = block.match(/<title>([\\s\\S]*?)<\\/title>/);\n    const l = block.match(/<link>([\\s\\S]*?)<\\/link>/);\n    const d = block.match(/<description>([\\s\\S]*?)<\\/description>/);\n    const p = block.match(/<pubDate>([\\s\\S]*?)<\\/pubDate>/);\n    const title = clean(t && t[1]);\n    if (!title) continue;\n    articles.push({\n      feed: feedTitle,\n      title,\n      link: clean(l && l[1]),\n      description: clean(d && d[1]).slice(0, 300),\n      pubDate: clean(p && p[1]),\n    });\n  }\n}\n\nconst combinedText = articles\n  .map((a, i) => `${i + 1}. [${a.feed}] ${a.title}\\n   ${a.description}\\n   ${a.link}`)\n  .join('\\n\\n');\n\nreturn [{ json: { articleCount: articles.length, combinedText, articles } }];"
      },
      "id": "7190445e-6288-4d36-8f64-96ac0e30eb0b",
      "name": "Parse RSS Items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        672,
        96
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "has-articles",
              "leftValue": "={{ $json.articleCount }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "6c758426-d108-47a3-83ff-f151fff26435",
      "name": "Has Articles?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        896,
        96
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "responses": {
          "values": [
            {
              "content": "=Below are recent AI-industry news items collected from RSS feeds. Produce a competitive-intelligence digest of 3 to 5 concise bullet points. For each point, focus on the strategic/competitive implication (who is doing what, and why it matters), not just a summary of the headline. Keep each point to 1-2 sentences.\n\nNEWS ITEMS:\n{{ $json.combinedText }}"
            }
          ]
        },
        "builtInTools": {},
        "options": {
          "instructions": "You are a competitive-intelligence analyst covering the AI industry. You write sharp, decision-useful briefings for a product and strategy team.",
          "maxTokens": 800,
          "temperature": 0.4
        }
      },
      "id": "fabb0c93-bf80-4b6a-9c66-ea722ea84364",
      "name": "Generate CI Digest",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        1120,
        0
      ],
      "retryOnFail": true,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const digest =\n  ($json.output && $json.output[0] && $json.output[0].content && $json.output[0].content[0] && $json.output[0].content[0].text) || '';\nconst count = $('Parse RSS Items').first().json.articleCount || 0;\nconst today = $now.toFormat('cccc, LLL d, yyyy');\n\nconst markdown = [\n  '*AI Competitive Intelligence Digest*',\n  '_' + today + ' \\u2014 based on ' + count + ' recent articles_',\n  '',\n  digest.trim(),\n].join('\\n');\n\nreturn [{ json: { markdown } }];"
      },
      "id": "6690a67e-0ed2-405a-852b-1ba633313b2f",
      "name": "Format Markdown",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1344,
        0
      ]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "C0BK2QVDSQN",
          "mode": "list",
          "cachedResultName": "ai-digest"
        },
        "text": "={{ $json.markdown }}",
        "otherOptions": {}
      },
      "id": "3754bc9d-ccf6-4b8a-85f2-003b799678a7",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.5,
      "position": [
        1568,
        0
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "sendTo": "your-email@example.com",
        "subject": "AI Competitive Intelligence Digest (Slack post failed)",
        "emailType": "text",
        "message": "={{ $json.markdown }}",
        "options": {}
      },
      "id": "a6f78b33-8b3c-4d86-b0be-f48b471d2fed",
      "name": "Email Digest Fallback",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        1760,
        208
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "C0BK2QVDSQN",
          "mode": "list",
          "cachedResultName": "ai-digest"
        },
        "text": "No new AI news this week",
        "otherOptions": {}
      },
      "id": "12e2f63e-c6af-4b25-bc10-fd2fda171ebe",
      "name": "No News to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.5,
      "position": [
        1120,
        192
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## AI Competitive Intelligence Digest\nRuns every Monday 9am. Fetches two RSS sources in parallel \u2014 **AI News** (artificialintelligence-news.com) and **VentureBeat** \u2014 merges them (append), and parses items with regex (no XML dependency, safe in the Cloud sandbox).\n\n**AI node:** gpt-4o-mini, temp 0.4, analyst framing \u2192 3\u20135 strategic bullets.\n\n**Resilience (selective, not blanket):** retries + error-output on both fetches; an IF guard skips the AI call when there are no articles; a Slack failure falls back to email.",
        "height": 300,
        "width": 420,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        320
      ],
      "typeVersion": 1,
      "id": "a9dab4a9-903b-4027-8e19-0aed2ba51f6c",
      "name": "Sticky Note"
    }
  ],
  "connections": {
    "Every Monday 9am": {
      "main": [
        [
          {
            "node": "Fetch AI News (RSS)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch VentureBeat (RSS)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch AI News (RSS)": {
      "main": [
        [
          {
            "node": "Merge Feeds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch VentureBeat (RSS)": {
      "main": [
        [
          {
            "node": "Merge Feeds",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Feeds": {
      "main": [
        [
          {
            "node": "Parse RSS Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse RSS Items": {
      "main": [
        [
          {
            "node": "Has Articles?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Articles?": {
      "main": [
        [
          {
            "node": "Generate CI Digest",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No News to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate CI Digest": {
      "main": [
        [
          {
            "node": "Format Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Markdown": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Slack": {
      "main": [
        [],
        [
          {
            "node": "Email Digest Fallback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "68717ea1-6097-4ee4-9d24-e95a75d35895",
  "nodeGroups": [],
  "id": "IyxGRhBB5eFAfrCP",
  "tags": []
}