✈️ 使用CarbonInterface API和GPT-4o计算商务旅行二氧化碳排放量
中级
这是一个Other, AI, IT Ops领域的自动化工作流,包含 12 个节点。主要使用 SplitOut, HttpRequest, GmailTrigger, GoogleSheets, SplitInBatches 等节点,结合人工智能技术实现智能自动化。 ✈️ 通过Carbon Interface API和GPT-4o计算商务旅行二氧化碳排放
前置要求
- •可能需要目标 API 的认证凭证
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (12)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "1H8R2Hvre2Z1LuTG",
"meta": {
"instanceId": "",
"templateCredsSetupCompleted": true
},
"name": "✈️ 使用 CarbonInterface API 和 GPT-4o 计算商务旅行的二氧化碳排放量",
"tags": [],
"nodes": [
{
"id": "16cb6418-383a-409e-ac18-8ba78aba031b",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-320,
415
],
"parameters": {
"simple": false,
"filters": {},
"options": {
"downloadAttachments": false
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "",
"name": ""
}
},
"notesInFlow": true,
"typeVersion": 1.2
},
{
"id": "5c7c052e-9a71-4867-9d05-492dac9a8b7c",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
140,
600
],
"parameters": {
"jsonSchemaExample": "{\n \"traveler_name\": \"Samir Saci\",\n \"trip_purpose\": \"Sustainability Client Workshop\",\n \"trip_id\": \"LG-TRIP-2025-0624\",\n \"flights\": [\n {\n \"type\": \"departure\",\n \"from\": \"Paris Charles de Gaulle (CDG)\",\n \"to\": \"Toronto Pearson International (YYZ)\",\n \"from_code\": \"CDG\",\n \"to_code\": \"YYZ\",\n \"date\": \"2025-06-24\",\n \"flight_number\": \"AF356\"\n },\n {\n \"type\": \"return\",\n \"from\": \"Toronto Pearson International (YYZ)\",\n \"to\": \"Paris Charles de Gaulle (CDG)\",\n \"from_code\": \"YYZ\",\n \"to_code\": \"CDG\",\n \"date\": \"2025-06-28\",\n \"flight_number\": \"AC880\"\n }\n ],\n \"hotel_booked\": false,\n \"ground_transport_booked\": false\n}\n"
},
"typeVersion": 1.2
},
{
"id": "c0eeae42-d3dd-400e-8d19-1068f4ab999d",
"name": "AI Agent 解析器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-100,
415
],
"parameters": {
"text": "=Extract the structured trip details from the following email:\n\n{{ $json.text }}\n",
"options": {
"systemMessage": "=You are a travel assistant. When provided with the body of a business trip confirmation email, extract the following structured JSON object.\n\nReturn **only** a JSON object with the following fields:\n\n{\n \"traveler_name\": string,\n \"trip_purpose\": string,\n \"trip_id\": string,\n \"flights\": [\n {\n \"type\": \"departure\" or \"return\",\n \"from\": string,\n \"from_code\": string (e.g., \"CDG\"),\n \"to\": string,\n \"to_code\": string (e.g., \"YYZ\"),\n \"date\": string (ISO 8601, e.g., \"2025-06-24\"),\n \"flight_number\": string\n }\n ],\n \"hotel_booked\": boolean,\n \"ground_transport_booked\": boolean\n}\n\n- Extract the 3-letter airport codes (IATA format) from the airport names and populate `from_code` and `to_code`.\n- If hotel or ground transport is marked “Not booked,” return `false`, otherwise `true`.\n- Always include both departure and return flights as separate items in the \"flights\" array.\n- Return only the JSON object, no extra text.\n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9
},
{
"id": "2a30a34e-76d2-4d89-a5f9-cf48f97f490e",
"name": "OpenAI 聊天模型2",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-100,
620
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "",
"name": ""
}
},
"typeVersion": 1.2
},
{
"id": "f0eb3490-4f5f-42ca-83fa-0a562a08d630",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
320,
420
],
"parameters": {
"options": {},
"fieldToSplitOut": "output.flights"
},
"typeVersion": 1
},
{
"id": "c7bb9d8b-a972-4d53-8217-8e77c29dda81",
"name": "记录航班信息",
"type": "n8n-nodes-base.googleSheets",
"position": [
840,
360
],
"parameters": {
"columns": {
"value": {
"To": "={{ $json.to }}",
"From": "={{ $json.from }}",
"To Code": "={{ $json.to_code }}",
"Trip ID": "={{ $('AI Agent Parser').item.json.output.trip_id }}_{{ $json.type }}",
"From Code": "={{ $json.from_code }}",
"Flight Date": "={{ $json.date }}",
"Flight Type": "={{ $json.type }}",
"Hotel Booked": "={{ $('AI Agent Parser').item.json.output.hotel_booked }}",
"Trip Purpose": "={{ $('AI Agent Parser').item.json.output.trip_purpose }}",
"Flight Number": "={{ $json.flight_number }}",
"Traveler Name": "={{ $('AI Agent Parser').item.json.output.traveler_name }}",
"Ground Transport Booked": "={{ $('AI Agent Parser').item.json.output.ground_transport_booked }}"
},
"schema": [
{
"id": "Traveler Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Traveler Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Trip Purpose",
"type": "string",
"display": true,
"required": false,
"displayName": "Trip Purpose",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Trip ID",
"type": "string",
"display": true,
"required": false,
"displayName": "Trip ID",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Hotel Booked",
"type": "string",
"display": true,
"required": false,
"displayName": "Hotel Booked",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Ground Transport Booked",
"type": "string",
"display": true,
"required": false,
"displayName": "Ground Transport Booked",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Type",
"type": "string",
"display": true,
"required": false,
"displayName": "Flight Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "From",
"type": "string",
"display": true,
"required": false,
"displayName": "From",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "From Code",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "From Code",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "To",
"type": "string",
"display": true,
"required": false,
"displayName": "To",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "To Code",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "To Code",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Date",
"type": "string",
"display": true,
"required": false,
"displayName": "Flight Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Flight Number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "",
"cachedResultName": "Flight"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Unyl-tEDYwtrILjNLOX7IbBP-TAYy8gcmqcZahPpiEI",
"cachedResultUrl": "",
"cachedResultName": "Carbon Emissions"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "",
"name": ""
}
},
"notesInFlow": true,
"typeVersion": 4.6
},
{
"id": "9a3da134-6af3-4130-9420-7efbd4d47d17",
"name": "循环遍历航班",
"type": "n8n-nodes-base.splitInBatches",
"position": [
540,
420
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "8fa6af96-da24-449f-ab07-7c26eebf82e1",
"name": "收集二氧化碳排放量",
"type": "n8n-nodes-base.httpRequest",
"position": [
1040,
360
],
"parameters": {
"url": "https://www.carboninterface.com/api/v1/estimates",
"method": "POST",
"options": {},
"jsonBody": "={\n \"type\": \"flight\",\n \"passengers\": 1,\n \"legs\": [\n {\n \"departure_airport\": \"{{ $json['From Code'] }}\",\n \"destination_airport\": \"{{ $json['To Code'] }}\"\n }\n ]\n}\n",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_API_LEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"notesInFlow": true,
"typeVersion": 4.2
},
{
"id": "0a297fa4-3ea0-485d-901e-48f8e3d32840",
"name": "加载结果",
"type": "n8n-nodes-base.googleSheets",
"position": [
1300,
420
],
"parameters": {
"columns": {
"value": {
"Trip ID": "={{ $('Record Flights Information').item.json['Trip ID'] }}",
"CO2 (kg)": "={{ $json.data.attributes.carbon_kg }}",
"Distance (km)": "={{ $json.data.attributes.distance_value }}",
"Estimation Time": "={{ $json.data.attributes.estimated_at }}"
},
"schema": [
{
"id": "Traveler Name",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Traveler Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Trip Purpose",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Trip Purpose",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Trip ID",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Trip ID",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Hotel Booked",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Hotel Booked",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Ground Transport Booked",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Ground Transport Booked",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Type",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Flight Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "From",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "From",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "From Code",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "From Code",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "To",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "To",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "To Code",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "To Code",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Date",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Flight Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Flight Number",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Flight Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Distance (km)",
"type": "string",
"display": true,
"required": false,
"displayName": "Distance (km)",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "CO2 (kg)",
"type": "string",
"display": true,
"required": false,
"displayName": "CO2 (kg)",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Estimation Time",
"type": "string",
"display": true,
"required": false,
"displayName": "Estimation Time",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Trip ID"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "",
"cachedResultName": "Flight"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Unyl-tEDYwtrILjNLOX7IbBP-TAYy8gcmqcZahPpiEI",
"cachedResultUrl": "",
"cachedResultName": "Carbon Emissions"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "",
"name": ""
}
},
"notesInFlow": true,
"typeVersion": 4.6
},
{
"id": "943097a7-84b2-4be1-a65a-711a8350daad",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
-60
],
"parameters": {
"color": 7,
"width": 180,
"height": 820,
"content": "### 1. 使用 Gmail 触发器的工作流触发器"
},
"typeVersion": 1
},
{
"id": "38d4649e-87c0-4bd6-b822-b88ff68309cc",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
-60
],
"parameters": {
"color": 7,
"width": 440,
"height": 820,
"content": "### 2. AI Agent 解析行程报告"
},
"typeVersion": 1
},
{
"id": "01acc971-5482-4e00-846b-584660ec30ab",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
300,
-60
],
"parameters": {
"color": 7,
"width": 1180,
"height": 820,
"content": "### 3. 记录运输请求信息并使用 Open Route API 获取距离和驾驶时间"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "8a89f371-efb3-4bd0-8909-8fb802f7826d",
"connections": {
"Split Out": {
"main": [
[
{
"node": "Loop Over Flights",
"type": "main",
"index": 0
}
]
]
},
"Load Results": {
"main": [
[
{
"node": "Loop Over Flights",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "AI Agent Parser",
"type": "main",
"index": 0
}
]
]
},
"AI Agent Parser": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Flights": {
"main": [
[],
[
{
"node": "Record Flights Information",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model2": {
"ai_languageModel": [
[
{
"node": "AI Agent Parser",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Collect CO2 Emissions": {
"main": [
[
{
"node": "Load Results",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent Parser",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Record Flights Information": {
"main": [
[
{
"node": "Collect CO2 Emissions",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 其他, 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
🚚 使用 Carbon Interface API 和 GPT-4o 计算货运的 CO2 排放量
🚚 使用 Carbon Interface API 和 GPT-4o 计算货运的 CO2 排放量
Http Request
Gmail Trigger
Google Sheets
+4
10 节点Samir Saci
人工智能
🤖🚚 基于GPT-4o和Open Route API的运输订单管理AI代理
🤖🚚 基于GPT-4o和Open Route API的运输订单管理AI代理
Set
Wait
Gmail
+7
26 节点Samir Saci
人工智能
🗞️ AI驱动的可持续性营销简报(使用Gmail、GPT-4o)
🗞️ AI驱动的可持续性营销简报(使用Gmail、GPT-4o)
If
Set
Code
+12
21 节点Samir Saci
人工智能
🉑 使用Google Translate和GPT-4o生成语言学习Anki闪卡
🉑 使用Google Translate和GPT-4o生成语言学习Anki闪卡
If
Set
Merge
+10
21 节点Samir Saci
其他
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
🌲 使用Gmail和GPT-40进行可持续发展报告审计的AI代理
🌲 使用Gmail和GPT-40进行可持续发展报告审计的AI代理
If
Code
Gmail
+6
14 节点Samir Saci
其他
工作流信息
难度等级
中级
节点数量12
分类3
节点类型9
作者
Samir Saci
@samirsaciAutomation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci
外部链接
在 n8n.io 查看 →
分享此工作流