{
  "id": "JvzzsjcieG8celUl",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Final Fixed: AI News Assistant",
  "tags": [],
  "nodes": [
    {
      "id": "d0b980c5-9603-41d9-93da-51dfa46daef1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1136,
        240
      ],
      "parameters": {
        "path": "iphone-news",
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "ba874d73-7c80-47bb-adcc-81233fe32925",
      "name": "Cron Daily Digest",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1136,
        432
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 8
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7514e55f-39c7-4abb-9afd-0906c5698a1a",
      "name": "Set Keyword",
      "type": "n8n-nodes-base.set",
      "position": [
        -912,
        336
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "chatInput",
              "value": "={{ $json.chatInput || \"technology\" }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 2
    },
    {
      "id": "749555ce-5b68-44f8-a44e-de8d271e9e50",
      "name": "Get News",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -688,
        336
      ],
      "parameters": {
        "url": "https://newsapi.org/v2/everything",
        "options": {},
        "queryParametersUi": {
          "parameter": [
            {
              "name": "q",
              "value": "={{ $json.chatInput }}"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "sortBy",
              "value": "publishedAt"
            },
            {
              "name": "pageSize",
              "value": "10"
            }
          ]
        },
        "headerParametersUi": {
          "parameter": [
            {
              "name": "X-Api-Key"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "931728d4-7316-4623-b94a-5f43331f365e",
      "name": "AI Agent (Filter)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -464,
        336
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json.articles) }}",
        "options": {
          "systemMessage": "You are a news filter. Your task is to evaluate the articles provided in the JSON.\n1. Filter out low-quality or clickbait articles.\n2. Select the most trustworthy and relevant articles.\n3. Return the content covering the key details and keeping the original URLs intact.\nDo not just summarize; ensure the data required for the next step (Title, URL, Author) is preserved in your response."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "b21c8ab1-ff1c-4f67-a8dd-417109ecfb31",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -400,
        560
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "a725ac8e-2423-488a-8d54-ba843f95e6e2",
      "name": "AI Agent (Structure)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -112,
        32
      ],
      "parameters": {
        "text": "={{ $json.output }}\nRead the filtered news above and select the top 3 most important articles.\nFor each article, generate the following information in English and return them in an array named 'articles':\n\n- title: Article title\n- author: Author/Media name (or \"Unknown\")\n- summary: Content summary (3-4 sentences)\n- url: Article URL (Must be accurate from the source)\n\nReturn ONLY valid JSON matching the schema. No markdown, no conversational text.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "ab644591-2b87-45fe-81bf-6ee4ff58cb82",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -112,
        256
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "20f593b1-6051-4920-a289-49c0b3c3c060",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        32,
        256
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"articles\": [\n    {\n      \"title\": \"string\",\n      \"author\": \"string\",\n      \"summary\": \"string\",\n      \"url\": \"string\"\n    }\n  ]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3a410b4c-b58c-4c1e-b432-8bfd350af97d",
      "name": "Split Articles",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        240,
        144
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "articles"
      },
      "typeVersion": 1
    },
    {
      "id": "9ec142de-6248-448b-a05d-554918109f45",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        464,
        144
      ],
      "parameters": {
        "operation": "append",
        "sheetName": "",
        "documentId": ""
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9d47c7b4-af97-4f01-a3c5-7e79e56284f1",
      "name": "AI Agent (Slack)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -112,
        544
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "options": {
          "systemMessage": "Based on the articles provided, create a readable summary formatted for Slack.\n\nFor each of the 3 articles, output in this format:\n\n---\n\ud83d\udcf0 *{{Title}}*\n\u270d\ufe0f Author: {{Author Name}}\n\ud83d\udcdd Summary:\n{{Summary Content}}\n\n\ud83d\udd17 Reference URL:\n{{URL}}\n---\n\nOutput conditions:\n- Write in English\n- Use markdown\n- No code blocks\n"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "4c66a24a-c8bc-4191-8f1e-fa9339c9c828",
      "name": "OpenRouter Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -48,
        768
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "770277c0-bb73-47bf-a409-0db463836487",
      "name": "Send English Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        240,
        432
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "select": "channel",
        "channelId": "",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "77acd726-0fe9-41c6-8971-3b44bfc28797",
      "name": "Translate to Japanese",
      "type": "n8n-nodes-base.deepL",
      "position": [
        240,
        640
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "translateTo": "JA",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "90f31ebf-1c7a-46b6-a1e9-4241af640783",
      "name": "Send Japanese Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        464,
        640
      ],
      "parameters": {
        "text": "={{ $json.translatedText }}",
        "select": "channel",
        "channelId": "",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "4850cb6f-830e-467f-a87d-c6a40d5f533b",
      "name": "Cron Weekly Report",
      "type": "n8n-nodes-base.cron",
      "position": [
        -768,
        1376
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 9,
              "mode": "everyWeek",
              "weekday": ""
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fc7e256a-b737-4681-a85b-fcfef643bdc5",
      "name": "Read sheet (weekly)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -544,
        1376
      ],
      "parameters": {
        "sheetName": "",
        "documentId": ""
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "8f23bb93-933a-46e0-ad51-7311ea68ad79",
      "name": "AI Agent Weekly Report",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -320,
        1376
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are given a list of news records (title, summary, URL, date, and category). Create a weekly trend report:\n- Top 3 most frequent topics\n- Key insights in 5-7 bullet points\n- Suggested actions for the team\nWrite in English in a Slack-friendly markdown format."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "dc8897ae-8113-4a4a-8b70-df0d84453c2a",
      "name": "OpenRouter Weekly",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -256,
        1600
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "21326f5b-5aa2-42d2-958c-ad3b19cdb44d",
      "name": "Send Weekly Summary",
      "type": "n8n-nodes-base.slack",
      "position": [
        32,
        1376
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "select": "channel",
        "channelId": "",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "42d8c569-b5e4-4e08-a35a-b454ba29603b",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2112,
        496
      ],
      "parameters": {
        "width": 752,
        "height": 560,
        "content": "## What it does\n1. **Fetches News:** Pulls daily articles via NewsAPI based on your chosen keyword (default: \"technology\").\n2. **AI Filtering:** Uses an AI Agent (via OpenRouter) to filter out low-quality or irrelevant clickbait.\n3. **Daily Digest (Slack):**\n   - Summarizes the top 3 articles in English.\n   - Translates the summaries to Japanese using DeepL (optional).\n   - Posts both versions to a Slack channel.\n4. **Data Archiving (Sheets):** Extracts structured data (Title, Author, Summary, URL) and saves it to Google Sheets.\n5. **Weekly Trend Report:** Every Monday, it reads the past week's data from Google Sheets and uses AI to generate a high-level trend report and strategic insights.\n\n## Requirements\n- **n8n** (Self-hosted or Cloud)\n- **NewsAPI** Key (Free tier available)\n- **OpenRouter** (or any LangChain compatible Chat Model like OpenAI)\n- **DeepL** API Key (for translation)\n- **Google Sheets** account\n- **Slack** Workspace\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1a245591-72de-4e64-a141-b26aef81ac5c",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1088,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 1600,
        "height": 880,
        "content": "## How to set up\n1. **Configure Credentials:** You will need API keys/auth for NewsAPI, OpenRouter (or OpenAI), DeepL, Google Sheets, and Slack.\n2. **Setup Google Sheet:** Create a sheet with the following headers in the first row: `title`, `author`, `summary`, `url`.\n3. **Map the Sheet:** In the \"Append row in sheet\" and \"Read sheet (weekly)\" nodes, select your file and map the columns.\n4. **Define Keyword:** Open the \"Set Keyword\" node and change `chatInput` to the topic you want to track (e.g., \"Crypto\", \"SaaS\", \"Climate Change\").\n5. **Slack Setup:** Select your desired channel in the Slack nodes.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9f64dfeb-a885-4dae-b080-14d6a150a9ec",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        1104
      ],
      "parameters": {
        "color": 7,
        "width": 832,
        "height": 544,
        "content": "##  Weekly Trend Report Configuration\n\nThis section automates the weekly analysis every Monday at 9:00 AM. It reads the accumulated articles from your Google Sheet and uses AI to identify trends.\n\n**Setup Steps:**\n1. **Google Sheets:** Open the `Read sheet (weekly)` node. Select the **same Document and Sheet** that you configured in the \"Append row in sheet\" node above. This allows the AI to access the past week's data.\n2. **AI Model:** Ensure the `OpenRouter Weekly` node has your credentials selected.\n3. **Slack:** In the `Send Weekly Summary` node, select the channel where you want the weekly insights report to be posted.\n4. **Schedule:** (Optional) You can change the reporting day and time in the `Cron Weekly Report` node."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9f56cb07-e66d-46ef-bd77-b20411ca00fd",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Set Keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get News": {
      "main": [
        [
          {
            "node": "AI Agent (Filter)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Keyword": {
      "main": [
        [
          {
            "node": "Get News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Articles": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Slack)": {
      "main": [
        [
          {
            "node": "Send English Message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Translate to Japanese",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Filter)": {
      "main": [
        [
          {
            "node": "AI Agent (Structure)",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent (Slack)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron Daily Digest": {
      "main": [
        [
          {
            "node": "Set Keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Weekly": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Weekly Report",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Cron Weekly Report": {
      "main": [
        [
          {
            "node": "Read sheet (weekly)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read sheet (weekly)": {
      "main": [
        [
          {
            "node": "AI Agent Weekly Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Structure)": {
      "main": [
        [
          {
            "node": "Split Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent (Filter)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Translate to Japanese": {
      "main": [
        [
          {
            "node": "Send Japanese Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Weekly Report": {
      "main": [
        [
          {
            "node": "Send Weekly Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent (Structure)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent (Slack)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent (Structure)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}