前往 WaytoAGI 飞书知识库 · 1 亿+ 次访问的开源 AI 知识库 →
通往 AGI 之路 WaytoAGI

知识库 · AI 智能体

n8n AI Builder 深度实测:是神器还是鸡肋?(附玩法提示词与避坑指南)

n8n AI Workflow Builder 可通过自然语言 Prompt 自动生成完整工作流。本文通过 4 个实测案例(Multi-agent、新闻日报、电商选品、工作流诊断)评估其能力边界,并给出 5 条避坑指南与额度说明,帮助用户高效使用。

n8nAI自动化工作流实测评测

n8n AI Builder 深度实测:是神器还是鸡肋?(附玩法提示词与避坑指南)

2025年10月26日修改
原创 芋头小宝 GenAI共生人2025年10月26日 10:14 上海
刚学n8n的时候,你是否也曾面对 n8n 的空白画布,不知从何入手?或者从大佬那里学了一个工作流,却很难理解与复刻?
10月14日,n8n 在社交平台 X 上正式推出的 AI Workflow Builder ,正是为了解决这种“ 从0到1的挣扎 ”。这条被官方置顶至今的消息,在海外社媒引发了不少关注与讨论。
那这个功能到底有什么用,效果如何,今天这篇文章将通过几个实测案例为大家一探究竟。
文档图片

什么是AI Workflow Builder?

简单来说,n8n AI Workflow Builder 是一个内置于 n8n 的智能助手。你不再需要从零开始拖拽节点,只需用文字告诉它“你想要搭建一个什么样的工作流”,它就能为你生成一套完整的工作流。 正如官方所说,“ Turn prompts into living workflows ”,不需要写一行代码,只要一句自然语言 Prompt,AI 就能帮你搞定节点逻辑、数据流转和结构搭建。
n8n AI目前主要有两种服务模式
Ask 模式: 当你不确定如何实现时,可以向 AI 提问,它会给你指导。(不扣积分)
Build 模式: 直接输入你的需求,AI 会自动为你搭建整个工作流。
文档图片

Ask模式之前一直都有,Build 模式是10/14 n8n官宣的主要功能

01|"三句话"看懂它到底能做什么?

用文字描述目标 → AI 开始自动找节点、放节点、连节点。
边建边看进度 → 生成过程分阶段进行,你能实时看到它在“ 搜索节点、连接节点、更新参数 ”。
一键试跑 + 二次提词微调 → 先执行,再继续用 Prompt 细化。官方的“工作流三步法”明确写了这条路线。
文档图片

友情提醒: 每一次与 Builder 的交互都算 1 个 credit ,包括“创建新工作流、让它修改现有工作流、点击 Execute and refine ”。 失败或你手动停止的请求不扣分。

02|直接上手:从浅至深,逐步解锁能力边界

案例1: Multi-agent research workflow

官方案例提示词 : Create a multi-agent AI workflow where different AI agents collaborate to research a topic, fact-check information, and compile comprehensive reports.
复杂度: 🌟 🌟
完成度:90%
文档图片

这个案例是用官方提示词生成的,整体完成度比较高,把凭证配好后,基本上可以运行,但还有一些提示词和数据结构的细节需要调整。(手动调试的时候注意这个AI窗口需要关闭,不然它会一直运行,消耗我们宝贵的积分)
文档图片

案例2: 新闻日报定时发送

提示词 :搭建一个每天定时(早上8:00)发送AI新闻日报到指定邮箱的工作流,AI新闻来源于newsAPI以及一些全球知名的信息rss feed,经过信息的过滤、清洗和筛选后,再由ai节点来进行梳理和总结,最后转成结构优美的html,发送到目标用户到邮箱。
复杂度: 🌟🌟 🌟
完成度:75%
文档图片

基本结构有了,但是很多细节都需要调整,尤其是数据清洗与合并的节点。还有最后一个markdown转html的功能它也是直接用code节点来写了,虽然可行,但直接用官方 Markdown 节点会更优雅、更低代码。
案例3: 海外电商选品分析
提示词: 请帮我搭建一个自动化工作流,目标是:
在国外主流电商平台(如Amazon、eBay)和社交媒体平台(如Twitter、Reddit)抓取指定行业的商品或话题数据。
对每个商品或话题,收集评论数、搜索量、转发量、销量等数据。
对抓取的数据进行清洗和结构化,去除重复和无关内容。
将所有清洗后的数据整理到一份表格(如Google Sheets或CSV),方便后续分析。
最后还要利用AI给我分析表格数据并生成一份结构优美的选品报告(html格式呈现)
行业关键词由用户输入
复杂度:🌟🌟🌟 🌟
完成度:65%
文档图片

整体框架还是比较完整的,但是这个工作流最麻烦的是各种API的接入以及数据清洗的部分,以及html报告的审美,这些AI目前都没法帮我们完成,后期还是需要花费比较多的调试时间。

案例4: 工作流诊断/复刻

这个其实可以使用ASK功能,先让AI帮我们诊断整个工作流,并分析每个节点的功能,最后再给出完整的优化建议,最后还可以让builder来直接执行这些优化建议。
文档图片

整体给出的建议可采纳度还是很高的,对新手学习或者复刻老师们的工作流也是很有帮助的。

03|哪些账号能用?额度怎么计算?

当前可用范围 :n8n Cloud 的 Trial、Starter、Pro 用户已分批开放(官方社区公告)
每月额度(credits) :Starter 50、Pro 150、Enterprise 1000
文档图片

04|提高AI搭建成功率的 5 条避坑指南

先ASK后BUILD :通过ASK模式一起梳理清楚你的需求以及可行性,你甚至可以让它帮你编写build的提示词,然后再开始build。
把输入/输出格式说清楚 :列表字段、消息模板、字符上限、失败处理等说清楚,AI才能帮你一步到位。
一次只加一种复杂度 :先“跑通”,再逐渐在此基础上优化迭代(有能力的可以手工调整,积分有限)
善用“执行并微调” :如果有错误日志就直接带回 Prompt,让它“按现状改”。
遇到误判及时“手动停止” :这类请求不计费,避免额度浪费

观点

我们必须清醒地认识到,n8n AI Builder 是一种角色极其分明的工具。它既是通往自动化殿堂的“超级加速器” ,也是检验使用者真实能力的 “残酷试金石”。
对于新手:它加速学习,而非替代学习。
AI 能为你铺好99%的路,但驾驶通过“最后一公里”的,必须是你自己。
试想一下,AI “一键”生成了一个看似华丽的复杂工作流。当它遇到一个微小的错误时,如果你不理解其运行原理,你将陷入无尽的调试黑洞,痛苦不堪。AI 给了你“是什么”的答案,但只有通过学习,掌握“为什么”的原理,你才能真正驾驭它,而不是被它“反噬”。它降低了入门的门槛,却也提高了“能用好”的隐形标准。
对于高阶玩家:你的角色,正从“执行者”变为“指挥官”。
对于早已洞悉 n8n 核心原理的你来说,AI Builder 则是将你从繁琐的搭建工作中解放出来的“效率放大器”。你的角色,正从一名事必躬亲的“执行者”,转变为一位运筹帷幄的“指挥官”。你只需下达战略意图,AI 便为你冲锋陷阵。 你的经验,加上 AI 的效率,将释放出 1+1>2 的巨大能量。

拥抱变革,成为一名优秀的「GenAI共生人」

站在今天看未来,可以预见,自动化和创造的门槛将以前所未有的速度降低。当人人都能“一句话生成工作流”时,真正的壁垒将不再是“会不会用工具”,而是“ 你是否深刻理解工具的边界,并能基于此设计出独一无二的、AI赋能的业务和产品” 。
我们正处在一个伟大的变革时代。早一天了解这些AI工具的真实能力与局限,你就早一天拥有了设计未来的主动权。
唯有积极拥抱每一次变革的浪潮,成为一名与 AI 共舞的 「GenAI共生人」 ,才能在这场不可逆转的智能革命中,永远立于不败之地。
如果觉得文章不错,别忘了点赞、在看、分享三连,感谢你的支持!
以上AI工作流如下:
      
