8
n8n 中文网amn8n.com

碳足迹追踪器

高级

这是一个Document Extraction, AI Summarization领域的自动化工作流,包含 16 个节点。主要使用 Code, GoogleDrive, ScheduleTrigger, ScrapegraphAi 等节点。 使用ScrapeGraphAI分析和Google云端硬盘ESG报告的碳足迹追踪器

前置要求
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CarbonFootprintTracker2025",
  "meta": {
    "instanceId": "carbon-tracker-sustainability-workflow-n8n",
    "templateCredsSetupCompleted": false
  },
  "name": "碳足迹追踪器",
  "tags": [
    "sustainability",
    "esg",
    "carbon-footprint",
    "environmental",
    "reporting"
  ],
  "nodes": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        300,
        800
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b2c3d4e5-f6g7-8901-bcde-f23456789012",
      "name": "能源数据采集器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        600,
        700
      ],
      "parameters": {
        "userPrompt": "Extract energy consumption data and carbon emission factors. Use this schema: { \"energy_type\": \"electricity\", \"consumption_value\": \"1000\", \"unit\": \"kWh\", \"carbon_factor\": \"0.92\", \"emission_unit\": \"lbs CO2/kWh\", \"source\": \"EPA\", \"last_updated\": \"2024-01-15\" }",
        "websiteUrl": "https://www.epa.gov/energy/greenhouse-gas-equivalencies-calculator"
      },
      "credentials": {
        "scrapegraphAIApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c3d4e5f6-g7h8-9012-cdef-345678901234",
      "name": "交通数据采集器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        600,
        900
      ],
      "parameters": {
        "userPrompt": "Extract transportation emission factors and fuel efficiency data. Use this schema: { \"vehicle_type\": \"passenger_car\", \"fuel_type\": \"gasoline\", \"mpg\": \"25.4\", \"co2_per_gallon\": \"19.6\", \"co2_per_mile\": \"0.77\", \"unit\": \"lbs CO2\", \"source\": \"EPA\", \"category\": \"transport\" }",
        "websiteUrl": "https://www.fueleconomy.gov/feg/co2.jsp"
      },
      "credentials": {
        "scrapegraphAIApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d4e5f6g7-h8i9-0123-defg-456789012345",
      "name": "足迹计算器",
      "type": "n8n-nodes-base.code",
      "position": [
        1000,
        800
      ],
      "parameters": {
        "jsCode": "// Carbon Footprint Calculator\nconst energyData = $input.item(0).json;\nconst transportData = $input.item(1).json;\n\n// Sample organizational data (in real scenario, this would come from your systems)\nconst organizationData = {\n  electricity_consumption: 50000, // kWh/month\n  natural_gas: 2000, // therms/month\n  fleet_miles: 15000, // miles/month\n  employee_commute: 25000, // miles/month\n  air_travel: 50000, // miles/month\n  employees: 100\n};\n\nfunction calculateCarbonFootprint(energyFactors, transportFactors, orgData) {\n  const calculations = {\n    scope1: {\n      natural_gas: orgData.natural_gas * 11.7, // lbs CO2 per therm\n      fleet_fuel: (orgData.fleet_miles / 25.4) * 19.6 // assuming 25.4 mpg\n    },\n    scope2: {\n      electricity: orgData.electricity_consumption * 0.92 // lbs CO2 per kWh\n    },\n    scope3: {\n      employee_commute: orgData.employee_commute * 0.77, // lbs CO2 per mile\n      air_travel: orgData.air_travel * 0.53, // lbs CO2 per mile\n      supply_chain: orgData.electricity_consumption * 0.1 // estimated\n    }\n  };\n\n  const totalScope1 = Object.values(calculations.scope1).reduce((a, b) => a + b, 0);\n  const totalScope2 = Object.values(calculations.scope2).reduce((a, b) => a + b, 0);\n  const totalScope3 = Object.values(calculations.scope3).reduce((a, b) => a + b, 0);\n  \n  const totalEmissions = totalScope1 + totalScope2 + totalScope3;\n  const emissionsPerEmployee = totalEmissions / orgData.employees;\n  \n  return {\n    timestamp: new Date().toISOString(),\n    total_emissions_lbs: Math.round(totalEmissions),\n    total_emissions_tons: Math.round(totalEmissions / 2000 * 100) / 100,\n    emissions_per_employee: Math.round(emissionsPerEmployee * 100) / 100,\n    scope1_total: Math.round(totalScope1),\n    scope2_total: Math.round(totalScope2),\n    scope3_total: Math.round(totalScope3),\n    breakdown: calculations,\n    baseline_data: orgData\n  };\n}\n\nconst footprintResults = calculateCarbonFootprint(\n  energyData.result || energyData,\n  transportData.result || transportData,\n  organizationData\n);\n\nreturn [{ json: footprintResults }];"
      },
      "typeVersion": 2
    },
    {
      "id": "e5f6g7h8-i9j0-1234-efgh-567890123456",
      "name": "减排机会查找器",
      "type": "n8n-nodes-base.code",
      "position": [
        1400,
        800
      ],
      "parameters": {
        "jsCode": "// Reduction Opportunity Finder\nconst footprintData = $input.first().json;\n\nfunction findReductionOpportunities(data) {\n  const opportunities = [];\n  const currentEmissions = data.total_emissions_tons;\n  \n  // Energy efficiency opportunities\n  if (data.scope2_total > data.scope1_total * 0.5) {\n    opportunities.push({\n      category: 'Energy Efficiency',\n      opportunity: 'LED lighting upgrade',\n      potential_reduction_tons: Math.round(currentEmissions * 0.08 * 100) / 100,\n      investment_required: '$25,000',\n      payback_period: '2.5 years',\n      priority: 'High',\n      implementation_effort: 'Medium'\n    });\n    \n    opportunities.push({\n      category: 'Renewable Energy',\n      opportunity: 'Solar panel installation',\n      potential_reduction_tons: Math.round(currentEmissions * 0.25 * 100) / 100,\n      investment_required: '$150,000',\n      payback_period: '7 years',\n      priority: 'High',\n      implementation_effort: 'High'\n    });\n  }\n  \n  // Transportation opportunities\n  if (data.breakdown.scope3.employee_commute > 5000) {\n    opportunities.push({\n      category: 'Transportation',\n      opportunity: 'Remote work policy (3 days/week)',\n      potential_reduction_tons: Math.round(currentEmissions * 0.12 * 100) / 100,\n      investment_required: '$10,000',\n      payback_period: '6 months',\n      priority: 'High',\n      implementation_effort: 'Low'\n    });\n    \n    opportunities.push({\n      category: 'Transportation',\n      opportunity: 'Electric vehicle fleet transition',\n      potential_reduction_tons: Math.round(currentEmissions * 0.15 * 100) / 100,\n      investment_required: '$200,000',\n      payback_period: '5 years',\n      priority: 'Medium',\n      implementation_effort: 'High'\n    });\n  }\n  \n  // Office efficiency\n  opportunities.push({\n    category: 'Office Operations',\n    opportunity: 'Smart HVAC system',\n    potential_reduction_tons: Math.round(currentEmissions * 0.06 * 100) / 100,\n    investment_required: '$40,000',\n    payback_period: '4 years',\n    priority: 'Medium',\n    implementation_effort: 'Medium'\n  });\n  \n  const totalPotentialReduction = opportunities.reduce(\n    (sum, opp) => sum + opp.potential_reduction_tons, 0\n  );\n  \n  return {\n    current_footprint: data,\n    opportunities: opportunities,\n    total_potential_reduction_tons: Math.round(totalPotentialReduction * 100) / 100,\n    potential_reduction_percentage: Math.round((totalPotentialReduction / currentEmissions) * 100),\n    analysis_date: new Date().toISOString()\n  };\n}\n\nconst reductionAnalysis = findReductionOpportunities(footprintData);\n\nreturn [{ json: reductionAnalysis }];"
      },
      "typeVersion": 2
    },
    {
      "id": "f6g7h8i9-j0k1-2345-fghi-678901234567",
      "name": "可持续性仪表板",
      "type": "n8n-nodes-base.code",
      "position": [
        1800,
        800
      ],
      "parameters": {
        "jsCode": "// Sustainability Dashboard Data Formatter\nconst analysisData = $input.first().json;\n\nfunction createDashboardData(data) {\n  const footprint = data.current_footprint;\n  const opportunities = data.opportunities;\n  \n  // KPI Cards Data\n  const kpis = {\n    total_emissions: {\n      value: footprint.total_emissions_tons,\n      unit: 'tons CO2e',\n      trend: '+5.2%', // This would be calculated from historical data\n      status: footprint.total_emissions_tons > 100 ? 'warning' : 'good'\n    },\n    emissions_per_employee: {\n      value: footprint.emissions_per_employee,\n      unit: 'lbs CO2e/employee',\n      trend: '+2.1%',\n      status: 'improving'\n    },\n    reduction_potential: {\n      value: data.potential_reduction_percentage,\n      unit: '%',\n      trend: 'new',\n      status: 'opportunity'\n    },\n    cost_savings_potential: {\n      value: Math.round(data.total_potential_reduction_tons * 50), // $50 per ton estimate\n      unit: '$/year',\n      trend: 'projected',\n      status: 'positive'\n    }\n  };\n  \n  // Scope Breakdown for Charts\n  const scopeBreakdown = {\n    labels: ['Scope 1 (Direct)', 'Scope 2 (Electricity)', 'Scope 3 (Indirect)'],\n    data: [footprint.scope1_total, footprint.scope2_total, footprint.scope3_total],\n    colors: ['#FF6B6B', '#4ECDC4', '#45B7D1']\n  };\n  \n  // Monthly Trend (simulated - would be from historical data)\n  const monthlyTrend = {\n    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],\n    emissions: [85, 78, 92, 88, 95, footprint.total_emissions_tons],\n    target: [80, 80, 80, 80, 80, 80]\n  };\n  \n  // Top Opportunities for Action Items\n  const topOpportunities = opportunities\n    .sort((a, b) => b.potential_reduction_tons - a.potential_reduction_tons)\n    .slice(0, 5)\n    .map(opp => ({\n      ...opp,\n      impact_score: Math.round((opp.potential_reduction_tons / data.total_potential_reduction_tons) * 100)\n    }));\n  \n  return {\n    dashboard_data: {\n      kpis: kpis,\n      scope_breakdown: scopeBreakdown,\n      monthly_trend: monthlyTrend,\n      top_opportunities: topOpportunities,\n      last_updated: new Date().toISOString(),\n      next_update: new Date(Date.now() + 24*60*60*1000).toISOString()\n    },\n    raw_analysis: data\n  };\n}\n\nconst dashboardData = createDashboardData(analysisData);\n\nreturn [{ json: dashboardData }];"
      },
      "typeVersion": 2
    },
    {
      "id": "g7h8i9j0-k1l2-3456-ghij-789012345678",
      "name": "ESG报告生成器",
      "type": "n8n-nodes-base.code",
      "position": [
        2200,
        800
      ],
      "parameters": {
        "jsCode": "// ESG Report Generator\nconst dashboardData = $input.first().json;\nconst data = dashboardData.raw_analysis;\nconst kpis = dashboardData.dashboard_data.kpis;\n\nfunction generateESGReport(analysisData, kpiData) {\n  const reportDate = new Date().toLocaleDateString('en-US', {\n    year: 'numeric',\n    month: 'long',\n    day: 'numeric'\n  });\n  \n  const executiveSummary = `\n**EXECUTIVE SUMMARY**\n\nOur organization's current carbon footprint stands at ${analysisData.current_footprint.total_emissions_tons} tons CO2e, with emissions per employee at ${analysisData.current_footprint.emissions_per_employee} lbs CO2e. \n\nWe have identified ${analysisData.opportunities.length} key reduction opportunities that could decrease our emissions by ${analysisData.potential_reduction_percentage}% (${analysisData.total_potential_reduction_tons} tons CO2e annually).\n\n**KEY FINDINGS:**\n• Scope 2 emissions (electricity) represent ${Math.round((analysisData.current_footprint.scope2_total / analysisData.current_footprint.total_emissions_lbs) * 100)}% of total emissions\n• Transportation accounts for ${Math.round(((analysisData.current_footprint.breakdown.scope3.employee_commute + analysisData.current_footprint.breakdown.scope1.fleet_fuel) / analysisData.current_footprint.total_emissions_lbs) * 100)}% of our footprint\n• High-impact, low-cost opportunities exist in remote work policies and energy efficiency\n  `;\n  \n  const emissionsBreakdown = `\n**EMISSIONS BREAKDOWN**\n\n**Scope 1 (Direct Emissions): ${Math.round(analysisData.current_footprint.scope1_total/2000*100)/100} tons CO2e**\n• Natural Gas: ${Math.round(analysisData.current_footprint.breakdown.scope1.natural_gas)} lbs CO2e\n• Fleet Vehicles: ${Math.round(analysisData.current_footprint.breakdown.scope1.fleet_fuel)} lbs CO2e\n\n**Scope 2 (Indirect - Electricity): ${Math.round(analysisData.current_footprint.scope2_total/2000*100)/100} tons CO2e**\n• Purchased Electricity: ${Math.round(analysisData.current_footprint.breakdown.scope2.electricity)} lbs CO2e\n\n**Scope 3 (Other Indirect): ${Math.round(analysisData.current_footprint.scope3_total/2000*100)/100} tons CO2e**\n• Employee Commuting: ${Math.round(analysisData.current_footprint.breakdown.scope3.employee_commute)} lbs CO2e\n• Business Travel: ${Math.round(analysisData.current_footprint.breakdown.scope3.air_travel)} lbs CO2e\n• Supply Chain: ${Math.round(analysisData.current_footprint.breakdown.scope3.supply_chain)} lbs CO2e\n  `;\n  \n  const opportunitiesSection = analysisData.opportunities.map(opp => \n    `• **${opp.opportunity}** (${opp.category})\\n  Reduction: ${opp.potential_reduction_tons} tons CO2e | Investment: ${opp.investment_required} | Priority: ${opp.priority}`\n  ).join('\\n\\n');\n  \n  const recommendations = `\n**STRATEGIC RECOMMENDATIONS**\n\n**Immediate Actions (0-6 months):**\n1. Implement remote work policy (3 days/week) - High impact, low cost\n2. Upgrade to LED lighting across all facilities\n3. Establish employee sustainability awareness program\n\n**Medium-term Goals (6-18 months):**\n1. Install smart HVAC systems with automated controls\n2. Conduct comprehensive energy audit of all facilities\n3. Develop supplier sustainability scorecard\n\n**Long-term Commitments (1-3 years):**\n1. Transition to renewable energy sources (solar installation)\n2. Electrify vehicle fleet where feasible\n3. Achieve carbon neutrality through verified offsets\n\n**Financial Impact:**\nTotal estimated annual savings from all initiatives: $${Math.round(analysisData.total_potential_reduction_tons * 50).toLocaleString()}\nPayback period for major investments: 3-7 years\n  `;\n  \n  const fullReport = `\n# 🌱 CARBON FOOTPRINT & ESG REPORT\n**Generated: ${reportDate}**\n**Reporting Period: Current Month**\n**Organization: [Company Name]**\n\n${executiveSummary}\n\n${emissionsBreakdown}\n\n**REDUCTION OPPORTUNITIES**\n\n${opportunitiesSection}\n\n${recommendations}\n\n**COMPLIANCE & BENCHMARKING**\n• Current emissions intensity: ${analysisData.current_footprint.emissions_per_employee} lbs CO2e per employee\n• Industry benchmark: 1,200-1,800 lbs CO2e per employee (service sector)\n• Science-based target alignment: Reduction pathway defined for 1.5°C scenario\n\n**NEXT STEPS**\n1. Present findings to executive leadership\n2. Allocate budget for priority initiatives\n3. Establish monthly monitoring and reporting cadence\n4. Engage employees in sustainability initiatives\n\n---\n*This report was automatically generated using real-time data collection and analysis. For questions or detailed implementation planning, contact the Sustainability Team.*\n  `;\n  \n  return {\n    report_text: fullReport,\n    report_date: reportDate,\n    report_type: 'Carbon Footprint & ESG Analysis',\n    key_metrics: {\n      total_emissions: analysisData.current_footprint.total_emissions_tons,\n      reduction_potential: analysisData.potential_reduction_percentage,\n      cost_savings_potential: Math.round(analysisData.total_potential_reduction_tons * 50),\n      opportunities_count: analysisData.opportunities.length\n    },\n    file_name: `Carbon_Footprint_Report_${new Date().toISOString().split('T')[0]}.md`\n  };\n}\n\nconst esgReport = generateESGReport(data, kpis);\n\nreturn [{ json: esgReport }];"
      },
      "typeVersion": 2
    },
    {
      "id": "h8i9j0k1-l2m3-4567-hijk-890123456789",
      "name": "创建报告文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2600,
        700
      ],
      "parameters": {
        "name": "ESG_Reports",
        "options": {},
        "resource": "folder",
        "operation": "create"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 3
    },
    {
      "id": "i9j0k1l2-m3n4-5678-ijkl-901234567890",
      "name": "保存报告到Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2600,
        900
      ],
      "parameters": {
        "name": "={{ $json.file_name }}",
        "driveId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node['Create Reports Folder'].json.id }}"
        },
        "options": {
          "parents": [
            "={{ $node['Create Reports Folder'].json.id }}"
          ]
        },
        "operation": "upload",
        "binaryData": false,
        "fileContent": "={{ $json.report_text }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 3
    },
    {
      "id": "sticky1-abcd-efgh-ijkl-mnop12345678",
      "name": "触发器信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        450
      ],
      "parameters": {
        "color": 5,
        "width": 520,
        "height": 580,
        "content": "# 步骤1:每日触发器 ⏰"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky2-bcde-fghi-jklm-nopq23456789",
      "name": "数据收集信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        450
      ],
      "parameters": {
        "color": 4,
        "width": 520,
        "height": 580,
        "content": "# 步骤2:数据收集 🌐"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky3-cdef-ghij-klmn-opqr34567890",
      "name": "计算器信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        450
      ],
      "parameters": {
        "color": 3,
        "width": 520,
        "height": 580,
        "content": "# 步骤3:足迹计算器 🧮"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky4-defg-hijk-lmno-pqrs45678901",
      "name": "机会分析信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        450
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 580,
        "content": "# 步骤4:机会分析 🎯"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky5-efgh-ijkl-mnop-qrst56789012",
      "name": "仪表板信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        450
      ],
      "parameters": {
        "color": 2,
        "width": 520,
        "height": 580,
        "content": "# 步骤5:仪表板准备 📊"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky6-fghi-jklm-nopq-rstu67890123",
      "name": "ESG报告信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        450
      ],
      "parameters": {
        "color": 1,
        "width": 520,
        "height": 580,
        "content": "# 步骤6:ESG报告生成 📋"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky7-ghij-klmn-opqr-stuv78901234",
      "name": "存储信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2400,
        450
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 580,
        "content": "# 步骤7:报告存储 💾"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "carbon-footprint-v1-2025-001",
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Energy Data Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "Transport Data Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Energy Data Scraper": {
      "main": [
        [
          {
            "node": "Footprint Calculator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ESG Report Generator": {
      "main": [
        [
          {
            "node": "Create Reports Folder",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save Report to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Footprint Calculator": {
      "main": [
        [
          {
            "node": "Reduction Opportunity Finder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Report to Drive": {
      "main": [
        []
      ]
    },
    "Create Reports Folder": {
      "main": [
        [
          {
            "node": "Save Report to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transport Data Scraper": {
      "main": [
        [
          {
            "node": "Footprint Calculator",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Sustainability Dashboard": {
      "main": [
        [
          {
            "node": "ESG Report Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reduction Opportunity Finder": {
      "main": [
        [
          {
            "node": "Sustainability Dashboard",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文档提取, AI 摘要总结

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流