8
n8n 中文网amn8n.com

AI 股票分析与评分及 Gmail 报告发送

高级

这是一个Crypto Trading, AI RAG领域的自动化工作流,包含 24 个节点。主要使用 Gmail, Markdown, Agent, HttpRequestTool, ToolThink 等节点。 基于 AI 的股票分析系统,包含 AI 评分和 Gmail 报告发送功能

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • PostgreSQL 数据库连接信息
  • Supabase URL 和 API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "e7ccf4281d5afb175c79c02db95b45f15d5b53862cb6bc357c5e5bc26567f35c",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ec0ab7b1-7f50-45d0-aeb8-147f525aa40c",
      "name": "思考",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1264,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "631a10cf-d3d5-4f0d-9831-3b3775c76e38",
      "name": "Supabase 向量存储1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        992,
        464
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 5,
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "danelfin",
          "cachedResultName": "danelfin"
        },
        "useReranker": true,
        "toolDescription": "Work with data in supabase to understand danelfin scoring and strategy",
        "includeDocumentMetadata": false
      },
      "credentials": {
        "supabaseApi": {
          "id": "4TXwWjRCifw2A3yw",
          "name": "Supabase tm"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0295201f-5b30-4bb4-bacd-f5ed57a76ab2",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        960,
        624
      ],
      "parameters": {
        "options": {
          "dimensions": 1536
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "OQJASLp1qn1StvpI",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "21b0a10e-69cf-4ba7-b1b8-7581900f242e",
      "name": "Cohere重新排序器",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        1120,
        640
      ],
      "parameters": {
        "modelName": "rerank-english-v3.0"
      },
      "credentials": {
        "cohereApi": {
          "id": "PCdrjFiCsNkbtU2E",
          "name": "CohereApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "879e5393-01ac-4f28-bb89-d57164a49d2e",
      "name": "Danelfin 请求",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        624,
        144
      ],
      "parameters": {
        "text": "=Manage it with the strategy Agent",
        "options": {
          "systemMessage": "=# You are an expert of making request to an api that retrieves you financial data, YOU ARE NOT A CHATBOT, YOUR ANSWERS HAVE ALWAYS TO BE CONCLUSIVE\n\n\n# Danelfin REST API Reference\n\n## Authentication\n- Header: `x-api-key: {API_KEY}`\n- Base URL: `https://apirest.danelfin.com`\n\n## Endpoints\n- `/ranking` - GET ticker scores/rankings\n- `/sectors` - GET sector list\n- `/sectors/{slug}` - GET sector history\n- `/industries` - GET industry list  \n- `/industries/{slug}` - GET industry history\n\n## /ranking Parameters\n**Required:** At least one of `ticker` OR `date`\n\n- `date` - YYYY-MM-DD format\n- `ticker` - Symbol (e.g. AAPL)\n- `market` - Exchange filter (NYSE, NASDAQ)\n- `aiscore`, `fundamental`, `technical`, `sentiment`, `low_risk` - Exact score 1-10\n- `*_min` versions - Minimum thresholds 1-10\n- `buy_track_record`, `sell_track_record` - 1/0 boolean\n- `sector` - Sector slug\n- `industry` - Industry slug\n- `asset` - stock/etf\n- `fields` - Comma-separated field list\n\n## Response Formats\n- With ticker: `{date: {scores}}`\n- Without ticker: `{date: {ticker: {scores}}}`\n- Score filter: `{ticker: {scores}}`\n\n## Score Fields\n- `aiscore` - AI Score 1-10\n- `technical` - Technical Score 1-10\n- `fundamental` - Fundamental Score 1-10\n- `sentiment` - Sentiment Score 1-10\n- `low_risk` - Low-Risk Score 1-10\n- `buy_track_record` - Boolean\n- `sell_track_record` - Boolean\n\n## Processing Rules\n1. Parse user intent → extract date, ticker, filters\n2. Validate ticker OR date present (default to today if neither)\n3. Build query string\n4. Send GET request with API key header\n5. Handle errors: 400 = bad params, 403 = auth fail\n6. Convert string scores to integers\n7. Sort by aiscore descending unless specified\n8. Return formatted results\n\n## Query Examples\n- Ticker history: `?ticker=AAPL`\n- Top 100 today: `?date={{ new Date().toISOString().split('T')[0] }}`\n- Score filter: `?date={{ new Date().toISOString().split('T')[0] }}&aiscore=10`\n- Sector filter: `?date={{ new Date().toISOString().split('T')[0] }}&sector=utilities&low_risk_min=5`\n\n## Error Codes\n- 200: Success\n- 400: Bad request - fix params\n- 403: Auth failed - abort\n\n## The http tool gives you acces to all 3 different endpoints\n\n## You must call the supabase RAG tool that gives you knowledge of Danelfin technology and strategy\n\n## Your current timestamp is {{ $now }}, by default always make queries from yesterday or the previous days where the market was opened. \n\n## If you have an error by consulting a stock scores, d'ont consult the one from the previous year, consult the one from the past day\n\n# Output: You always have to make a full deep report on the user query\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "5111ce59-f32a-47d8-a16d-eff54cdc0d4a",
      "name": "排名",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        336,
        464
      ],
      "parameters": {
        "url": "https://apirest.danelfin.com/ranking",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "ranking endpoint"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "WtAyYH2L9Z9enZqX",
          "name": "danelfin"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2b8207dd-aa9c-4032-a4d0-fc98bfa59370",
      "name": "板块",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        448,
        464
      ],
      "parameters": {
        "url": "https://apirest.danelfin.com/sectors",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "sectors endpoint"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "WtAyYH2L9Z9enZqX",
          "name": "danelfin"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "baf0f5de-3629-4f26-8a2e-3195f4928c78",
      "name": "行业",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        544,
        464
      ],
      "parameters": {
        "url": "https://apirest.danelfin.com/industries",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "industries endpoint"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "WtAyYH2L9Z9enZqX",
          "name": "danelfin"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b3ff8d0f-1298-4dd9-ac16-e1221a43bd17",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -48
      ],
      "parameters": {
        "color": 4,
        "width": 1352,
        "height": 792,
        "content": "# 主代理 /danelfin 评分"
      },
      "typeVersion": 1
    },
    {
      "id": "a15112eb-32ba-4d73-a2ee-8f1d388052d8",
      "name": "发送报告",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1200,
        144
      ],
      "webhookId": "f6586c17-da23-454b-adad-6d02fc79ec4b",
      "parameters": {
        "sendTo": "paul@taskmorphr.com",
        "message": "={{ $json.data }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Report"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "zDJ58xrpmivGPuAW",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "21e95e0c-2774-481b-a546-8313d841c848",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        48,
        144
      ],
      "webhookId": "730fb36d-bd91-468d-8eab-9d028698b16c",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "99a81cec-74ff-4962-ab52-9f22b9d89713",
      "name": "Postgres聊天内存1",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        192,
        416
      ],
      "parameters": {},
      "credentials": {
        "postgres": {
          "id": "44lwBYXMr6Vx0Fmq",
          "name": "Postgres account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "875650d8-6399-46d2-b1e3-a63ee762ad2b",
      "name": "设置推理模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        80,
        416
      ],
      "parameters": {
        "model": "x-ai/grok-4",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "1t22HwKbMlWsWxcJ",
          "name": "OpenRouter account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9ef4549b-449c-41bd-8a3d-b79fe4b8cbd0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        80
      ],
      "parameters": {
        "color": 5,
        "width": 288,
        "height": 208,
        "content": "### 询问任何股票、行业、板块、潜在交易等"
      },
      "typeVersion": 1
    },
    {
      "id": "b492be0c-f316-4c1f-af73-2cde40a7efcb",
      "name": "Markdown 转 HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        1008,
        144
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {},
        "markdown": "={{ $json.output }}"
      },
      "typeVersion": 1
    },
    {
      "id": "862c2311-fd44-43cd-b288-460a3595ee8b",
      "name": "Supabase向量存储",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        496,
        896
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "danelfin",
          "cachedResultName": "danelfin"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "4TXwWjRCifw2A3yw",
          "name": "Supabase tm"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0d2987bc-01ec-4c6a-b263-48f4f495323a",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        640,
        1120
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {}
            ]
          }
        },
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "f70e3c0a-e4e6-4c44-a24e-49e0f4fcd854",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        688,
        1280
      ],
      "parameters": {
        "options": {
          "splitCode": "markdown"
        },
        "chunkSize": 700
      },
      "typeVersion": 1
    },
    {
      "id": "e3689a2b-5c64-473c-869a-45dae5997cb6",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        368,
        1136
      ],
      "parameters": {
        "options": {
          "dimensions": 1536
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "OQJASLp1qn1StvpI",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "56b19f7f-8451-4c39-9349-737ce968bd4c",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        800
      ],
      "parameters": {
        "color": 7,
        "width": 1136,
        "height": 660,
        "content": "## 将数据加载到向量数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "514b7f03-e91c-49a3-bc46-da2f4ab75a73",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        896
      ],
      "parameters": {
        "width": 416,
        "height": 272,
        "content": "## 加载包含以下信息的 PDF"
      },
      "typeVersion": 1
    },
    {
      "id": "8bca3f8f-0309-446b-9e84-41855e0075f9",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -48
      ],
      "parameters": {
        "color": 6,
        "width": 640,
        "height": 2240,
        "content": "# 工作流描述与设置指南"
      },
      "typeVersion": 1
    },
    {
      "id": "5cd42ade-bb36-49d9-b2c1-29cf96b581d8",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        16
      ],
      "parameters": {
        "color": 3,
        "width": 576,
        "height": 560,
        "content": "## 需要量身定制的工作流?告诉我您的业务需求并获得免费提案:"
      },
      "typeVersion": 1
    },
    {
      "id": "2405dbd4-f266-466f-aab3-8bff9f72871f",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        416
      ],
      "parameters": {
        "color": 3,
        "width": 224,
        "height": 128,
        "content": "### 🛠️ 自己构建"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "ranking": {
      "ai_tool": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "sectors": {
      "ai_tool": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "industries": {
      "ai_tool": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Danelfin request": {
      "main": [
        [
          {
            "node": "Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown to HTML": {
      "main": [
        [
          {
            "node": "Send report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory1": {
      "ai_memory": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Set a reasoning model": {
      "ai_languageModel": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store1": {
      "ai_tool": [
        [
          {
            "node": "Danelfin request",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Danelfin request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 加密货币交易, AI RAG 检索增强

需要付费吗?

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

工作流信息
难度等级
高级
节点数量24
分类2
节点类型14
难度说明

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

作者

Automation expert & n8n power user. I build advanced workflows combining AI, outbound, and business logic. Grab my templates or reach out for custom builds.

外部链接
在 n8n.io 查看

分享此工作流