8
n8n 中文网amn8n.com

股市每日摘要

高级

这是一个AI领域的自动化工作流,包含 22 个节点。主要使用 Set, Wait, Switch, SplitOut, Aggregate 等节点,结合人工智能技术实现智能自动化。 使用 Bright Data 爬取和 Gemini AI 邮件报告的股市每日摘要

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "db80165df40cb07c0377167c050b3f9ab0b0fb04f0e8cae0dc53f5a8527103ca",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e27afbc7-8cae-44b6-b506-474bb2692f08",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        -640,
        -300
      ],
      "webhookId": "cf27222d-20db-4ba5-bd4c-e6ca05efd4d7",
      "parameters": {
        "amount": 20
      },
      "typeVersion": 1.1
    },
    {
      "id": "2cc8d35f-f255-4adc-b1d7-7f9ab34dde66",
      "name": "获取进度",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1020,
        -400
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/progress/{{ $json.snapshot_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_BRIGHTDATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "eb6ab86c-3e8b-4dc6-8d70-3346531905fa",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -840,
        -400
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "ready",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4712e222-2bad-4d91-be87-ab0e0693c0c6",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "ready"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "running",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9a473960-6ba5-4f1b-afc6-396348bd338d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "=running"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "88b7e912-af0c-4527-baa3-4f8cf0b072d1",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1660,
        -400
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "json"
      },
      "typeVersion": 1
    },
    {
      "id": "d0ee4823-0536-415e-8fa9-861c1701665d",
      "name": "示例数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -1860,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8d1bd0c8-37bf-4028-a20c-ac214ec06d7b",
              "name": "json",
              "type": "array",
              "value": "=[\n  {\n    \"ticker\": \"NVDA\",\n    \"name\": \"NVIDIA Corporation\",\n    \"market_cap\": \"≈ $3.6T\"\n  },\n  {\n    \"ticker\": \"MSFT\",\n    \"name\": \"Microsoft Corporation\",\n    \"market_cap\": \"≈ $3.6T\"\n  },\n  {\n    \"ticker\": \"AAPL\",\n    \"name\": \"Apple Inc.\",\n    \"market_cap\": \"≈ $3.0T\"\n  },\n  {\n    \"ticker\": \"AMZN\",\n    \"name\": \"Amazon.com Inc.\",\n    \"market_cap\": \"≈ $2.2T\"\n  },\n  {\n    \"ticker\": \"GOOGL\",\n    \"name\": \"Alphabet Inc.\",\n    \"market_cap\": \"≈ $1.9T\"\n  },\n  {\n    \"ticker\": \"META\",\n    \"name\": \"Meta Platforms Inc.\",\n    \"market_cap\": \"≈ $1.5T\"\n  },\n  {\n    \"ticker\": \"BRK.B\",\n    \"name\": \"Berkshire Hathaway Inc.\",\n    \"market_cap\": \"≈ $1.1T\"\n  },\n  {\n    \"ticker\": \"TSLA\",\n    \"name\": \"Tesla Inc.\",\n    \"market_cap\": \"≈ $830B\"\n  },\n  {\n    \"ticker\": \"UNH\",\n    \"name\": \"UnitedHealth Group Inc.\",\n    \"market_cap\": \"≈ $450B\"\n  },\n  {\n    \"ticker\": \"JNJ\",\n    \"name\": \"Johnson & Johnson\",\n    \"market_cap\": \"≈ $450B\"\n  }\n]\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2aab292f-0287-4da6-86ee-83c5a9aee30a",
      "name": "设置关键词",
      "type": "n8n-nodes-base.set",
      "position": [
        -1480,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8d9e80d9-16dd-4658-928f-d94735209bfd",
              "name": "keyword",
              "type": "string",
              "value": "={{ $json.ticker }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "13f81727-f586-4fb6-be73-4880c9efd165",
      "name": "金融时报爬虫",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1260,
        -400
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $('set keyword').all().map(item => item.json)}}",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "gd_lmrpz3vxmz972ghd7"
            },
            {
              "name": "include_errors",
              "value": "true"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "keyword"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer YOUR_BRIGHTDATA_API_KEY"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "5e828381-8268-4114-b16c-a60c4ca23e80",
      "name": "获取快照 + 数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -620,
        -480
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/snapshot/{{ $json.snapshot_id }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_BRIGHTDATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c2826ee-30bb-4438-a531-c370edbe2103",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -300,
        -280
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "9cd0f2fd-248b-4047-aeb3-1a548ad02514",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -320,
        -620
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1I5CvpHlmDsIFOfnGg4DEtniem0oTiumWWzGs4CV6AuM/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1I5CvpHlmDsIFOfnGg4DEtniem0oTiumWWzGs4CV6AuM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1I5CvpHlmDsIFOfnGg4DEtniem0oTiumWWzGs4CV6AuM/edit?usp=drivesdk",
          "cachedResultName": "Stock Monitor"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ZAI2a6Qt80kX5a9s",
          "name": "Google Sheets account✅ "
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "d9797a77-bdf3-4600-bcd7-21311bb405fd",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        0,
        -260
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "Xp5T9q3YYxBIw2nd",
          "name": "Google Gemini(PaLM) Api account✅"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ef5165a4-0452-4b20-b2fa-994429f3bc5b",
      "name": "创建摘要",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        0,
        -480
      ],
      "parameters": {
        "text": "=\n\n## 📤 SYSTEM PROMPT: Daily Stock Summary Email Generator (for n8n AI Agent)\n\n````markdown\n## 🎯 ROLE\nYou are a financial summary agent integrated in an n8n workflow. Your role is to:\n- Analyze incoming JSON data of top 10 U.S. stocks.\n- Identify meaningful insights: trends, outliers, sentiment, sector behavior.\n- Format this into a **clear, styled HTML email body** for professional users.\n- Return the **HTML content only** – ready to send via n8n’s email nodes.\n\n---\n\n## 📥 INPUT FORMAT (JSON)\n\nYou will receive daily JSON input structured like this:\n\n\nThe day and date today is {{ $now.format('cccc yyyy-MM-dd t ') }}\n\nHere is today’s data: =\n\n```\n\n{{ $json.data.toJsonString() }}\n\n```\n\n---\n\n## ✅ TASKS\n\n1. **Analyze market trends** based on price movements and sentiment.\n2. **Highlight top 2 gainers and losers**, including reasoning from news or change %.\n3. **Generate a stock table** (Ticker, Name, Price Change, Sentiment Icon).\n4. **Include 3–5 key takeaways**, insights, or investor watch notes.\n5. **Add upcoming events** if mentioned in news or based on date.\n6. Format everything as **HTML only**, ready for use in an email body.\n\n---\n\n## ✨ OUTPUT FORMAT (HTML Only)\n\n* Include inline styles (no external CSS).\n* Use semantic structure:\n\n  * `<h2>` for main title\n  * `<ul>` for movers and insights\n  * `<table>` for stock data\n* Use icons or colors for sentiment: 🟢 Positive, 🟡 Neutral, 🔴 Negative\n* Footer: “Generated automatically by your AI-powered stock monitor”\n\n---\n\n## ⚠️ CONSTRAINTS\n\n* DO NOT include subject or email headers\n* DO NOT output plaintext explanations or markdown\n* Output **HTML only**, clean and professional\n\n---\n\n## 📬 GOAL\n\nDeliver a polished, mobile-friendly, and insightful daily stock market summary email that can be sent directly by n8n. Final output should require zero manual edits.\n\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "cf744498-62bf-4e6a-8570-dda7fea35fe5",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2140,
        -400
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d564ee93-181f-461b-8ace-2dcb26439b6c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1940,
        -600
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 420,
        "content": "## 添加要跟踪的股票"
      },
      "typeVersion": 1
    },
    {
      "id": "0c7e5d90-ce9e-456c-9f48-ba6872557467",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -600
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 420,
        "content": "## 拆分并设置字段名称"
      },
      "typeVersion": 1
    },
    {
      "id": "64d932ee-f0b1-458a-a017-505676666c18",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -600
      ],
      "parameters": {
        "color": 2,
        "height": 420,
        "content": "## 金融时报爬虫"
      },
      "typeVersion": 1
    },
    {
      "id": "bb55cc08-f262-42c1-9951-00771689495a",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -680
      ],
      "parameters": {
        "color": 4,
        "width": 620,
        "height": 520,
        "content": "## 检查进度状态并获取结果"
      },
      "typeVersion": 1
    },
    {
      "id": "9bc67859-d0b7-4d48-84d3-d0b9c90e8ca5",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 260,
        "content": "## 获取爬取结果"
      },
      "typeVersion": 1
    },
    {
      "id": "9627ec91-d2c4-4076-b39f-9f8be978177b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -420
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "## 汇总结果以传递给 AI 生成邮件摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "e01b8ad5-e028-4c81-9162-b27ae75687a3",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -720
      ],
      "parameters": {
        "color": 3,
        "width": 520,
        "height": 600,
        "content": "## 创建草稿邮件并通知管理员"
      },
      "typeVersion": 1
    },
    {
      "id": "8a23ca78-36e5-4ce3-b81d-fa62d770aa36",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -680
      ],
      "parameters": {
        "color": 6,
        "width": 280,
        "height": 240,
        "content": "## 将结果保存到 Google Sheets"
      },
      "typeVersion": 1
    },
    {
      "id": "3f953ffd-4faa-4cd5-bd3a-b3a6d021eebf",
      "name": "Gmail1",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        180,
        -260
      ],
      "webhookId": "fe4a416a-43f3-4ad1-80c8-51f1de4c2343",
      "parameters": {
        "sendTo": "kimothozacharia5@gmail.com",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', `A detailed summary of the stock performance today. Must Look good`, 'string') }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', `Daily Stock report for {date today}`, 'string') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "8PS0qVYNzZvoWNA7",
          "name": "phoenix✅"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "pinData": {
    "Financial times scraper": [
      {
        "snapshot_id": "s_mcbvdqgz1avn39assa"
      },
      {
        "snapshot_id": "s_mcbvdqht249242mqlq"
      },
      {
        "snapshot_id": "s_mcbvdqg4px7h201w9"
      },
      {
        "snapshot_id": "s_mcbvdqh4ci8ij15d1"
      },
      {
        "snapshot_id": "s_mcbvdqgs12legdw0a2"
      },
      {
        "snapshot_id": "s_mcbvdqhpqyr6tf8q"
      },
      {
        "snapshot_id": "s_mcbvdqgu1ti5q0ginr"
      },
      {
        "snapshot_id": "s_mcbvdqi21uyjc3tefw"
      },
      {
        "snapshot_id": "s_mcbvdqgzp73zxysyr"
      },
      {
        "snapshot_id": "s_mcbvdqgi2f3l95krzm"
      }
    ]
  },
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Get progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "ai_tool": [
        [
          {
            "node": "create summary",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get snapshot + data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "create summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "set keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SAMPLE DATA": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set keyword": {
      "main": [
        [
          {
            "node": "Financial times scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get progress": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        []
      ]
    },
    "create summary": {
      "main": [
        []
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "SAMPLE DATA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get snapshot + data": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Financial times scraper": {
      "main": [
        [
          {
            "node": "Get progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "create summary",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量22
分类1
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Imperol

Imperol

@imperolq

Automation expert with years of experience helping businesses improve their efficiency and productivity with smart automations that are affordable, scalable, and flexible.

外部链接
在 n8n.io 查看

分享此工作流