AAVE投资组合专业AI助手

高级

这是一个Finance、AI领域的自动化工作流,包含 23 个节点。主要使用 Set、Code、Gmail、Telegram、GoogleSheets 等节点,结合人工智能技术实现智能自动化。 Telegram + 邮件 + GPT-4o + Moralis

前置要求
  • Google 账号和 Gmail API 凭证
  • Telegram Bot Token
  • Google Sheets API 凭证
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ECZnCUL1v6EUrpHN",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6",
    "templateCredsSetupCompleted": true
  },
  "name": "AAVE投资组合专业AI助手",
  "tags": [],
  "nodes": [
    {
      "id": "8b4dd2cc-ecb4-46bb-bf3e-7715cf88a108",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2760,
        0
      ],
      "webhookId": "dc4b5b74-52d4-4132-a9ee-4bbb1bd1d93f",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "<<Insert ChatID>>",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "l6TLZaqCatJTKOw8",
          "name": "DeFi Monitor"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6506d454-1cd2-44b7-8207-9797141dce5a",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        620,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "94d3ce0c-fafd-4ca0-a767-a164a5b2c160",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1320,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "yUizd8t0sD5wMYVG",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "51b04d71-e0fa-48bd-a6bb-80021478010b",
      "name": "获取DeFi摘要",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1600,
        320
      ],
      "parameters": {
        "url": "=https://deep-index.moralis.io/api/v2.2/wallets/{{$json.Wallet_Address}}/defi/summary",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "Get DeFi protocols by wallet",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "lr0Flt0yHKKGlKTj",
          "name": "Moralis"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "981c2af0-b001-4f82-903a-b7c843fa0df9",
      "name": "获取DeFi持仓摘要",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1900,
        320
      ],
      "parameters": {
        "url": "=https://deep-index.moralis.io/api/v2.2/wallets/{{$json.Wallet_Address}}/defi/positions",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "Get DeFi positions by wallet",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "lr0Flt0yHKKGlKTj",
          "name": "Moralis"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4f95523b-4877-4f29-a9f1-21c2d153bbb6",
      "name": "按协议获取DeFi持仓",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        2180,
        320
      ],
      "parameters": {
        "url": "=https://deep-index.moralis.io/api/v2.2/wallets/{{$json.Wallet_Address}}/defi/aave-v3/positions",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "Get detailed DeFi positions by wallet and protocol",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "lr0Flt0yHKKGlKTj",
          "name": "Moralis"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1df5e729-f892-4a1e-8c4a-f50af0fc318e",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2780,
        260
      ],
      "webhookId": "ef883c10-ea03-44f0-b7f7-e3c855cdb175",
      "parameters": {
        "sendTo": "don.jayamaha@treasurium.capital",
        "message": "={{ $json.htmlBody }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Aave DeFi Health Report"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "gJq9VKcqPXjhNh02",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "60badfca-b47c-4e07-abc4-be75e2297a71",
      "name": "格式化邮件",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        260
      ],
      "parameters": {
        "jsCode": "const aiOutput = $json.output || \"No data available.\";\nconst date = new Date().toISOString().split('T')[0];\n\n// Extract wallet using regex\nconst walletMatch = aiOutput.match(/Wallet:\\s*(0x[a-fA-F0-9]{40})/);\nconst wallet = walletMatch ? walletMatch[1] : \"Unknown Wallet\";\n\n// Convert \\n to <br> for HTML formatting\nconst htmlFormatted = aiOutput\n  .replace(/---/g, '<hr>') // Replace section breaks\n  .replace(/\\n{2,}/g, '<br><br>') // Extra line spacing between sections\n  .replace(/\\n/g, '<br>'); // Standard line breaks\n\n// Wrap in basic HTML styling\nconst htmlBody = `\n  <div style=\"font-family: Arial, sans-serif; font-size: 14px; line-height: 1.6; color: #222;\">\n    ${htmlFormatted}\n  </div>\n`;\n\nconst textBody = aiOutput;\nconst subject = `🛡️ Aave DeFi Health Report – ${date}`;\n\nreturn [\n  {\n    json: {\n      wallet,\n      subject,\n      htmlBody,\n      textBody\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "cf7e92d5-5201-4273-a65d-bb80f2d1f993",
      "name": "AAVE投资组合专业AI助手",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1740,
        0
      ],
      "parameters": {
        "text": "={{ $json.Wallet_Address }}",
        "options": {
          "systemMessage": "You are a blockchain DeFi data assistant. Your task is to fetch, analyze, and summarize Aave-related DeFi positions using the Moralis DeFi API, then deliver a human-readable report to the user via Telegram.\n\nYour task is to:\n1. Fetch, analyze, and summarize Aave-related DeFi positions using the Moralis DeFi API.\n2. Collect data from the following three API endpoints:\n   - **getDefiSummary**  \n     URL: https://deep-index.moralis.io/api/v2.2/wallets/{{ $json.wallet_address }}/defi/summary  \n     Description: Retrieves a list of all DeFi protocols the wallet is interacting with.\n\n   - **getDefiPositionsSummary**  \n     URL: https://deep-index.moralis.io/api/v2.2/wallets/{{ $json.wallet_address }}/defi/positions  \n     Description: Provides a summary of DeFi protocol positions for the wallet, including collateral and debt levels.\n\n   - **getDefiPositionsByProtocol**  \n     URL: https://deep-index.moralis.io/api/v2.2/wallets/{{ $json.wallet_address }}/defi/aave-v3/positions  \n     Description: Returns detailed Aave position data, including pool details, underlying assets, balances, and health factors.\n\n🔹 Your output format must follow this structure:\n\n1️⃣ **Header**  \n📊 Aave DeFi Health Report\nWallet: {{wallet_address}}\nDate: {{$json.current_date}}\n\n2️⃣ **Position Summary (Loop over each Aave pool position)**  \n\n▪️ Pool: {{pool_name}}\n• Supply: ${{supplyBalanceUSD}}\n• Borrowed: ${{borrowBalanceUSD}}\n• Collateral: ${{collateralValueUSD}}\n• Health Factor: {{healthFactor}}\n• Liquidation Threshold: {{liquidationThreshold}}\n• Liquidation Risk: {{liquidationRisk ? \"⚠️ Yes\" : \"No\"}}\n\nUnderlying Assets:\n{{#each underlyingAssets}}\n- {{name}} ({{symbol}}): {{balance}}\n{{/each}}\n\n\n, \n\n4️⃣ **Readable Numbers:**  \n- Format large numbers with commas (e.g., `15,000` instead of `15000`).\n- Display ETH values to 4 decimal places for easy reading.\n\n5️⃣ **Fallback Message**  \nIf no Aave data is found, reply with:\n\n❌ No Aave V3 positions found for this wallet.\n\n6️⃣ **Example Telegram Output:**  \n\n📊 Aave DeFi Health Report\nWallet: 0xA221674eDB403A8F714F66Af74a2332c3CB5C0c3\nDate: 2025-05-08\n\n▪️ Pool: Aave Lending Pool\n• Supply: $15,000.00\n• Borrowed: $7,500.00\n• Collateral: $15,000.00\n• Health Factor: 2.00\n• Liquidation Threshold: 1.05\n• Liquidation Risk: No\n• Net Worth\nUnderlying Assets:\n\nDAI: 10,000\n\nUSDC: 5,000\n\n\n🔹 **Instructions:**  \n- Fetch data directly from the Moralis API endpoints provided.  \n- Parse and format the response according to the structure above.  \n- Send the formatted message to the specified Telegram Chat ID.  \n- If no data is available, send the fallback message instead.  \n- This report should be updated every 30 minutes and triggered on critical health factors (<1.1).\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "b57ddee3-7b92-4e89-9f58-37855a86ab31",
      "name": "监控的钱包地址",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        980,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rTPT4-e8AER5xJkm297ibk3e4wVhDd5zSi66kTOCW0U/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1rTPT4-e8AER5xJkm297ibk3e4wVhDd5zSi66kTOCW0U",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rTPT4-e8AER5xJkm297ibk3e4wVhDd5zSi66kTOCW0U/edit?usp=drivesdk",
          "cachedResultName": "Aave Wallet Address"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "vHcPQdCHeNGUtbT0",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "16293754-9aa6-4c6c-b9c5-e630e0ccbe25",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        1340,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "92ced85e-ea59-4c12-9ee9-fe0b46a91ed4",
              "name": "Wallet_Address",
              "type": "string",
              "value": "={{ $json.wallet_address }}"
            },
            {
              "id": "da0fed7a-5fe0-4202-b8e6-f8ccb7efcebe",
              "name": "=current_date",
              "type": "string",
              "value": "={{ new Date().toISOString().split('T')[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40cde5ac-8e8c-4e34-8ed8-24f2e13933cd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        -240
      ],
      "parameters": {
        "color": 4,
        "height": 420,
        "content": "## ⏰ 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "72748224-3c09-4cc0-8607-d64788b35c0f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -340
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 520,
        "content": "## 📄 Google表格钱包加载器"
      },
      "typeVersion": 1
    },
    {
      "id": "e1b4d506-5859-466b-8754-2e2bd2630685",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        -260
      ],
      "parameters": {
        "color": 2,
        "height": 440,
        "content": "## 🧩 设置变量"
      },
      "typeVersion": 1
    },
    {
      "id": "d2494da5-0196-438a-8da8-02fba036ab3b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1620,
        -340
      ],
      "parameters": {
        "color": 5,
        "width": 500,
        "height": 520,
        "content": "## 🤖 Aave AI报告生成器"
      },
      "typeVersion": 1
    },
    {
      "id": "b27d9c2c-853c-4aad-891d-eb1722089b17",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        280
      ],
      "parameters": {
        "color": 6,
        "height": 460,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "956ddef2-e2cb-4203-8aa1-e1bed07895f7",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1820,
        280
      ],
      "parameters": {
        "color": 6,
        "height": 460,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "30a23bfd-ea48-473d-b72c-0164c278d7b4",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2100,
        280
      ],
      "parameters": {
        "color": 6,
        "height": 460,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5ca1a63a-c5a3-4a96-a1b4-9942ef73467d",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2700,
        200
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 560,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "45ee0bc1-5c11-4b18-9f2f-8b09d015e6e8",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2400,
        200
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 560,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9b5d76f4-2e46-4847-a360-f4f2b3927e43",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2700,
        -300
      ],
      "parameters": {
        "color": 4,
        "height": 480,
        "content": "## 📲 Telegram消息投递"
      },
      "typeVersion": 1
    },
    {
      "id": "7384fbd5-7964-4b2a-a0bd-fa715217cac0",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        280
      ],
      "parameters": {
        "color": 3,
        "width": 260,
        "height": 560,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9baa4c9d-2cb0-40bb-bdb8-cea460451024",
      "name": "便利贴11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3240,
        -1400
      ],
      "parameters": {
        "width": 1280,
        "height": 2180,
        "content": "# 🧠 AAVE投资组合专业AI助手 – 完整系统文档"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0f2602e9-4654-4181-af14-06438b8a3a32",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AAVE Portfolio Professional AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getDefiSummary": {
      "ai_tool": [
        [
          {
            "node": "AAVE Portfolio Professional AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Wallet Addresses to Monitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AAVE Portfolio Professional AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "getDefiPositionsSummary": {
      "ai_tool": [
        [
          {
            "node": "AAVE Portfolio Professional AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "getDefiPositionsByProtocol": {
      "ai_tool": [
        [
          {
            "node": "AAVE Portfolio Professional AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wallet Addresses to Monitor": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AAVE Portfolio Professional AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Format Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Finance、AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

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

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

作者
Don Jayamaha Jr

Don Jayamaha Jr

@don-the-gem-dealer

With 12 years of experience as a Blockchain Strategist and Web3 Architect, I specialize in bridging the gap between traditional industries and decentralized technologies. My expertise spans tokenized assets, crypto payment integrations, and blockchain-driven market solutions.

外部链接
在 n8n.io 上查看 →

分享此工作流