{
  "name": "Morning Intelligence Briefing",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24,
              "triggerAtHour": 6
            }
          ]
        }
      },
      "id": "cron-trigger",
      "name": "6 AM Daily",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "url": "http://freshrss.kangaroo-eel.ts.net/api/greader.php/reader/api/0/stream/items/ids",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "output",
              "value": "json"
            },
            {
              "name": "n",
              "value": "20"
            }
          ]
        },
        "options": {}
      },
      "id": "freshrss-fetch",
      "name": "Fetch FreshRSS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [450, 200],
      "credentials": {
        "httpBasicAuth": {
          "id": "freshrss-creds",
          "name": "FreshRSS Credentials"
        }
      }
    },
    {
      "parameters": {
        "command": "cd /home/openclaw/.openclaw/workspace/skills/news-aggregator-skill && .venv/bin/python scripts/fetch_news.py --source all --limit 15"
      },
      "id": "news-aggregator",
      "name": "News Aggregator",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [450, 400]
    },
    {
      "parameters": {
        "model": "llama-3.1-sonar-large-128k-online",
        "messages": {
          "message": [
            {
              "role": "user",
              "content": "What are the top 5 tech, AI, and business news stories from today?"
            }
          ]
        },
        "options": {}
      },
      "id": "perplexity-search",
      "name": "Perplexity Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [650, 300],
      "credentials": {
        "httpHeaderAuth": {
          "id": "perplexity-creds",
          "name": "Perplexity API"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Combine all news sources and deduplicate\nconst freshRSS = $input.first().json;\nconst newsAgg = $input.all()[1].json;\nconst perplexity = $input.all()[2].json;\n\n// Create combined list\nlet allStories = [];\n\n// Add FreshRSS items\nif (freshRSS && freshRSS.items) {\n  allStories = allStories.concat(freshRSS.items.map(item => ({\n    source: 'FreshRSS',\n    title: item.title,\n    url: item.url,\n    time: item.timestamp\n  })));\n}\n\n// Add News Aggregator items\nif (newsAgg && Array.isArray(newsAgg)) {\n  allStories = allStories.concat(newsAgg.map(item => ({\n    source: item.source || 'News Aggregator',\n    title: item.title,\n    url: item.url,\n    heat: item.heat\n  })));\n}\n\n// Add Perplexity insights\nif (perplexity && perplexity.choices) {\n  allStories.push({\n    source: 'Perplexity AI',\n    title: 'AI-Synthesized Briefing',\n    content: perplexity.choices[0].message.content\n  });\n}\n\n// Return combined for AI analysis\nreturn [{\n  json: {\n    stories: allStories,\n    count: allStories.length,\n    sources: ['FreshRSS', 'News Aggregator', 'Perplexity']\n  }\n}];"
      },
      "id": "combine-sources",
      "name": "Combine Sources",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [850, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {},
        "messages": {
          "message": [
            {
              "role": "system",
              "content": "You are a news editor creating a morning intelligence briefing. Analyze the provided news stories from multiple sources, remove duplicates, identify genuinely new information, and create a concise summary of the top 5-7 most important stories. Format as markdown with emojis. Focus on tech, AI, business, and relevant world news."
            },
            {
              "role": "user",
              "content": "=Create a morning briefing from these sources:\n\n{{ $json.stories }}"
            }
          ]
        }
      },
      "id": "ai-summarize",
      "name": "AI Summarize",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [1050, 300]
    },
    {
      "parameters": {
        "chatId": "1793951355",
        "text": "=🌅 **Morning Intelligence Briefing**\n\n{{ $json.output }}\n\n---\n_Sources: FreshRSS, News Aggregator, Perplexity AI_",
        "options": {}
      },
      "id": "telegram-send",
      "name": "Send Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.1,
      "position": [1250, 300],
      "credentials": {
        "telegramApi": {
          "id": "telegram-bot-creds",
          "name": "Telegram Bot"
        }
      }
    }
  ],
  "connections": {
    "6 AM Daily": {
      "main": [
        [
          {
            "node": "Fetch FreshRSS",
            "type": "main",
            "index": 0
          },
          {
            "node": "News Aggregator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch FreshRSS": {
      "main": [
        [
          {
            "node": "Combine Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "News Aggregator": {
      "main": [
        [
          {
            "node": "Combine Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Sources": {
      "main": [
        [
          {
            "node": "AI Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Summarize": {
      "main": [
        [
          {
            "node": "Send Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "pinData": {},
  "description": "Daily morning briefing combining FreshRSS, News Aggregator, and Perplexity AI into a single Telegram message at 6 AM"
}
