N
n8n Store
Workflow Market
AI Daily News

AI Daily News

by derekschatz0 views

Description

Categories

🤖 AI & Machine Learning

Nodes Used

n8n-nodes-base.setn8n-nodes-base.coden8n-nodes-base.gmailn8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.httpRequestn8n-nodes-base.scheduleTrigger
PriceFree
Views0
Last Updated11/28/2025
workflow.json
{
  "id": "1TrBJJYAdnNO3EjR",
  "meta": {
    "instanceId": "1a11bd3c275e3c33214cb43c016339cfab9e21a0caa657df228ee3ea5a628101",
    "templateCredsSetupCompleted": true
  },
  "name": "AI Daily News",
  "tags": [],
  "nodes": [
    {
      "id": "a808eaa1-744e-4a01-98d8-d96428346d11",
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -120,
        60
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "702221b3-c127-462a-a4f1-9b32518dd4ea",
      "name": "Set Dates",
      "type": "n8n-nodes-base.set",
      "position": [
        80,
        60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "current-date",
              "name": "currentDate",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "id": "yesterday-date",
              "name": "lastweekDate",
              "type": "string",
              "value": "={{ $now.minus({days: 7}).format('yyyy-MM-dd') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e4e02799-c6e2-44ce-8015-5fd71ef9a848",
      "name": "Workflow Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -400
      ],
      "parameters": {
        "color": 6,
        "width": 350,
        "height": 400,
        "content": "## Daily AI News Summary Workflow\n\nThis workflow runs every day at 9 AM to:\n\n1. **Fetch Latest AI News**: Uses Perplexity to find recent AI developments\n2. **Categorize Content**: Organizes news into three key areas:\n   - 🚀 New Technology (breakthroughs, models, research)\n   - 💡 Tips & Tricks (practical applications, tutorials)\n   - 🛡️ AI Ethics & Security (privacy, safety, regulations)\n3. **Format & Send**: Creates a beautiful HTML email with summaries and links\n\n### Setup Required:\n- Perplexity API credentials\n- SMTP email credentials\n- Update recipient email address\n\n### Customization:\n- Change schedule time in Daily Trigger\n- Modify categories in Perplexity prompt\n- Adjust email styling in Format Email Content node"
      },
      "typeVersion": 1
    },
    {
      "id": "dd06d61f-a4bd-4813-9586-d690e0177dc8",
      "name": "Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        -280
      ],
      "parameters": {
        "color": 3,
        "width": 300,
        "height": 260,
        "content": "⚙️ **Configuration Needed:**\n\n1. **Perplexity API**: Add your Perplexity API key to \"perplexity-credentials\"\n\n2. **Email Settings**: \n   - Update SMTP credentials in \"email-credentials\"\n   - Change recipient email in \"Send Email Summary\" node\n   - Update sender email if needed\n\n3. **Timing**: Modify schedule in \"Daily Trigger\" if you want different timing\n\n4. **Content**: Customize the news categories or add more in the Perplexity prompt"
      },
      "typeVersion": 1
    },
    {
      "id": "d1990f1e-04bb-4a64-a3ed-9f4dc01416f3",
      "name": "Perplexity AI News Search",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        60
      ],
      "parameters": {
        "url": "https://api.perplexity.ai/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"sonar\",\n  \"messages\": [\n    {\n      \"content\": \"Summarize top AI news from the last week for the following categories: \\\"New Tech\\\", \\\"AI Security\\\", \\\"Top Stories\\\", \\\"Trending Topics\\\". Provide Links. \",\n      \"role\": \"user\"\n    }\n  ],\n  \"max_tokens\": 1000,\n  \"temperature\": 0.2,\n  \"top_p\": 0.9,\n  \"return_images\": false,\n  \"return_related_questions\": false,\n  \"search_recency_filter\": \"week\",\n  \"top_k\": 0,\n  \"stream\": false,\n  \"presence_penalty\": 0,\n  \"frequency_penalty\": 1,\n  \"web_search_options\": {\n    \"search_context_size\": \"low\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer XXX-XXXXX"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "492432d5-3c18-4517-85b9-4407c4ed26a3",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        820,
        60
      ],
      "webhookId": "6e5776e8-b6b9-4c56-8b3a-812f68959433",
      "parameters": {
        "sendTo": "",
        "message": "={{ $json.emailHtml }}",
        "options": {},
        "subject": "={{ $json.emailSubject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "QFihRQlqedvJQxrX",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9d871937-9d72-40ff-8c26-8680475ae183",
      "name": "Format Email Content1",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        60
      ],
      "parameters": {
        "jsCode": "try {\n  // Get the Perplexity response - using the correct node reference\n  const perplexityData = $input.first().json;\n  const newsContent = perplexityData.choices[0].message.content;\n  const citations = perplexityData.citations || [];\n  \n  // Get current date from Set Dates node\n  const currentDate = $('Set Dates').first().json.currentDate;\n  \n  // Format the news content into HTML\n  const formattedContent = newsContent\n    .replace(/\\n/g, '<br>')\n    .replace(/## (.*?)\\n/g, '<h2 style=\"color: #2563eb; margin: 25px 0 15px 0; border-bottom: 2px solid #e5e7eb; padding-bottom: 8px;\">$1</h2>')\n    .replace(/\\*\\*(.*?)\\*\\*/g, '<strong>$1</strong>')\n    .replace(/\\*(.*?)\\*/g, '<em>$1</em>')\n    .replace(/- \\*\\*(.*?)\\*\\*:/g, '<div style=\"margin: 15px 0;\"><strong style=\"color: #1e40af;\">• $1:</strong>')\n    .replace(/\\[\\d+\\]/g, '') // Remove citation numbers for cleaner display\n    .replace(/(https?:\\/\\/[^\\s]+)/g, '<a href=\"$1\" style=\"color: #2563eb; text-decoration: none;\">Read more</a>');\n  \n  // Create citations section if available\n  let citationsHtml = '';\n  if (citations.length > 0) {\n    citationsHtml = `\n      <div style=\"margin-top: 30px; padding: 20px; background-color: #f0f9ff; border-radius: 8px; border: 1px solid #e0f2fe;\">\n        <h3 style=\"color: #0369a1; margin: 0 0 15px 0;\">📚 Sources</h3>\n        <ul style=\"margin: 0; padding-left: 20px;\">`;\n    \n    citations.forEach((citation, index) => {\n      citationsHtml += `<li style=\"margin: 8px 0;\"><a href=\"${citation}\" style=\"color: #2563eb; text-decoration: none;\">${citation}</a></li>`;\n    });\n    \n    citationsHtml += `</ul></div>`;\n  }\n  \n  // Create complete email HTML\n  const emailHtml = `\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <meta charset=\"utf-8\">\n      <title>Daily AI News Summary</title>\n    </head>\n    <body style=\"font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; line-height: 1.6; background-color: #f9fafb;\">\n      <header style=\"text-align: center; margin-bottom: 30px; padding: 30px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\">\n        <h1 style=\"margin: 0; font-size: 2.5em; font-weight: 700;\">🤖 Daily AI News Summary</h1>\n        <p style=\"margin: 15px 0 0 0; font-size: 1.2em; opacity: 0.9;\">${currentDate}</p>\n        <p style=\"margin: 10px 0 0 0; font-size: 1em; opacity: 0.8;\">Your curated AI news digest</p>\n      </header>\n      \n      <main style=\"background-color: white; padding: 30px; border-radius: 12px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\">\n        <div style=\"margin-bottom: 25px;\">\n          <div style=\"margin: 20px 0; padding: 20px; background-color: #f8fafc; border-radius: 8px; border-left: 4px solid #3b82f6;\">\n            ${formattedContent}\n          </div>\n        </div>\n        \n        ${citationsHtml}\n        \n        <div style=\"margin-top: 30px; padding: 20px; background-color: #ecfdf5; border-radius: 8px; border: 1px solid #d1fae5;\">\n          <p style=\"margin: 0; color: #065f46; font-size: 0.9em; text-align: center;\">\n            <strong>💡 Tip:</strong> Click on any links to read the full articles and stay ahead of AI trends!\n          </p>\n        </div>\n      </main>\n      \n      <footer style=\"margin-top: 30px; padding: 20px; text-align: center; color: #6b7280; font-size: 0.9em;\">\n        <p style=\"margin: 0;\">Generated by your AI News Workflow</p>\n        <p style=\"margin: 5px 0 0 0;\">${new Date().toLocaleString()}</p>\n      </footer>\n    </body>\n    </html>\n  `;\n  \n  return {\n    emailHtml,\n    emailSubject: `🤖 Daily AI News Summary - ${currentDate}`,\n    rawNewsContent: newsContent,\n    citationCount: citations.length\n  };\n  \n} catch (error) {\n  console.error('Error processing news data:', error);\n  \n  // Get current date safely\n  let currentDate;\n  try {\n    currentDate = $('Set Dates').first().json.currentDate;\n  } catch {\n    currentDate = new Date().toISOString().split('T')[0];\n  }\n  \n  // Get raw response safely  \n  let rawResponse;\n  try {\n    rawResponse = $input.first().json;\n  } catch {\n    rawResponse = 'Unable to retrieve response';\n  }\n  \n  // Fallback email in case of parsing errors\n  const fallbackHtml = `\n    <!DOCTYPE html>\n    <html>\n    <body style=\"font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px;\">\n      <h1 style=\"color: #dc2626;\">🤖 Daily AI News Summary - ${currentDate}</h1>\n      <div style=\"padding: 20px; background-color: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; margin: 20px 0;\">\n        <h2 style=\"color: #dc2626; margin-top: 0;\">⚠️ Processing Error</h2>\n        <p>There was an issue processing today's AI news. Please check the workflow configuration.</p>\n        <p><strong>Error:</strong> ${error.message}</p>\n        <details style=\"margin-top: 15px;\">\n          <summary style=\"cursor: pointer; font-weight: bold;\">View Raw Response</summary>\n          <pre style=\"background-color: #f3f4f6; padding: 15px; border-radius: 4px; overflow-x: auto; margin-top: 10px; font-size: 12px;\">${JSON.stringify(rawResponse, null, 2)}</pre>\n        </details>\n      </div>\n    </body>\n    </html>\n  `;\n  \n  return {\n    emailHtml: fallbackHtml,\n    emailSubject: `⚠️ AI News Summary Error - ${currentDate}`,\n    error: error.message,\n    rawResponse: JSON.stringify(rawResponse)\n  };\n}\n"
      },
      "typeVersion": 2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "24396203-6135-419c-a500-c97583f0eb1a",
  "connections": {
    "Set Dates": {
      "main": [
        [
          {
            "node": "Perplexity AI News Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Set Dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email Content1": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perplexity AI News Search": {
      "main": [
        [
          {
            "node": "Format Email Content1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流