NASA近地小行星警报系统
高级
这是一个Social Media领域的自动化工作流,包含 16 个节点。主要使用 If, Code, Nasa, Slack, SplitOut 等节点。 使用NASA API、Slack和Google Calendar的自动化小行星警报
前置要求
- •Slack Bot Token 或 Webhook URL
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "qxBmyFKAUjkuc2Wx",
"meta": {
"instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
"templateCredsSetupCompleted": true
},
"name": "NASA近地小行星警报系统",
"tags": [],
"nodes": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
224,
304
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 12
}
]
}
},
"typeVersion": 1.2
},
{
"id": "note1a2b3c4d-5678-90ab-cdef-1234567890ab",
"name": "工作流概览",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
16
],
"parameters": {
"color": 5,
"width": 300,
"height": 264,
"content": "## NASA小行星警报工作流"
},
"typeVersion": 1
},
{
"id": "b2c3d4e5-f678-90ab-cdef-234567890abc",
"name": "计算日期范围",
"type": "n8n-nodes-base.code",
"position": [
464,
304
],
"parameters": {
"jsCode": "// Calculate date range for API request\nconst today = new Date();\nconst nextWeek = new Date();\nnextWeek.setDate(today.getDate() + 14);\n\n// Format dates as YYYY-MM-DD\nconst formatDate = (date) => {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n};\n\nreturn [{\n json: {\n start_date: formatDate(today),\n end_date: formatDate(nextWeek),\n today: formatDate(today),\n next_week: formatDate(nextWeek)\n }\n}];"
},
"typeVersion": 2
},
{
"id": "note2b3c4d5e-6789-0abc-def1-234567890abc",
"name": "API密钥说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
16
],
"parameters": {
"color": 6,
"width": 280,
"height": 260,
"content": "## ⚙️ NASA API配置"
},
"typeVersion": 1
},
{
"id": "d4e5f678-90ab-cdef-1234-567890abcdef",
"name": "筛选和处理小行星",
"type": "n8n-nodes-base.code",
"position": [
992,
304
],
"parameters": {
"jsCode": "// Get all individual asteroid items from the input\nconst allAsteroidItems = $input.all();\n\n// Configuration thresholds (テスト用の緩い値)\nconst MAX_DISTANCE_KM = 75000000000; // 75 billion km\nconst MIN_DIAMETER_METERS = 1; // 1 meter\n\nconst filteredAsteroids = [];\n\n// Loop through each asteroid item that was passed to this node\nfor (const item of allAsteroidItems) {\n const asteroid = item.json; // Get the actual asteroid data from the item\n\n // Ensure the necessary data exists before trying to process it\n if (asteroid && asteroid.close_approach_data && asteroid.close_approach_data.length > 0) {\n const missDistance = parseFloat(asteroid.close_approach_data[0].miss_distance.kilometers);\n const maxDiameter = asteroid.estimated_diameter.meters.estimated_diameter_max;\n const minDiameter = asteroid.estimated_diameter.meters.estimated_diameter_min;\n const avgDiameter = (maxDiameter + minDiameter) / 2;\n\n // Apply filters\n if (missDistance <= MAX_DISTANCE_KM && avgDiameter >= MIN_DIAMETER_METERS) {\n filteredAsteroids.push({\n name: asteroid.name,\n id: asteroid.id,\n approach_date: asteroid.close_approach_data[0].close_approach_date,\n approach_date_full: asteroid.close_approach_data[0].close_approach_date_full,\n miss_distance_km: Math.round(missDistance),\n miss_distance_lunar: parseFloat(asteroid.close_approach_data[0].miss_distance.lunar).toFixed(2),\n diameter_min_m: Math.round(minDiameter),\n diameter_max_m: Math.round(maxDiameter),\n diameter_avg_m: Math.round(avgDiameter),\n velocity_km_h: Math.round(parseFloat(asteroid.close_approach_data[0].relative_velocity.kilometers_per_hour)),\n is_potentially_hazardous: asteroid.is_potentially_hazardous_asteroid,\n nasa_jpl_url: asteroid.nasa_jpl_url,\n absolute_magnitude: asteroid.absolute_magnitude_h\n });\n }\n }\n}\n\n// Sort by closest approach distance\nfilteredAsteroids.sort((a, b) => a.miss_distance_km - b.miss_distance_km);\n\n// Return the final list of asteroids that met the criteria\nreturn filteredAsteroids.map(asteroid => ({ json: asteroid }));"
},
"typeVersion": 2
},
{
"id": "note3c4d5e6f-7890-abcd-ef12-34567890abcd",
"name": "筛选设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
-16
],
"parameters": {
"color": 3,
"width": 280,
"height": 280,
"content": "## ⚙️ 筛选标准"
},
"typeVersion": 1
},
{
"id": "e5f67890-abcd-ef12-3456-7890abcdef12",
"name": "检查是否找到小行星",
"type": "n8n-nodes-base.if",
"position": [
1376,
304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567891",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ $items().length }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2
},
{
"id": "f6789012-3456-7890-abcd-ef1234567890",
"name": "格式化警报消息",
"type": "n8n-nodes-base.code",
"position": [
1648,
192
],
"parameters": {
"jsCode": "// Format message for Slack/Email\nconst asteroids = $input.all();\nconst messageLines = [];\n\nmessageLines.push('🚨 *NEAR-EARTH ASTEROID ALERT* 🚨');\nmessageLines.push('');\nmessageLines.push(`Found ${asteroids.length} asteroid(s) meeting alert criteria:`);\nmessageLines.push('');\n\nasteroids.forEach((item, index) => {\n const asteroid = item.json;\n const hazardIcon = asteroid.is_potentially_hazardous ? '⚠️' : '✓';\n \n messageLines.push(`*${index + 1}. ${asteroid.name}* ${hazardIcon}`);\n messageLines.push(` • Approach Date: ${asteroid.approach_date}`);\n messageLines.push(` • Distance: ${asteroid.miss_distance_km.toLocaleString()} km (${asteroid.miss_distance_lunar} lunar distances)`);\n messageLines.push(` • Size: ${asteroid.diameter_min_m}-${asteroid.diameter_max_m} meters`);\n messageLines.push(` • Speed: ${asteroid.velocity_km_h.toLocaleString()} km/h`);\n messageLines.push(` • Details: ${asteroid.nasa_jpl_url}`);\n messageLines.push('');\n});\n\nmessageLines.push('_Data source: NASA Near Earth Object Web Service_');\n\nreturn [{\n json: {\n slackMessage: messageLines.join('\\n'),\n emailSubject: `🚨 Asteroid Alert: ${asteroids.length} Near-Earth Object(s) Detected`,\n emailBody: messageLines.join('\\n').replace(/\\*/g, '').replace(/_/g, ''),\n asteroidCount: asteroids.length,\n asteroids: asteroids.map(a => a.json)\n }\n}];"
},
"typeVersion": 2
},
{
"id": "78901234-5678-90ab-cdef-123456789012",
"name": "发送Slack警报",
"type": "n8n-nodes-base.slack",
"position": [
1840,
64
],
"webhookId": "927fb2da-a34d-40b5-a589-e67716049dd1",
"parameters": {
"text": "={{ $json.slackMessage }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C09KTEYDKDY",
"cachedResultName": "サポートチーム"
},
"otherOptions": {
"mrkdwn": true
},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "BX5igCUXrjyHLAU1",
"name": "Slack account 5"
}
},
"typeVersion": 2.2
},
{
"id": "note4d5e6f78-90ab-cdef-1234-567890abcdef",
"name": "Slack 设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
1504,
-80
],
"parameters": {
"color": 4,
"width": 280,
"height": 244,
"content": "## ⚙️ Slack配置"
},
"typeVersion": 1
},
{
"id": "90123456-7890-abcd-ef12-345678901234",
"name": "拆分单个小行星",
"type": "n8n-nodes-base.splitOut",
"position": [
1840,
304
],
"parameters": {
"include": "selectedOtherFields",
"options": {},
"fieldToSplitOut": "asteroids",
"fieldsToInclude": "emailSubject, slackMessage"
},
"typeVersion": 1
},
{
"id": "note6f78901a-bcde-f123-4567-890abcdef123",
"name": "日历设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
512
],
"parameters": {
"width": 280,
"height": 264,
"content": "## ⚙️ Google Calendar设置"
},
"typeVersion": 1
},
{
"id": "note7890abcd-ef12-3456-7890-abcdef123456",
"name": "无结果说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
480
],
"parameters": {
"color": 7,
"width": 280,
"height": 224,
"content": "## 无小行星分支"
},
"typeVersion": 1
},
{
"id": "8da8e937-6acf-43d7-8a7e-43635b7abfde",
"name": "获取小行星近地天体数据",
"type": "n8n-nodes-base.nasa",
"position": [
720,
304
],
"parameters": {
"resource": "asteroidNeoFeed",
"additionalFields": {}
},
"credentials": {
"nasaApi": {
"id": "gvg1cGvjElgkwNpP",
"name": "NASA account 2"
}
},
"typeVersion": 1
},
{
"id": "9c7340e9-6b56-4888-8180-373942e5d1d7",
"name": "创建事件",
"type": "n8n-nodes-base.googleCalendar",
"position": [
2064,
304
],
"parameters": {
"start": "={{ $json.asteroids.approach_date_full }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "t.minamig20@gmail.com",
"cachedResultName": "t.minamig20@gmail.com"
},
"additionalFields": {
"summary": "小惑星接近アラート",
"description": "=接近距離: {{ $json.asteroids.miss_distance_km.toLocaleString() }} km \n直径: 約{{ $json.asteroids.diameter_avg_m }} m \n速度: {{ $json.asteroids.velocity_km_h.toLocaleString() }} km/h \n詳細URL: {{ $json.asteroids.nasa_jpl_url }}"
}
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "5lKtFJo2lfQL9TkJ",
"name": "Google Calendar account 12"
}
},
"typeVersion": 1.3
},
{
"id": "89d59b68-b6a1-43c3-8968-c6710a561032",
"name": "无操作,不执行任何操作",
"type": "n8n-nodes-base.noOp",
"position": [
1616,
400
],
"parameters": {},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"timezone": "America/New_York",
"errorWorkflow": "",
"executionOrder": "v1",
"saveManualExecutions": true,
"saveExecutionProgress": true,
"saveDataErrorExecution": "all",
"saveDataSuccessExecution": "all"
},
"versionId": "80885207-ba21-410d-b306-fc5bc0e8e339",
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "Calculate Date Range",
"type": "main",
"index": 0
}
]
]
},
"Calculate Date Range": {
"main": [
[
{
"node": "Get an asteroid neo feed",
"type": "main",
"index": 0
}
]
]
},
"Format Alert Messages": {
"main": [
[
{
"node": "Send Slack Alert",
"type": "main",
"index": 0
},
{
"node": "Split Out Individual Asteroids",
"type": "main",
"index": 0
}
]
]
},
"Check If Asteroids Found": {
"main": [
[
{
"node": "Format Alert Messages",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"Get an asteroid neo feed": {
"main": [
[
{
"node": "Filter and Process Asteroids",
"type": "main",
"index": 0
}
]
]
},
"Filter and Process Asteroids": {
"main": [
[
{
"node": "Check If Asteroids Found",
"type": "main",
"index": 0
}
]
]
},
"Split Out Individual Asteroids": {
"main": [
[
{
"node": "Create an event",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 社交媒体
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于AI的会议研究与每日议程(Google日历、Attio CRM和Slack)
基于AI的会议研究与每日议程:使用Google日历、Attio CRM和Slack
If
Set
Code
+15
30 节点Harry Siggins
AI 摘要总结
绩效评估调度与提醒
使用Google Sheets、日历、邮件和Slack自动化绩效评估流程
If
Set
Code
+7
16 节点Oneclick AI Squad
人力资源
使用Groq、Gemini和Slack审批系统自动化RSS到Medium发布
通过Groq、Gemini和Slack审批系统实现RSS到Medium发布的自动化流程
If
Set
Code
+16
41 节点ObisDev
内容创作
敏捷团队冲刺规划自动化
使用OpenAI、Google日历和Gmail为敏捷团队自动化冲刺规划
If
Set
Code
+17
52 节点Willemijn
产品
自动化会议准备
使用 GPT-5 和 Gemini 研究从日历到 Slack 通过 Attio CRM 自动准备会议
If
Set
Code
+16
39 节点Harry Siggins
AI 摘要总结
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
工作流信息
难度等级
高级
节点数量16
分类1
节点类型9
作者
Yusuke Yamamoto
@yusuke-yamamotoBusiness creator from Tokyo. Designing AI-driven automations that enhance marketing, reporting, and daily operations. I turn complex workflows into simple, elegant automations with n8n.
外部链接
在 n8n.io 查看 →
分享此工作流