
n8n学习之AI新闻聚合工作流
2025/9/17 大约 5 分钟
前言
参考B站UP 陶渊xiao明 的视频,自定义一个AI新闻聚合工作流。
📌 本文内容:
✅ 使用多个新闻 API 获取 AI 相关新闻 🔍
✅ 使用DeepSeek-V3.1 API,AI 翻译 & 整理新闻 🧠
✅ 低成本搭建 钉钉群 自动推送机器人 🤖
🎯 最终效果:每天 8 点自动抓取新闻,翻译优化后推送到 钉钉聊天群。
📢 适合人群:内容创作者、自媒体运营者、AI 技术爱好者
工作流说明
原视频的内容是一个全自动的 Telegram 新闻推送 AI 工作流。但是 中国人谁用 Telegram 啊。所以,为了贴合国内环境,将Telegram机器人改为了钉钉机器人 🤖 。


节点说明
- 工作流开始使用了俩个 HTTP Request 节点 俩获取最新的新闻列表,通过 Merge 节点 合并后输入了AI Agent节点。
- AI Agent节点 将调用 DeepSeek API 对新闻信息进行翻译和整理。
- 工作流的最后使用了一个 http 节点来向 钉钉 发送 新闻,在此之前必须使用一个code 节点来对发送的新闻进行字符预处理。code 节点过滤了一些可能无法处理的emoji表情。
需要的资源
你需要申请 获取新闻列表的API 和 DeepSeek API。我所使用的申请链接如下:
⚡ 相关链接 & 资源
📎 n8n:https://n8n.io/
📎 n8n GitHub:https://github.com/n8n-io/n8n
📎 DeepSeek API 申请: 阿里云的大模型服务平台百炼
📎 News API:https://newsapi.org/
📎 GNews API:https://gnews.io/
📎 如何通过钉钉机器人发送消息
完整工作流代码
因为牵涉API的 key,我已经删除相关内容,你需要自己申请到相关内容填入节点然后运行
{
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 8
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-640,
128
],
"id": "1a08b74c-4326-4e19-a6de-653bb8af9b8b",
"name": "Schedule Trigger"
},
{
"parameters": {
"url": "https://newsapi.org/v2/everything?q=ai&apiKey=xxx",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-448,
32
],
"id": "99f16fab-1a32-4d9f-af19-fc59d4b801c0",
"name": "HTTP Request"
},
{
"parameters": {
"url": "https://gnews.io/api/v4/search?q=ai&lang=en&apikey=xxx",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-448,
240
],
"id": "1fef2b40-efc8-49b1-9f27-08f5aa0a326a",
"name": "HTTP Request1"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "542a67ef-b627-4c71-8188-8a208c500cb1",
"name": "articles",
"value": "={{ $json.articles }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-240,
0
],
"id": "a0a9d2e0-719c-485d-9b80-c0b069a70bb5",
"name": "Edit Fields"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "340bfcfa-1241-463c-b141-a81712d91735",
"name": "articles",
"value": "={{ $json.articles }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-240,
272
],
"id": "38bb719b-663e-46f2-b32a-c50449bbde97",
"name": "Edit Fields1"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
-16,
128
],
"id": "3bbfdf20-488c-49da-a6ea-5bb4753b435c",
"name": "Merge"
},
{
"parameters": {
"promptType": "define",
"text": "=你是一名AI新闻编辑,负责筛选、翻译和整理最新的AI行业动态,并确保信息清晰、美观地呈现给读者。 \n\n任务要求: \n1. 从中{{ $json.articles }}筛选1条仅与AI技术进展和应用相关的新闻,忽略无关信息。 \n2. 精准翻译为中文,并保留业内常见的英文术语(如Neural Networks、Reinforcement Learning等,不必强制翻译)。 \n3. 确保每条新闻附带原始URL,方便读者获取详细信息。 \n4. 在开头注明当天日期,例如:“早上好,今天是2025年3月26日,以下是最新的AI行业新闻。” \n5. 对输出内容进行排版美化,使用适当的换行、编号、粗体等格式,使信息更易阅读。例如: \n\n📌 1. AI突破:新型Transformer架构提升文本理解能力 \n🔗 [原文链接](URL) \n研究人员开发了一种改进版的 Transformer 结构,相比传统模型,在文本分类和摘要生成方面提升了20%的准确率…… \n\n📌 2. OpenAI 发布 GPT-5,参数量达 2 万亿 \n🔗 [原文链接](URL) \n最新的 GPT-5 具备更强的推理能力,能够更自然地处理多轮对话,并支持实时检索…… \n\n请确保最终输出内容清晰、美观,方便读者快速获取关键信息。",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.8,
"position": [
208,
112
],
"id": "d333b44d-7388-4120-af52-7fc043fb8e5a",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "deepseek-v3.1",
"mode": "list",
"cachedResultName": "deepseek-v3.1"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
208,
384
],
"id": "0184ad86-eada-4058-b2d4-6d46b6e9ba8c",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "Wu4hUUhsSoaA84aq",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"text\": {\n \"content\":\"{{$json.output.toString()}}\"\n },\n \"msgtype\":\"text\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
768,
112
],
"id": "f5e69871-3900-4faa-af3a-ed067d311bc4",
"name": "HTTP Request2"
},
{
"parameters": {
"jsCode": "\n// 方法2:如需更精细控制,可自定义转义函数\nfunction customEscape(str) {\n if (!str) return '';\n return str\n .replace(/\\\\/g, '\\\\\\\\') // 转义反斜杠\n .replace(/\"/g, '\\\\\"') // 转义双引号\n .replace(/\\n/g, '\\\\n') // 转义换行符\n .replace(/\\r/g, '\\\\r') // 转义回车符\n .replace(/\\t/g, '\\\\t') // 转义制表符\n .replace(/\\u0000/g, '\\\\0'); // 转义空字符\n}\n\n// Loop over input items \nfor (const item of $input.all()) {\n //item.json.myNewField = 1;\n item.json.output = customEscape(item.json.output);\n // 过滤无法处理的emoji(保留常见字符)\n item.json.output = item.json.output.replace(/[^\\x00-\\x7F\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]/g, '');\n}\n\nreturn $input.all();"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
560,
112
],
"id": "d3d8aa11-fff1-4a75-8c06-9bccfcbc6fdf",
"name": "Code"
}
],
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "HTTP Request1",
"type": "main",
"index": 0
},
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request1": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Merge": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "HTTP Request2",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "a478f5fc0c32363ef4eac5409445dc10c5e410a2829fab9734ea5c8c26ff7b32"
}
}