{"active":false,"connections":{"Chat Trigger":{"main":[[{"index":0,"node":"Workflow Configuration","type":"main"}]]},"Conversation Memory":{"ai_memory":[[{"index":0,"node":"Coordinator Agent","type":"ai_memory"}]]},"Data Analysis Tool":{"ai_tool":[[{"index":0,"node":"Report Writer Agent Tool","type":"ai_tool"}]]},"Fact-Checking Agent Tool":{"ai_tool":[[{"index":0,"node":"Coordinator Agent","type":"ai_tool"}]]},"OpenAI Chat Model - Coordinator":{"ai_languageModel":[[{"index":0,"node":"Coordinator Agent","type":"ai_languageModel"}]]},"OpenAI Chat Model - Fact-Checker":{"ai_languageModel":[[{"index":0,"node":"Fact-Checking Agent Tool","type":"ai_languageModel"}]]},"OpenAI Chat Model - Research":{"ai_languageModel":[[{"index":0,"node":"Research Agent Tool","type":"ai_languageModel"}]]},"OpenAI Chat Model - Writer":{"ai_languageModel":[[{"index":0,"node":"Report Writer Agent Tool","type":"ai_languageModel"}]]},"Report Writer Agent Tool":{"ai_tool":[[{"index":0,"node":"Coordinator Agent","type":"ai_tool"}]]},"Research Agent Tool":{"ai_tool":[[{"index":0,"node":"Coordinator Agent","type":"ai_tool"}]]},"Web Search Tool":{"ai_tool":[[{"index":0,"node":"Research Agent Tool","type":"ai_tool"},{"index":0,"node":"Fact-Checking Agent Tool","type":"ai_tool"}]]},"Workflow Configuration":{"main":[[{"index":0,"node":"Coordinator Agent","type":"main"}]]}},"id":"mrdnneUz42Ty1iDa","meta":{"instanceId":"382e376cf0c77261ab58b52fb5203072e6f3d632e43adf5a68c3823147c39dcd","templateCredsSetupCompleted":true},"name":"Collaborative Research and Fact-Checking Report Generator","nodes":[{"id":"82074736-8b89-4188-8292-7b65e4294bdb","name":"Chat Trigger","parameters":{"options":{}},"position":[0,0],"type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.3,"webhookId":"d9fbed0a-a716-4151-848c-b0b9d0d0d8cb"},{"id":"17a7fb7e-dbe1-41b4-976f-a6c05a14a74a","name":"Workflow Configuration","parameters":{"assignments":{"assignments":[{"id":"id-1","name":"researchDepth","type":"string","value":"comprehensive"},{"id":"id-2","name":"factCheckThreshold","type":"number","value":0.85},{"id":"id-3","name":"reportFormat","type":"string","value":"detailed"}]},"includeOtherFields":true,"options":{}},"position":[224,0],"type":"n8n-nodes-base.set","typeVersion":3.4},{"id":"a279011f-0d52-49e0-ba8e-7fed45c7b8f5","name":"Coordinator Agent","parameters":{"options":{"enableStreaming":true,"maxIterations":10,"passthroughBinaryImages":true,"returnIntermediateSteps":false,"systemMessage":"You are a Coordinator Agent managing a team of specialized AI agents. Your role is to: 1) Understand the user's research request, 2) Delegate tasks to the Research Agent for gathering information, 3) Send findings to the Fact-Checking Agent for verification, 4) Have the Report Writer Agent compile comprehensive reports. Coordinate the workflow efficiently and ensure high-quality output."}},"position":[720,0],"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2},{"id":"78f49079-d394-464c-b89e-1472209a6971","name":"Research Agent Tool","parameters":{"options":{},"text":"=Research the following topic thoroughly: {{ $json.chatInput }}. Gather information from multiple sources, identify key facts, statistics, and relevant details. Provide a comprehensive summary of findings.","toolDescription":"Research Agent that gathers comprehensive information on any topic using web search and analysis tools"},"position":[704,224],"type":"@n8n/n8n-nodes-langchain.agentTool","typeVersion":2.2},{"id":"35a4c0d5-017d-4369-8794-6dfb66376b55","name":"Fact-Checking Agent Tool","parameters":{"options":{},"text":"=Fact-check the following information: {{ $json.chatInput }}. Verify claims against reliable sources, identify any inconsistencies or potential misinformation, and provide a confidence score for each fact. Use web search to cross-reference information.","toolDescription":"Fact-Checking Agent that verifies information accuracy by cross-referencing multiple sources and identifying potential misinformation"},"position":[992,224],"type":"@n8n/n8n-nodes-langchain.agentTool","typeVersion":2.2},{"id":"cd847101-8b37-4f50-a48d-61e8713eb19d","name":"Report Writer Agent Tool","parameters":{"options":{},"text":"=Create a comprehensive report based on the following information: {{ $json.chatInput }}. Structure the report with: 1) Executive Summary, 2) Key Findings, 3) Detailed Analysis, 4) Verified Facts, 5) Conclusions. Use the data analysis tool to organize and present information clearly.","toolDescription":"Report Writer Agent that compiles research findings and fact-checked information into well-structured, comprehensive reports"},"position":[1280,224],"type":"@n8n/n8n-nodes-langchain.agentTool","typeVersion":2.2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"c91a2c30-3eab-4b92-b3bb-c8b67d783cf4","name":"OpenAI Chat Model - Coordinator","parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"position":[448,224],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"2f609fc2-6e76-49ff-b01f-b1561ac3bbb1","name":"OpenAI Chat Model - Research","parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"position":[768,432],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"23d436e3-3acc-4b8e-bccf-47ba9d4bc25b","name":"OpenAI Chat Model - Fact-Checker","parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"position":[1152,432],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"ad4a1cf0-568e-46d0-840a-d62f752cd89a","name":"OpenAI Chat Model - Writer","parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"position":[1280,432],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"id":"1f1acd19-f2f6-4c30-b61d-283954257b0d","name":"Conversation Memory","parameters":{},"position":[576,224],"type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","typeVersion":1.3},{"id":"26737016-348c-4d6d-b865-9aa8d949548a","name":"Web Search Tool","parameters":{"options":{},"toolDescription":"Search the web for current information on any topic. Use this to find facts, statistics, news, and research data.","url":"={{ 'https://api.duckduckgo.com/?q=' + $fromAI('search_query', 'The search query to look up') + '\u0026format=json' }}"},"position":[944,432],"type":"n8n-nodes-base.httpRequestTool","typeVersion":4.2},{"id":"ab14193d-0707-417d-b389-2dd26b3f0a98","name":"Data Analysis Tool","parameters":{"description":"Analyze and structure data, extract key insights, calculate statistics, and organize information for report writing","jsCode":"const data = $input.all();\nconst analysis = {\n totalItems: data.length,\n summary: 'Data analysis complete',\n insights: data.map(item =\u003e ({\n key: Object.keys(item.json)[0],\n value: Object.values(item.json)[0]\n }))\n};\nreturn analysis;"},"position":[1424,432],"type":"@n8n/n8n-nodes-langchain.toolCode","typeVersion":1.3}],"pinData":{},"settings":{"executionOrder":"v1"},"tags":[],"versionId":"0d8b6b0c-65b9-4b64-ac77-d11025b309b2"}
      
{"active":false,"connections":{"AI News Summarizer":{"main":[[{"index":0,"node":"Generate HTML Email","type":"main"}]]},"Daily 8AM Trigger":{"main":[[{"index":0,"node":"Workflow Configuration","type":"main"}]]},"Fetch NewsAPI Articles":{"main":[[{"index":0,"node":"Merge All News Sources","type":"main"}]]},"Fetch TechCrunch RSS":{"main":[[{"index":1,"node":"Merge All News Sources","type":"main"}]]},"Filter and Clean News Data":{"main":[[{"index":0,"node":"AI News Summarizer","type":"main"}]]},"Generate HTML Email":{"main":[[{"index":0,"node":"Send Email via Gmail","type":"main"}]]},"Merge All News Sources":{"main":[[{"index":0,"node":"Filter and Clean News Data","type":"main"}]]},"OpenAI GPT-4":{"ai_languageModel":[[{"index":0,"node":"AI News Summarizer","type":"ai_languageModel"}]]},"Workflow Configuration":{"main":[[{"index":0,"node":"Fetch NewsAPI Articles","type":"main"},{"index":0,"node":"Fetch TechCrunch RSS","type":"main"},{"index":0,"node":"Fetch MIT Tech Review RSS","type":"main"},{"index":0,"node":"Fetch VentureBeat AI RSS","type":"main"}]]}},"id":"fbZQxVBTn67JCh5U","meta":{"instanceId":"382e376cf0c77261ab58b52fb5203072e6f3d632e43adf5a68c3823147c39dcd","templateCredsSetupCompleted":true},"name":"Daily AI News Digest Email Automation at 8AM","nodes":[{"id":"95db9b43-3983-44ea-a22e-d00fc4cb2ad8","name":"Daily 8AM Trigger","parameters":{"rule":{"interval":[{"triggerAtHour":8}]}},"position":[-448,288],"type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2},{"id":"ce0b1acb-e7cd-4167-a643-bc756a581c39","name":"Workflow Configuration","parameters":{"assignments":{"assignments":[{"id":"id-1","name":"newsApiKey","type":"string","value":"\u003c__PLACEHOLDER_VALUE__NewsAPI API Key__\u003e"},{"id":"id-2","name":"newsApiUrl","type":"string","value":"https://newsapi.org/v2/everything"},{"id":"id-3","name":"techCrunchRss","type":"string","value":"https://techcrunch.com/feed/"},{"id":"id-4","name":"mitTechReviewRss","type":"string","value":"https://www.technologyreview.com/feed/"},{"id":"id-5","name":"ventureBeatRss","type":"string","value":"https://venturebeat.com/category/ai/feed/"},{"id":"id-6","name":"recipientEmail","type":"string","value":"\u003c__PLACEHOLDER_VALUE__Recipient Email Address__\u003e"}]},"includeOtherFields":true,"options":{}},"position":[-224,288],"type":"n8n-nodes-base.set","typeVersion":3.4},{"id":"96be5cf8-4767-40b1-b016-695fd43937cc","name":"Fetch NewsAPI Articles","parameters":{"options":{},"url":"={{ $('Workflow Configuration').first().json.newsApiUrl }}?q=artificial intelligence OR AI OR machine learning\u0026language=en\u0026sortBy=publishedAt\u0026pageSize=20\u0026apiKey={{ $('Workflow Configuration').first().json.newsApiKey }}"},"position":[0,0],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"ea5ff4c7-9020-4848-8a95-757db9f5f559","name":"Fetch TechCrunch RSS","parameters":{"options":{},"url":"={{ $('Workflow Configuration').first().json.techCrunchRss }}"},"position":[0,192],"type":"n8n-nodes-base.rssFeedRead","typeVersion":1.2},{"id":"9a257f49-a700-46bf-b365-00a7c9410b27","name":"Fetch MIT Tech Review RSS","parameters":{"options":{},"url":"={{ $('Workflow Configuration').first().json.mitTechReviewRss }}"},"position":[0,384],"type":"n8n-nodes-base.rssFeedRead","typeVersion":1.2},{"id":"563fbc30-180c-4139-b6f9-87d84f552d20","name":"Fetch VentureBeat AI RSS","parameters":{"options":{},"url":"={{ $('Workflow Configuration').first().json.ventureBeatRss }}"},"position":[0,576],"type":"n8n-nodes-base.rssFeedRead","typeVersion":1.2},{"id":"60a56578-e435-4fb6-9fa9-2db21127cda2","name":"Merge All News Sources","parameters":{"mode":"combine","options":{}},"position":[224,96],"type":"n8n-nodes-base.merge","typeVersion":3.2},{"id":"9740e351-9f47-41c3-a6ea-85b4c41241e0","name":"Filter and Clean News Data","parameters":{"jsCode":"// Filter and clean news data from multiple sources\nconst now = new Date();\nconst twentyFourHoursAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);\n\n// Extract and normalize data from all sources\nconst articles = [];\n\nfor (const item of $input.all()) {\n let article = {\n title: '',\n description: '',\n link: '',\n publishedDate: null\n };\n \n // Handle different source formats\n if (item.json.title) {\n article.title = item.json.title;\n }\n \n if (item.json.description) {\n article.description = item.json.description;\n } else if (item.json.content) {\n article.description = item.json.content;\n } else if (item.json.summary) {\n article.description = item.json.summary;\n }\n \n if (item.json.link) {\n article.link = item.json.link;\n } else if (item.json.url) {\n article.link = item.json.url;\n }\n \n // Parse published date from various formats\n if (item.json.publishedAt) {\n article.publishedDate = new Date(item.json.publishedAt);\n } else if (item.json.pubDate) {\n article.publishedDate = new Date(item.json.pubDate);\n } else if (item.json.published) {\n article.publishedDate = new Date(item.json.published);\n } else if (item.json.isoDate) {\n article.publishedDate = new Date(item.json.isoDate);\n }\n \n // Only add articles with required fields\n if (article.title \u0026\u0026 article.link \u0026\u0026 article.publishedDate) {\n articles.push(article);\n }\n}\n\n// Filter out articles older than 24 hours\nconst recentArticles = articles.filter(article =\u003e {\n return article.publishedDate \u003e= twentyFourHoursAgo;\n});\n\n// Remove duplicates based on title similarity\nconst uniqueArticles = [];\nconst seenTitles = new Set();\n\nfor (const article of recentArticles) {\n // Normalize title for comparison (lowercase, remove special chars)\n const normalizedTitle = article.title.toLowerCase().replace(/[^a-z0-9\\s]/g, '').trim();\n \n // Check for similar titles (simple approach)\n let isDuplicate = false;\n for (const seenTitle of seenTitles) {\n // Calculate simple similarity (if 80% of words match, consider duplicate)\n const words1 = normalizedTitle.split(/\\s+/);\n const words2 = seenTitle.split(/\\s+/);\n const commonWords = words1.filter(word =\u003e words2.includes(word));\n const similarity = commonWords.length / Math.max(words1.length, words2.length);\n \n if (similarity \u003e 0.8) {\n isDuplicate = true;\n break;\n }\n }\n \n if (!isDuplicate) {\n seenTitles.add(normalizedTitle);\n uniqueArticles.push(article);\n }\n}\n\n// Sort by published date descending (newest first)\nuniqueArticles.sort((a, b) =\u003e b.publishedDate - a.publishedDate);\n\n// Limit to top 15 articles\nconst topArticles = uniqueArticles.slice(0, 15);\n\n// Return as n8n items\nreturn topArticles.map(article =\u003e ({\n json: {\n title: article.title,\n description: article.description,\n link: article.link,\n publishedDate: article.publishedDate.toISOString()\n }\n}));"},"position":[448,96],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"9d48e12c-e3a8-4e9f-ae3e-51e5268afa39","name":"AI News Summarizer","parameters":{"options":{},"promptType":"define","text":"You are an AI news analyst. Analyze the following AI news articles and create a comprehensive daily digest. Group the news by themes (e.g., LLMs, Computer Vision, AI Ethics, Industry News). For each article, provide a concise summary highlighting key points. Identify the most important trends and developments. Format the output as structured JSON with sections: {\"digest_title\": \"AI News Digest - [Date]\", \"summary\": \"Brief overview of today's AI landscape\", \"sections\": [{\"theme\": \"theme name\", \"articles\": [{\"title\": \"\", \"summary\": \"\", \"link\": \"\", \"importance\": \"high/medium/low\"}]}], \"key_trends\": [\"trend 1\", \"trend 2\"]}"},"position":[672,96],"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"c3dce914-3708-429b-a6a7-91b46d3440d6","name":"OpenAI GPT-4","parameters":{"model":{"__rl":true,"mode":"id","value":"gpt-4o"},"options":{"temperature":0.3}},"position":[624,320],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"id":"6132601d-98c6-4741-a1da-802876766f58","name":"Generate HTML Email","parameters":{"jsCode":"// Generate Beautiful HTML Email from AI Digest JSON\nconst items = $input.all();\nconst digestData = items[0].json;\n\n// Helper function to generate importance badge\nfunction getImportanceBadge(importance) {\n const colors = {\n 'high': '#dc3545',\n 'medium': '#ffc107',\n 'low': '#28a745'\n };\n const color = colors[importance?.toLowerCase()] || '#6c757d';\n return `\u003cspan style=\"display: inline-block; padding: 4px 12px; background-color: ${color}; color: white; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;\"\u003e${importance || 'N/A'}\u003c/span\u003e`;\n}\n\n// Get current date\nconst today = new Date().toLocaleDateString('en-US', { \n weekday: 'long', \n year: 'numeric', \n month: 'long', \n day: 'numeric' \n});\n\n// Build sections HTML\nlet sectionsHTML = '';\nif (digestData.sections \u0026\u0026 Array.isArray(digestData.sections)) {\n digestData.sections.forEach(section =\u003e {\n sectionsHTML += `\n \u003cdiv style=\"margin-bottom: 40px;\"\u003e\n \u003ch2 style=\"color: #2c3e50; font-size: 24px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 3px solid #3498db;\"\u003e\n ${section.theme || 'News Section'}\n \u003c/h2\u003e\n \u003cdiv style=\"margin-left: 10px;\"\u003e\n `;\n \n if (section.articles \u0026\u0026 Array.isArray(section.articles)) {\n section.articles.forEach(article =\u003e {\n sectionsHTML += `\n \u003cdiv style=\"margin-bottom: 25px; padding: 20px; background-color: #f8f9fa; border-left: 4px solid #3498db; border-radius: 4px;\"\u003e\n \u003cdiv style=\"margin-bottom: 8px;\"\u003e\n \u003ca href=\"${article.url || '#'}\" style=\"color: #2c3e50; font-size: 18px; font-weight: 600; text-decoration: none;\"\u003e\n ${article.title || 'Untitled Article'}\n \u003c/a\u003e\n \u003cspan style=\"margin-left: 10px;\"\u003e${getImportanceBadge(article.importance)}\u003c/span\u003e\n \u003c/div\u003e\n \u003cp style=\"color: #555; font-size: 14px; line-height: 1.6; margin: 10px 0 0 0;\"\u003e\n ${article.summary || 'No summary available.'}\n \u003c/p\u003e\n \u003c/div\u003e\n `;\n });\n }\n \n sectionsHTML += `\n \u003c/div\u003e\n \u003c/div\u003e\n `;\n });\n}\n\n// Build key trends HTML\nlet keyTrendsHTML = '';\nif (digestData.keyTrends \u0026\u0026 Array.isArray(digestData.keyTrends)) {\n keyTrendsHTML = digestData.keyTrends.map(trend =\u003e \n `\u003cli style=\"margin-bottom: 8px; color: #555;\"\u003e${trend}\u003c/li\u003e`\n ).join('');\n}\n\n// Complete HTML email template\nconst htmlEmail = `\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n \u003cmeta charset=\"UTF-8\"\u003e\n \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n \u003ctitle\u003eDaily AI News Digest\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody style=\"margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #ecf0f1;\"\u003e\n \u003cdiv style=\"max-width: 800px; margin: 0 auto; background-color: #ffffff;\"\u003e\n \n \u003c!-- Header --\u003e\n \u003cdiv style=\"background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 40px 30px; text-align: center;\"\u003e\n \u003ch1 style=\"color: #ffffff; margin: 0; font-size: 32px; font-weight: 700;\"\u003e🤖 Daily AI News Digest\u003c/h1\u003e\n \u003cp style=\"color: #f0f0f0; margin: 10px 0 0 0; font-size: 16px;\"\u003e${today}\u003c/p\u003e\n \u003c/div\u003e\n \n \u003c!-- Main Content --\u003e\n \u003cdiv style=\"padding: 40px 30px;\"\u003e\n ${sectionsHTML || '\u003cp style=\"color: #555;\"\u003eNo news sections available today.\u003c/p\u003e'}\n \u003c/div\u003e\n \n \u003c!-- Key Trends Footer --\u003e\n \u003cdiv style=\"background-color: #34495e; padding: 30px; color: #ffffff;\"\u003e\n \u003ch3 style=\"margin: 0 0 15px 0; font-size: 20px; color: #ffffff;\"\u003e📊 Key Trends Today\u003c/h3\u003e\n ${keyTrendsHTML ? `\u003cul style=\"margin: 0; padding-left: 20px; line-height: 1.8;\"\u003e${keyTrendsHTML}\u003c/ul\u003e` : '\u003cp style=\"color: #ecf0f1;\"\u003eNo key trends identified today.\u003c/p\u003e'}\n \u003c/div\u003e\n \n \u003c!-- Footer --\u003e\n \u003cdiv style=\"background-color: #2c3e50; padding: 20px 30px; text-align: center;\"\u003e\n \u003cp style=\"color: #95a5a6; margin: 0; font-size: 12px;\"\u003e\n Generated by your AI News Automation | Powered by n8n\n \u003c/p\u003e\n \u003c/div\u003e\n \n \u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n`;\n\nreturn [{\n json: {\n htmlEmail: htmlEmail,\n subject: `🤖 Daily AI News Digest - ${today}`,\n digestData: digestData\n }\n}];"},"position":[1024,96],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"9d9b50db-2b05-4aa7-98de-d43d53471879","name":"Send Email via Gmail","parameters":{"message":"={{ $json.html }}","options":{},"sendTo":"={{ $('Workflow Configuration').first().json.recipientEmail }}","subject":"=AI News Daily Digest - {{ new Date().toLocaleDateString('zh-CN') }}"},"position":[1248,96],"type":"n8n-nodes-base.gmail","typeVersion":2.1,"webhookId":"74ec12f9-d7d2-4b34-822b-c8cdec044607"}],"pinData":{},"settings":{"executionOrder":"v1"},"tags":[],"versionId":"4889409a-0644-4015-9f13-e05686f5a660"}
      
{"active":false,"connections":{"AI Analysis Agent":{"main":[[{"index":0,"node":"Generate HTML Report","type":"main"}]]},"Format Final Data":{"main":[[{"index":0,"node":"Save to Google Sheets","type":"main"},{"index":0,"node":"Prepare Data for AI Analysis","type":"main"}]]},"Generate HTML Report":{"main":[[{"index":0,"node":"Convert to HTML File","type":"main"}]]},"Merge All Data":{"main":[[{"index":0,"node":"Remove Duplicates","type":"main"}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"index":0,"node":"AI Analysis Agent","type":"ai_languageModel"}]]},"Parse Amazon Data":{"main":[[{"index":0,"node":"Merge All Data","type":"main"}]]},"Parse Reddit Data":{"main":[[{"index":3,"node":"Merge All Data","type":"main"}]]},"Parse Twitter Data":{"main":[[{"index":2,"node":"Merge All Data","type":"main"}]]},"Parse eBay Data":{"main":[[{"index":1,"node":"Merge All Data","type":"main"}]]},"Prepare Data for AI Analysis":{"main":[[{"index":0,"node":"AI Analysis Agent","type":"main"}]]},"Remove Duplicates":{"main":[[{"index":0,"node":"Format Final Data","type":"main"}]]},"Schedule Trigger":{"main":[[{"index":0,"node":"Workflow Configuration","type":"main"}]]},"Scrape Amazon Data":{"main":[[{"index":0,"node":"Parse Amazon Data","type":"main"}]]},"Scrape Reddit Data":{"main":[[{"index":0,"node":"Parse Reddit Data","type":"main"}]]},"Scrape Twitter Data":{"main":[[{"index":0,"node":"Parse Twitter Data","type":"main"}]]},"Scrape eBay Data":{"main":[[{"index":0,"node":"Parse eBay Data","type":"main"}]]},"Structured Output Parser":{"ai_outputParser":[[{"index":0,"node":"AI Analysis Agent","type":"ai_outputParser"}]]},"Workflow Configuration":{"main":[[{"index":0,"node":"Scrape Amazon Data","type":"main"},{"index":0,"node":"Scrape eBay Data","type":"main"},{"index":0,"node":"Scrape Twitter Data","type":"main"},{"index":0,"node":"Scrape Reddit Data","type":"main"}]]}},"id":"fh2noODklRgBAkE3","meta":{"instanceId":"382e376cf0c77261ab58b52fb5203072e6f3d632e43adf5a68c3823147c39dcd","templateCredsSetupCompleted":true},"name":"Multi-Platform E-commerce and Social Media Data Scraping and Analysis","nodes":[{"id":"c254fac4-b63e-44d7-b4c6-6846c7e73768","name":"Schedule Trigger","parameters":{"rule":{"interval":[{"triggerAtHour":9}]}},"position":[-448,288],"type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2},{"id":"5a32c305-6fdd-4a4e-9516-d93e23744073","name":"Workflow Configuration","parameters":{"assignments":{"assignments":[{"id":"id-1","name":"keyword","type":"string","value":"\u003c__PLACEHOLDER_VALUE__Industry keyword to search (e.g., wireless earbuds, gaming laptop)__\u003e"},{"id":"id-2","name":"amazonApiUrl","type":"string","value":"\u003c__PLACEHOLDER_VALUE__Amazon API endpoint URL__\u003e"},{"id":"id-3","name":"ebayApiUrl","type":"string","value":"\u003c__PLACEHOLDER_VALUE__eBay API endpoint URL__\u003e"},{"id":"id-4","name":"twitterApiUrl","type":"string","value":"\u003c__PLACEHOLDER_VALUE__Twitter API endpoint URL__\u003e"},{"id":"id-5","name":"redditApiUrl","type":"string","value":"\u003c__PLACEHOLDER_VALUE__Reddit API endpoint URL__\u003e"}]},"includeOtherFields":true,"options":{}},"position":[-224,288],"type":"n8n-nodes-base.set","typeVersion":3.4},{"id":"cb604dce-6fad-4e9a-9223-0c2ac8f09ebb","name":"Scrape Amazon Data","parameters":{"headerParameters":{"parameters":[{"name":"Authorization","value":"\u003c__PLACEHOLDER_VALUE__Amazon API key or token__\u003e"}]},"options":{},"queryParameters":{"parameters":[{"name":"q","value":"={{ $('Workflow Configuration').first().json.keyword }}"}]},"sendHeaders":true,"sendQuery":true,"url":"={{ $('Workflow Configuration').first().json.amazonApiUrl }}"},"position":[0,0],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"bbe89f06-eac1-4b67-b618-f7c1a0220dcf","name":"Scrape eBay Data","parameters":{"headerParameters":{"parameters":[{"name":"Authorization","value":"\u003c__PLACEHOLDER_VALUE__eBay API key or token__\u003e"}]},"options":{},"queryParameters":{"parameters":[{"name":"keywords","value":"={{ $('Workflow Configuration').first().json.keyword }}"}]},"sendHeaders":true,"sendQuery":true,"url":"={{ $('Workflow Configuration').first().json.ebayApiUrl }}"},"position":[0,192],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"2eb8ec46-6acf-4480-95e6-7e3a8277ca3d","name":"Scrape Twitter Data","parameters":{"headerParameters":{"parameters":[{"name":"Authorization","value":"\u003c__PLACEHOLDER_VALUE__Twitter Bearer token__\u003e"}]},"options":{},"queryParameters":{"parameters":[{"name":"query","value":"={{ $('Workflow Configuration').first().json.keyword }}"}]},"sendHeaders":true,"sendQuery":true,"url":"={{ $('Workflow Configuration').first().json.twitterApiUrl }}"},"position":[0,384],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"f3412e58-c89c-4611-bec1-2c8175475132","name":"Scrape Reddit Data","parameters":{"headerParameters":{"parameters":[{"name":"Authorization","value":"\u003c__PLACEHOLDER_VALUE__Reddit API token__\u003e"}]},"options":{},"queryParameters":{"parameters":[{"name":"q","value":"={{ $('Workflow Configuration').first().json.keyword }}"}]},"sendHeaders":true,"sendQuery":true,"url":"={{ $('Workflow Configuration').first().json.redditApiUrl }}"},"position":[0,576],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"f8aeb54d-ea56-4363-83df-c06a848e607c","name":"Parse Amazon Data","parameters":{"jsCode":"// Parse Amazon API response and extract product data\nconst items = $input.all();\nconst parsedData = [];\n\nfor (const item of items) {\n const data = item.json;\n \n // Handle different possible response structures\n let products = [];\n \n if (Array.isArray(data)) {\n products = data;\n } else if (data.products \u0026\u0026 Array.isArray(data.products)) {\n products = data.products;\n } else if (data.results \u0026\u0026 Array.isArray(data.results)) {\n products = data.results;\n } else if (data.items \u0026\u0026 Array.isArray(data.items)) {\n products = data.items;\n } else {\n // Single product object\n products = [data];\n }\n \n // Parse each product\n for (let i = 0; i \u003c products.length; i++) {\n const product = products[i];\n \n parsedData.push({\n platform: 'Amazon',\n productName: product.title || product.name || product.productName || '',\n price: parseFloat(product.price || product.currentPrice || product.amount || 0),\n rating: parseFloat(product.rating || product.stars || product.averageRating || 0),\n reviewCount: parseInt(product.reviewCount || product.reviews || product.numberOfReviews || 0),\n salesVolume: parseInt(product.salesVolume || product.sales || product.unitsSold || 0),\n searchRanking: product.searchRanking || product.rank || product.position || (i + 1),\n url: product.url || product.link || product.productUrl || '',\n timestamp: new Date().toISOString()\n });\n }\n}\n\nreturn parsedData.map(item =\u003e ({ json: item }));"},"position":[224,0],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"d966b1e5-2e21-438d-83fb-df4f4acf7ab2","name":"Parse eBay Data","parameters":{"jsCode":"// Parse eBay API response and extract product data\nconst items = $input.all();\nconst parsedData = [];\n\nfor (const item of items) {\n const data = item.json;\n \n // Handle different possible eBay API response structures\n const products = data.itemSummaries || data.items || data.searchResult?.item || [];\n \n if (Array.isArray(products)) {\n products.forEach((product, index) =\u003e {\n parsedData.push({\n platform: 'eBay',\n productName: product.title || product.name || '',\n price: parseFloat(product.price?.value || product.sellingStatus?.currentPrice?.value || product.price || 0),\n rating: parseFloat(product.averageRating || product.rating || 0),\n reviewCount: parseInt(product.reviewCount || product.ratingCount || 0),\n salesVolume: parseInt(product.quantitySold || product.soldQuantity || 0),\n searchRanking: index + 1,\n url: product.itemWebUrl || product.viewItemURL || product.url || '',\n timestamp: new Date().toISOString()\n });\n });\n } else if (typeof products === 'object') {\n // Handle single product response\n parsedData.push({\n platform: 'eBay',\n productName: products.title || products.name || '',\n price: parseFloat(products.price?.value || products.sellingStatus?.currentPrice?.value || products.price || 0),\n rating: parseFloat(products.averageRating || products.rating || 0),\n reviewCount: parseInt(products.reviewCount || products.ratingCount || 0),\n salesVolume: parseInt(products.quantitySold || products.soldQuantity || 0),\n searchRanking: 1,\n url: products.itemWebUrl || products.viewItemURL || products.url || '',\n timestamp: new Date().toISOString()\n });\n }\n}\n\nreturn parsedData.map(item =\u003e ({ json: item }));"},"position":[224,192],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"b63810cb-cee8-415a-8d59-21c476f6cab2","name":"Parse Twitter Data","parameters":{"jsCode":"// Parse Twitter API response and extract relevant data\nconst items = $input.all();\nconst parsedData = [];\n\nfor (const item of items) {\n const data = item.json;\n \n // Handle different Twitter API response structures\n const tweets = data.data || data.tweets || [data];\n \n for (const tweet of tweets) {\n // Calculate engagement score (weighted sum of interactions)\n const retweetCount = tweet.public_metrics?.retweet_count || tweet.retweet_count || 0;\n const likeCount = tweet.public_metrics?.like_count || tweet.like_count || 0;\n const replyCount = tweet.public_metrics?.reply_count || tweet.reply_count || 0;\n const engagementScore = (retweetCount * 2) + likeCount + (replyCount * 1.5);\n \n // Extract author information\n const author = tweet.author?.username || tweet.user?.screen_name || tweet.author_id || 'Unknown';\n \n // Extract tweet text\n const content = tweet.text || tweet.full_text || '';\n \n // Build tweet URL\n const tweetId = tweet.id || tweet.id_str || '';\n const url = tweetId ? `https://twitter.com/${author}/status/${tweetId}` : '';\n \n // Extract timestamp\n const timestamp = tweet.created_at || new Date().toISOString();\n \n parsedData.push({\n json: {\n platform: 'Twitter',\n content: content,\n author: author,\n retweetCount: retweetCount,\n likeCount: likeCount,\n replyCount: replyCount,\n engagementScore: Math.round(engagementScore),\n url: url,\n timestamp: timestamp\n }\n });\n }\n}\n\nreturn parsedData;"},"position":[224,384],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"6927bb7f-e196-4dbc-be27-93e3e38accff","name":"Parse Reddit Data","parameters":{"jsCode":"// Parse Reddit API response and extract relevant data\nconst items = $input.all();\nconst parsedData = [];\n\nfor (const item of items) {\n const data = item.json;\n \n // Handle Reddit API response structure\n // Reddit API typically returns data in data.children array\n const posts = data.data?.children || [];\n \n for (const post of posts) {\n const postData = post.data;\n \n // Calculate engagement score (upvotes + comments)\n const upvotes = postData.ups || 0;\n const commentCount = postData.num_comments || 0;\n const engagementScore = upvotes + commentCount;\n \n parsedData.push({\n json: {\n platform: 'Reddit',\n content: postData.title || '',\n subreddit: postData.subreddit || '',\n upvotes: upvotes,\n commentCount: commentCount,\n engagementScore: engagementScore,\n url: `https://reddit.com${postData.permalink}` || '',\n timestamp: postData.created_utc ? new Date(postData.created_utc * 1000).toISOString() : new Date().toISOString()\n }\n });\n }\n}\n\nreturn parsedData;"},"position":[224,576],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"4a46e435-421d-4071-8533-31a297c6a9cc","name":"Merge All Data","parameters":{"numberInputs":4},"position":[448,256],"type":"n8n-nodes-base.merge","typeVersion":3.2},{"id":"e2575738-fa3d-4619-b0dc-5e7c94a5636c","name":"Remove Duplicates","parameters":{"compare":"selectedFields","fieldsToCompare":"url","options":{}},"position":[672,288],"type":"n8n-nodes-base.removeDuplicates","typeVersion":2},{"id":"1092210b-0764-414a-bd3e-11b62ed6ec60","name":"Format Final Data","parameters":{"assignments":{"assignments":[{"id":"id-1","name":"platform","type":"string","value":"={{ $json.platform }}"},{"id":"id-2","name":"productName","type":"string","value":"={{ $json.productName || $json.content }}"},{"id":"id-3","name":"price","type":"number","value":"={{ $json.price }}"},{"id":"id-4","name":"rating","type":"number","value":"={{ $json.rating }}"},{"id":"id-5","name":"reviewCount","type":"number","value":"={{ $json.reviewCount || $json.commentCount }}"},{"id":"id-6","name":"salesVolume","type":"number","value":"={{ $json.salesVolume }}"},{"id":"id-7","name":"retweetCount","type":"number","value":"={{ $json.retweetCount }}"},{"id":"id-8","name":"likeCount","type":"number","value":"={{ $json.likeCount }}"},{"id":"id-9","name":"upvotes","type":"number","value":"={{ $json.upvotes }}"},{"id":"id-10","name":"engagementScore","type":"number","value":"={{ $json.engagementScore }}"},{"id":"id-11","name":"url","type":"string","value":"={{ $json.url }}"},{"id":"id-12","name":"timestamp","type":"string","value":"={{ $json.timestamp }}"},{"id":"id-13","name":"dataType","type":"string","value":"={{ $json.productName ? 'product' : 'social_post' }}"}]},"options":{}},"position":[896,288],"type":"n8n-nodes-base.set","typeVersion":3.4},{"id":"16d527db-5ad1-45b5-87ca-15b9c2a0e7f0","name":"Save to Google Sheets","parameters":{"columns":{"attemptToConvertTypes":false,"convertFieldsToString":false,"mappingMode":"autoMapInputData","matchingColumns":[],"schema":[],"value":{}},"documentId":{"__rl":true,"mode":"id","value":"\u003c__PLACEHOLDER_VALUE__Google Sheets document ID__\u003e"},"operation":"appendOrUpdate","options":{},"sheetName":{"__rl":true,"mode":"name","value":"\u003c__PLACEHOLDER_VALUE__Sheet name (e.g., Data Analysis)__\u003e"}},"position":[1120,192],"type":"n8n-nodes-base.googleSheets","typeVersion":4.7},{"id":"1bdbc2fd-f941-4372-b96a-8c92012fcf5a","name":"Prepare Data for AI Analysis","parameters":{"jsCode":"// Aggregate and summarize all data for AI analysis\nconst items = $input.all();\n\n// Initialize counters and arrays\nlet productCount = 0;\nlet socialPostCount = 0;\nconst platformBreakdown = {};\nconst products = [];\nconst socialPosts = [];\nconst prices = [];\n\n// Process all items\nfor (const item of items) {\n const data = item.json;\n const platform = data.platform || 'Unknown';\n \n // Count by platform\n platformBreakdown[platform] = (platformBreakdown[platform] || 0) + 1;\n \n // Categorize by data type\n if (data.dataType === 'product' || data.productName) {\n productCount++;\n products.push({\n platform: platform,\n name: data.productName,\n price: data.price || 0,\n rating: data.rating || 0,\n reviewCount: data.reviewCount || 0,\n salesVolume: data.salesVolume || 0,\n url: data.url\n });\n \n if (data.price \u0026\u0026 data.price \u003e 0) {\n prices.push(data.price);\n }\n } else {\n socialPostCount++;\n socialPosts.push({\n platform: platform,\n content: data.content || data.productName || '',\n engagementScore: data.engagementScore || 0,\n retweetCount: data.retweetCount || 0,\n likeCount: data.likeCount || 0,\n upvotes: data.upvotes || 0,\n commentCount: data.commentCount || 0,\n url: data.url\n });\n }\n}\n\n// Sort products by rating and sales\nconst topProductsByRating = products\n .filter(p =\u003e p.rating \u003e 0)\n .sort((a, b) =\u003e b.rating - a.rating)\n .slice(0, 10);\n\nconst topProductsBySales = products\n .filter(p =\u003e p.salesVolume \u003e 0)\n .sort((a, b) =\u003e b.salesVolume - a.salesVolume)\n .slice(0, 10);\n\n// Sort social posts by engagement\nconst topSocialPosts = socialPosts\n .sort((a, b) =\u003e b.engagementScore - a.engagementScore)\n .slice(0, 10);\n\n// Calculate price statistics\nlet priceStats = {\n min: 0,\n max: 0,\n average: 0,\n median: 0\n};\n\nif (prices.length \u003e 0) {\n prices.sort((a, b) =\u003e a - b);\n priceStats.min = prices[0];\n priceStats.max = prices[prices.length - 1];\n priceStats.average = prices.reduce((sum, p) =\u003e sum + p, 0) / prices.length;\n priceStats.median = prices[Math.floor(prices.length / 2)];\n}\n\n// Calculate average ratings and engagement\nconst avgRating = products.length \u003e 0 \n ? products.reduce((sum, p) =\u003e sum + (p.rating || 0), 0) / products.filter(p =\u003e p.rating \u003e 0).length \n : 0;\n\nconst avgEngagement = socialPosts.length \u003e 0\n ? socialPosts.reduce((sum, p) =\u003e sum + p.engagementScore, 0) / socialPosts.length\n : 0;\n\n// Build aggregated summary\nconst summary = {\n totalItems: items.length,\n totalProducts: productCount,\n totalSocialPosts: socialPostCount,\n platformBreakdown: platformBreakdown,\n \n productInsights: {\n totalProducts: productCount,\n topProductsByRating: topProductsByRating,\n topProductsBySales: topProductsBySales,\n averageRating: Math.round(avgRating * 100) / 100,\n priceStatistics: {\n minimum: Math.round(priceStats.min * 100) / 100,\n maximum: Math.round(priceStats.max * 100) / 100,\n average: Math.round(priceStats.average * 100) / 100,\n median: Math.round(priceStats.median * 100) / 100\n }\n },\n \n socialInsights: {\n totalPosts: socialPostCount,\n topPostsByEngagement: topSocialPosts,\n averageEngagement: Math.round(avgEngagement)\n },\n \n trends: {\n mostActiveplatform: Object.keys(platformBreakdown).reduce((a, b) =\u003e \n platformBreakdown[a] \u003e platformBreakdown[b] ? a : b, 'None'),\n totalDataPoints: items.length,\n analysisTimestamp: new Date().toISOString()\n },\n \n rawDataSample: items.slice(0, 5).map(item =\u003e item.json)\n};\n\n// Return single aggregated item\nreturn [{ json: summary }];"},"position":[1120,384],"type":"n8n-nodes-base.code","typeVersion":2},{"credentials":{"openAiApi":{"id":"RPXDZXkSVBenC5L2","name":"n8n free OpenAI API credits"}},"id":"3ece5a2d-afc7-4f52-b0b3-367cb0d7b488","name":"OpenAI Chat Model","parameters":{"model":{"__rl":true,"mode":"id","value":"gpt-4o"},"options":{}},"position":[1328,608],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"id":"02761c8b-3cde-4564-bd7c-a7e3a8d53034","name":"Structured Output Parser","parameters":{"inputSchema":"{\n \"type\": \"object\",\n \"properties\": {\n \"executiveSummary\": {\n \"type\": \"string\",\n \"description\": \"A comprehensive executive summary of the analysis\"\n },\n \"marketTrends\": {\n \"type\": \"array\",\n \"description\": \"Key market trends identified from the data\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"trend\": {\n \"type\": \"string\",\n \"description\": \"Name or title of the trend\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Detailed description of the trend\"\n }\n },\n \"required\": [\"trend\", \"description\"]\n }\n },\n \"topProducts\": {\n \"type\": \"array\",\n \"description\": \"Top performing products across platforms\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Product name\"\n },\n \"platform\": {\n \"type\": \"string\",\n \"description\": \"Platform where the product is listed\"\n },\n \"price\": {\n \"type\": \"number\",\n \"description\": \"Product price\"\n },\n \"rating\": {\n \"type\": \"number\",\n \"description\": \"Product rating\"\n },\n \"salesVolume\": {\n \"type\": \"number\",\n \"description\": \"Sales volume or units sold\"\n },\n \"reason\": {\n \"type\": \"string\",\n \"description\": \"Reason why this product is top performing\"\n }\n },\n \"required\": [\"name\", \"platform\", \"price\", \"rating\", \"salesVolume\", \"reason\"]\n }\n },\n \"socialMediaInsights\": {\n \"type\": \"array\",\n \"description\": \"Insights from social media platforms\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"type\": \"string\",\n \"description\": \"Social media platform name\"\n },\n \"topPost\": {\n \"type\": \"string\",\n \"description\": \"Content of the top performing post\"\n },\n \"engagement\": {\n \"type\": \"number\",\n \"description\": \"Engagement score or metrics\"\n },\n \"insight\": {\n \"type\": \"string\",\n \"description\": \"Key insight from this platform\"\n }\n },\n \"required\": [\"platform\", \"topPost\", \"engagement\", \"insight\"]\n }\n },\n \"priceAnalysis\": {\n \"type\": \"object\",\n \"description\": \"Price analysis across all products\",\n \"properties\": {\n \"avgPrice\": {\n \"type\": \"number\",\n \"description\": \"Average price\"\n },\n \"minPrice\": {\n \"type\": \"number\",\n \"description\": \"Minimum price\"\n },\n \"maxPrice\": {\n \"type\": \"number\",\n \"description\": \"Maximum price\"\n },\n \"priceRange\": {\n \"type\": \"string\",\n \"description\": \"Description of the price range\"\n }\n },\n \"required\": [\"avgPrice\", \"minPrice\", \"maxPrice\", \"priceRange\"]\n },\n \"recommendations\": {\n \"type\": \"array\",\n \"description\": \"Strategic recommendations based on the analysis\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"conclusion\": {\n \"type\": \"string\",\n \"description\": \"Overall conclusion of the analysis\"\n }\n },\n \"required\": [\"executiveSummary\", \"marketTrends\", \"topProducts\", \"socialMediaInsights\", \"priceAnalysis\", \"recommendations\", \"conclusion\"]\n}","schemaType":"manual"},"position":[1480,608],"type":"@n8n/n8n-nodes-langchain.outputParserStructured","typeVersion":1.3},{"id":"3e1893dc-d3f6-4ac3-8edd-670b00dbab0d","name":"AI Analysis Agent","parameters":{"hasOutputParser":true,"options":{},"promptType":"define","text":"=You are a professional e-commerce market analyst. Analyze the provided data from Amazon, eBay, Twitter, and Reddit. Generate a comprehensive product selection report including: 1) Executive summary of market opportunities, 2) Key market trends and patterns, 3) Top recommended products with detailed reasoning, 4) Social media sentiment and engagement insights, 5) Price analysis and competitive positioning, 6) Strategic recommendations for product selection. Be specific, data-driven, and actionable in your analysis."},"position":[1344,384],"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2},{"id":"7bf2e1b3-0537-4705-be13-cfc0b1eb1ec4","name":"Generate HTML Report","parameters":{"jsCode":"// Generate a beautiful HTML report from AI analysis output\nconst items = $input.all();\nconst analysisData = items[0].json;\n\n// Extract data from AI analysis\nconst executiveSummary = analysisData.executiveSummary || analysisData.summary || 'No executive summary available.';\nconst marketTrends = analysisData.marketTrends || analysisData.trends || [];\nconst topProducts = analysisData.topProducts || analysisData.products || [];\nconst socialInsights = analysisData.socialInsights || analysisData.social || {};\nconst priceAnalysis = analysisData.priceAnalysis || analysisData.pricing || {};\nconst recommendations = analysisData.recommendations || [];\nconst conclusion = analysisData.conclusion || 'Analysis complete.';\n\n// Get current date\nconst reportDate = new Date().toLocaleDateString('en-US', { \n year: 'numeric', \n month: 'long', \n day: 'numeric' \n});\n\n// Generate HTML report\nconst html = `\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n \u003cmeta charset=\"UTF-8\"\u003e\n \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n \u003ctitle\u003eMarket Analysis Report\u003c/title\u003e\n \u003cstyle\u003e\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n \n body {\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n line-height: 1.6;\n color: #333;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n padding: 20px;\n }\n \n .container {\n max-width: 1200px;\n margin: 0 auto;\n background: white;\n border-radius: 15px;\n box-shadow: 0 20px 60px rgba(0,0,0,0.3);\n overflow: hidden;\n }\n \n .header {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n padding: 40px;\n text-align: center;\n }\n \n .header h1 {\n font-size: 2.5em;\n margin-bottom: 10px;\n font-weight: 700;\n }\n \n .header .date {\n font-size: 1.1em;\n opacity: 0.9;\n }\n \n .content {\n padding: 40px;\n }\n \n .section {\n margin-bottom: 40px;\n }\n \n .section-title {\n font-size: 1.8em;\n color: #667eea;\n margin-bottom: 20px;\n padding-bottom: 10px;\n border-bottom: 3px solid #667eea;\n font-weight: 600;\n }\n \n .executive-summary {\n background: #f8f9ff;\n padding: 25px;\n border-radius: 10px;\n border-left: 5px solid #667eea;\n font-size: 1.1em;\n line-height: 1.8;\n }\n \n .trends-grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n gap: 20px;\n margin-top: 20px;\n }\n \n .trend-card {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n padding: 25px;\n border-radius: 10px;\n box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);\n transition: transform 0.3s ease;\n }\n \n .trend-card:hover {\n transform: translateY(-5px);\n }\n \n .trend-card h3 {\n font-size: 1.3em;\n margin-bottom: 10px;\n }\n \n .trend-card p {\n opacity: 0.95;\n line-height: 1.6;\n }\n \n .products-table {\n width: 100%;\n border-collapse: collapse;\n margin-top: 20px;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n border-radius: 10px;\n overflow: hidden;\n }\n \n .products-table thead {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n }\n \n .products-table th {\n padding: 15px;\n text-align: left;\n font-weight: 600;\n font-size: 1.05em;\n }\n \n .products-table td {\n padding: 15px;\n border-bottom: 1px solid #eee;\n }\n \n .products-table tbody tr:hover {\n background: #f8f9ff;\n }\n \n .products-table tbody tr:last-child td {\n border-bottom: none;\n }\n \n .price-badge {\n background: #4CAF50;\n color: white;\n padding: 5px 12px;\n border-radius: 20px;\n font-weight: 600;\n }\n \n .rating-badge {\n background: #FF9800;\n color: white;\n padding: 5px 12px;\n border-radius: 20px;\n font-weight: 600;\n }\n \n .social-insights {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));\n gap: 20px;\n margin-top: 20px;\n }\n \n .insight-box {\n background: #f8f9ff;\n padding: 20px;\n border-radius: 10px;\n border-left: 4px solid #667eea;\n }\n \n .insight-box h4 {\n color: #667eea;\n font-size: 1.2em;\n margin-bottom: 10px;\n }\n \n .insight-box .value {\n font-size: 2em;\n font-weight: 700;\n color: #333;\n }\n \n .insight-box .label {\n color: #666;\n font-size: 0.9em;\n margin-top: 5px;\n }\n \n .price-stats {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));\n gap: 20px;\n margin-top: 20px;\n }\n \n .stat-card {\n background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);\n color: white;\n padding: 20px;\n border-radius: 10px;\n text-align: center;\n }\n \n .stat-card .stat-value {\n font-size: 2.2em;\n font-weight: 700;\n margin-bottom: 5px;\n }\n \n .stat-card .stat-label {\n font-size: 1em;\n opacity: 0.9;\n }\n \n .recommendations-list {\n list-style: none;\n margin-top: 20px;\n }\n \n .recommendations-list li {\n background: #f8f9ff;\n padding: 15px 20px;\n margin-bottom: 15px;\n border-radius: 8px;\n border-left: 4px solid #667eea;\n font-size: 1.05em;\n line-height: 1.6;\n }\n \n .recommendations-list li:before {\n content: \"✓\";\n color: #4CAF50;\n font-weight: bold;\n margin-right: 10px;\n font-size: 1.2em;\n }\n \n .conclusion {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n padding: 30px;\n border-radius: 10px;\n font-size: 1.1em;\n line-height: 1.8;\n text-align: center;\n }\n \n .footer {\n background: #f5f5f5;\n padding: 20px;\n text-align: center;\n color: #666;\n font-size: 0.9em;\n }\n \n @media (max-width: 768px) {\n .header h1 {\n font-size: 1.8em;\n }\n \n .content {\n padding: 20px;\n }\n \n .section-title {\n font-size: 1.4em;\n }\n }\n \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n \u003cdiv class=\"container\"\u003e\n \u003cdiv class=\"header\"\u003e\n \u003ch1\u003e📊 Market Analysis Report\u003c/h1\u003e\n \u003cdiv class=\"date\"\u003eGenerated on ${reportDate}\u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"content\"\u003e\n \u003c!-- Executive Summary --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eExecutive Summary\u003c/h2\u003e\n \u003cdiv class=\"executive-summary\"\u003e\n ${executiveSummary}\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c!-- Market Trends --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eMarket Trends\u003c/h2\u003e\n \u003cdiv class=\"trends-grid\"\u003e\n ${Array.isArray(marketTrends) ? marketTrends.map((trend, index) =\u003e `\n \u003cdiv class=\"trend-card\"\u003e\n \u003ch3\u003e${trend.title || trend.name || 'Trend ' + (index + 1)}\u003c/h3\u003e\n \u003cp\u003e${trend.description || trend.detail || trend}\u003c/p\u003e\n \u003c/div\u003e\n `).join('') : '\u003cp\u003eNo market trends data available.\u003c/p\u003e'}\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c!-- Top Products --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eTop Products\u003c/h2\u003e\n \u003ctable class=\"products-table\"\u003e\n \u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eRank\u003c/th\u003e\n \u003cth\u003eProduct Name\u003c/th\u003e\n \u003cth\u003ePlatform\u003c/th\u003e\n \u003cth\u003ePrice\u003c/th\u003e\n \u003cth\u003eRating\u003c/th\u003e\n \u003cth\u003eSales/Engagement\u003c/th\u003e\n \u003c/tr\u003e\n \u003c/thead\u003e\n \u003ctbody\u003e\n ${Array.isArray(topProducts) \u0026\u0026 topProducts.length \u003e 0 ? topProducts.map((product, index) =\u003e `\n \u003ctr\u003e\n \u003ctd\u003e\u003cstrong\u003e${index + 1}\u003c/strong\u003e\u003c/td\u003e\n \u003ctd\u003e${product.name || product.productName || 'N/A'}\u003c/td\u003e\n \u003ctd\u003e${product.platform || 'N/A'}\u003c/td\u003e\n \u003ctd\u003e\u003cspan class=\"price-badge\"\u003e$${product.price || '0.00'}\u003c/span\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cspan class=\"rating-badge\"\u003e⭐ ${product.rating || 'N/A'}\u003c/span\u003e\u003c/td\u003e\n \u003ctd\u003e${product.sales || product.engagement || 'N/A'}\u003c/td\u003e\n \u003c/tr\u003e\n `).join('') : '\u003ctr\u003e\u003ctd colspan=\"6\" style=\"text-align: center;\"\u003eNo product data available.\u003c/td\u003e\u003c/tr\u003e'}\n \u003c/tbody\u003e\n \u003c/table\u003e\n \u003c/div\u003e\n \n \u003c!-- Social Media Insights --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eSocial Media Insights\u003c/h2\u003e\n \u003cdiv class=\"social-insights\"\u003e\n \u003cdiv class=\"insight-box\"\u003e\n \u003ch4\u003eTotal Engagement\u003c/h4\u003e\n \u003cdiv class=\"value\"\u003e${socialInsights.totalEngagement || '0'}\u003c/div\u003e\n \u003cdiv class=\"label\"\u003eLikes, Shares, Comments\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"insight-box\"\u003e\n \u003ch4\u003eTop Platform\u003c/h4\u003e\n \u003cdiv class=\"value\"\u003e${socialInsights.topPlatform || 'N/A'}\u003c/div\u003e\n \u003cdiv class=\"label\"\u003eMost Active Platform\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"insight-box\"\u003e\n \u003ch4\u003eSentiment Score\u003c/h4\u003e\n \u003cdiv class=\"value\"\u003e${socialInsights.sentimentScore || 'N/A'}\u003c/div\u003e\n \u003cdiv class=\"label\"\u003eOverall Sentiment\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"insight-box\"\u003e\n \u003ch4\u003eTrending Topics\u003c/h4\u003e\n \u003cdiv class=\"value\"\u003e${socialInsights.trendingTopics || '0'}\u003c/div\u003e\n \u003cdiv class=\"label\"\u003eHot Topics Identified\u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c!-- Price Analysis --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003ePrice Analysis\u003c/h2\u003e\n \u003cdiv class=\"price-stats\"\u003e\n \u003cdiv class=\"stat-card\"\u003e\n \u003cdiv class=\"stat-value\"\u003e$${priceAnalysis.average || '0.00'}\u003c/div\u003e\n \u003cdiv class=\"stat-label\"\u003eAverage Price\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"stat-card\"\u003e\n \u003cdiv class=\"stat-value\"\u003e$${priceAnalysis.min || '0.00'}\u003c/div\u003e\n \u003cdiv class=\"stat-label\"\u003eMinimum Price\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"stat-card\"\u003e\n \u003cdiv class=\"stat-value\"\u003e$${priceAnalysis.max || '0.00'}\u003c/div\u003e\n \u003cdiv class=\"stat-label\"\u003eMaximum Price\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"stat-card\"\u003e\n \u003cdiv class=\"stat-value\"\u003e$${priceAnalysis.median || '0.00'}\u003c/div\u003e\n \u003cdiv class=\"stat-label\"\u003eMedian Price\u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c!-- Recommendations --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eRecommendations\u003c/h2\u003e\n \u003cul class=\"recommendations-list\"\u003e\n ${Array.isArray(recommendations) \u0026\u0026 recommendations.length \u003e 0 ? recommendations.map(rec =\u003e `\n \u003cli\u003e${rec.text || rec.recommendation || rec}\u003c/li\u003e\n `).join('') : '\u003cli\u003eNo specific recommendations available at this time.\u003c/li\u003e'}\n \u003c/ul\u003e\n \u003c/div\u003e\n \n \u003c!-- Conclusion --\u003e\n \u003cdiv class=\"section\"\u003e\n \u003ch2 class=\"section-title\"\u003eConclusion\u003c/h2\u003e\n \u003cdiv class=\"conclusion\"\u003e\n ${conclusion}\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"footer\"\u003e\n \u003cp\u003eReport generated by n8n Automated Market Analysis System\u003c/p\u003e\n \u003cp\u003e© ${new Date().getFullYear()} - All Rights Reserved\u003c/p\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n`;\n\nreturn [{ json: { html: html } }];"},"position":[1696,384],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"3c4fb30f-c00b-439d-af61-2f821599ac03","name":"Convert to HTML File","parameters":{"operation":"html","options":{"fileName":"=Product_Selection_Report_{{ $now.format('yyyy-MM-dd_HHmmss') }}.html"}},"position":[1920,384],"type":"n8n-nodes-base.convertToFile","typeVersion":1.1}],"pinData":{},"settings":{"executionOrder":"v1"},"tags":[],"versionId":"41f82d86-b4e6-4e9c-87c1-146aaeb7289e"}

我是芋头小宝,关注我,持续带你探索GenAI的成长宇宙。
【相关文章推荐】