{
  "id": "QiL5QGmjTyMdvxHW",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Daily AI News Summary & Gmail Delivery",
  "tags": [],
  "nodes": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        224,
        304
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "note1-2345-6789-abcd-ef1234567890",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -16
      ],
      "parameters": {
        "width": 320,
        "height": 280,
        "content": "## Daily AI News Summary to Gmail\nThis workflow runs on a schedule to gather the latest news, summarize it using an AI agent, and deliver it as a formatted email via Gmail.\n\n**Required Setup:**\n1. Configure the **Schedule Trigger** to your desired time.\n2. Add your **OpenRouter API** credentials to the \"OpenRouter Chat Model\" node.\n3. Add your **Tavily API Key** in the \"Tavily News Search\" node.\n4. Add your **Gmail OAuth2** credentials to the \"Send a message\" node."
      },
      "typeVersion": 1
    },
    {
      "id": "agent123-4567-8901-2345-678901234567",
      "name": "AI News Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        704,
        304
      ],
      "parameters": {
        "text": "={{ $json.query }}",
        "options": {
          "systemMessage": "=You are a professional news analyst. Your task is to find the most important news stories for the day on topics like technology, business, world events, and science. Language is must be Japanese.\n\nYou MUST provide your response as a single, valid JSON object. Do not add any text or markdown before or after the JSON. The JSON object must strictly follow this schema:\n\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"title\": {\n      \"type\": \"string\",\n      \"description\": \"Create a compelling title for the daily news summary, like 'Daily News Briefing: [Date]'.\"\n    },\n    \"summary\": {\n      \"type\": \"string\",\n      \"description\": \"A very brief, one-sentence overview of the day's news headlines.\"\n    },\n    \"stories\": {\n      \"type\": \"array\",\n      \"description\": \"An array of 5 to 7 of the most important news stories.\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"headline\": {\n            \"type\": \"string\",\n            \"description\": \"The headline of the story.\"\n          },\n          \"summary\": {\n            \"type\": \"string\",\n            \"description\": \"A concise summary of the individual story (2-3 sentences).\"\n          },\n          \"category\": {\n            \"type\": \"string\",\n            \"description\": \"The relevant category (e.g., 'Technology', 'Business', 'World Events', 'Science').\"\n          }\n        },\n        \"required\": [\"headline\", \"summary\", \"category\"]\n      }\n    }\n  },\n  \"required\": [\"title\", \"summary\", \"stories\"]\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "model456-7890-1234-5678-901234567890",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        624,
        512
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "tavily789-0123-4567-8901-234567890123",
      "name": "Tavily News Search",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        800,
        512
      ],
      "parameters": {
        "url": "https://api.tavily.com/search",
        "method": "POST",
        "jsonBody": "={\n    \"api_key\": \"your-API\",\n    \"query\": \"{searchTerm}\",\n    \"search_depth\": \"advanced\",\n    \"include_answer\": true,\n    \"topic\": \"news\",\n    \"include_raw_content\": true,\n    \"max_results\": 10,\n    \"days\": 1\n}",
        "sendBody": true,
        "specifyBody": "json",
        "toolDescription": "Use this tool to search for the latest news on any topic",
        "placeholderDefinitions": {
          "values": [
            {
              "name": "searchTerm",
              "type": "string",
              "description": "The news topic or query to search for"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "parser012-3456-7890-1234-567890123456",
      "name": "News Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        976,
        512
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"title\": {\n      \"type\": \"string\",\n      \"description\": \"The title for today's news summary\"\n    },\n    \"summary\": {\n      \"type\": \"string\",\n      \"description\": \"The complete formatted news summary with all stories\"\n    },\n    \"stories\": {\n      \"type\": \"array\",\n      \"description\": \"Individual news stories\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"headline\": {\n            \"type\": \"string\"\n          },\n          \"summary\": {\n            \"type\": \"string\"\n          },\n          \"category\": {\n            \"type\": \"string\"\n          }\n        }\n      }\n    }\n  },\n  \"required\": [\"title\", \"summary\", \"stories\"]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "note2-3456-7890-1234-567890123456",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -16
      ],
      "parameters": {
        "width": 368,
        "height": 240,
        "content": "## AI News Agent Configuration\nThe core of this workflow is the AI Agent, which is configured to:\n- Search for news across key topics (Tech, Business, World Events, etc.).\n- Use the **Tavily API** for real-time news search.\n- Structure the output into a specific JSON format for easy processing."
      },
      "typeVersion": 1
    },
    {
      "id": "code345-6789-0123-4567-890123456789",
      "name": "Prepare News Query",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        304
      ],
      "parameters": {
        "jsCode": "const today = new Date();\nconst dateString = today.toLocaleDateString('en-US', { \n  weekday: 'long', \n  year: 'numeric', \n  month: 'long', \n  day: 'numeric' \n});\n\nreturn [\n  {\n    json: {\n      query: `Search for today's most important news stories from ${dateString}. Include major headlines from technology, business, politics, science, and world events. Focus on the most significant and impactful stories.`,\n      date: dateString\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "note3-4567-8901-2345-678901234567",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        -16
      ],
      "parameters": {
        "width": 336,
        "height": 272,
        "content": "## Gmail Delivery Setup\n**Required Configuration:**\n1. Add your **Gmail OAuth2 credentials** to the final node.\n2. Set the recipient's email address in the \"Send a message\" node.\n3. The \"Format for Gmail\" node uses JavaScript to create a well-formatted HTML email. You can customize the styling there."
      },
      "typeVersion": 1
    },
    {
      "id": "675a14e9-0472-42f5-8828-6dceb7547dbe",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1344,
        304
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.htmlBody }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "format901-2345-6789-0123-456789012345",
      "name": "Format for Gmail",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        304
      ],
      "parameters": {
        "jsCode": "const output = $input.first().json.output;\nconst date = $input.first().json.date;\n\n// \u30e1\u30fc\u30eb\u306e\u4ef6\u540d\nconst subject = output.title || \"Daily News Summary\";\n\n// HTML\u30e1\u30fc\u30eb\u306e\u672c\u6587\u3092\u751f\u6210\nlet htmlBody = `\n<!DOCTYPE html>\n<html lang=\"ja\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <style>\n    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; color: #333333; background-color: #f4f4f4; margin: 0; padding: 0; }\n    .container { max-width: 600px; margin: 20px auto; padding: 20px; background-color: #ffffff; border: 1px solid #dddddd; border-radius: 8px; }\n    h1 { font-size: 24px; color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; }\n    h3 { font-size: 18px; color: #34495e; margin-bottom: 5px; }\n    p { margin-top: 0; }\n    .story { margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #eeeeee; }\n    .story:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0;}\n    .category { font-style: italic; color: #7f8c8d; font-size: 0.9em; margin-bottom: 10px; }\n    .date { font-weight: bold; color: #555555; }\n    .footer { text-align: center; margin-top: 20px; font-size: 12px; color: #999999; }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <h1>\ud83d\udcf0 ${output.title}</h1>\n    <p class=\"date\">${date}</p>\n    <hr style=\"border: 0; border-top: 1px solid #eeeeee; margin: 20px 0;\">\n`;\n\n// \u5404\u30cb\u30e5\u30fc\u30b9\u8a18\u4e8b\u3092HTML\u306b\u8ffd\u52a0\nif (output.stories && output.stories.length > 0) {\n  output.stories.forEach(story => {\n    htmlBody += `\n      <div class=\"story\">\n        <h3>${story.headline}</h3>\n        <p class=\"category\">${story.category}</p>\n        <p>${story.summary}</p>\n      </div>\n    `;\n  });\n}\n\nhtmlBody += `\n    <div class=\"footer\">\n      <p>Generated by n8n Automation</p>\n    </div>\n  </div>\n</body>\n</html>\n`;\n\n// \u5f8c\u7d9a\u306eGmail\u30ce\u30fc\u30c9\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\nreturn [\n  {\n    json: {\n      subject: subject,\n      htmlBody: htmlBody\n    }\n  }\n];"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "timezone": "America/New_York",
    "errorWorkflow": "",
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "versionId": "f722d1f3-eeaa-4922-a1da-b2c9abca521b",
  "connections": {
    "AI News Agent": {
      "main": [
        [
          {
            "node": "Format for Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format for Gmail": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Prepare News Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "News Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI News Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Prepare News Query": {
      "main": [
        [
          {
            "node": "AI News Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tavily News Search": {
      "ai_tool": [
        [
          {
            "node": "AI News Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI News Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}