之前有介绍过一个自动化工作流:Get top5 on Product Hunt。也就是说每天定时通过邮件给你发送Product Hunt上的top5产品信息,帮你快速了解最新产品动态。(这一篇文章在这里:Get top5 on Product Hunt | n8n自动化工作流)
Product Hunt网站:https://www.producthunt.com/

每天收到的邮件信息:

那么问题来了,针对产品的大篇幅的评论,看起来比较耗时,我能否用AI模型,来整理评论的重要信息?比如是正面还是负面评价,评论里是否有用户的需求,是否有用户提出了产品建议之类的。 这样帮你了解产品趋势和用户想法也是非常有价值的。
比如在之前的表格下面,加一行AI的总结。

这就需要我们在n8n的流程上增加AI的节点,今天我们就来介绍下,如何在n8n使用AI节点,来达到我们分析评论的需求。
我们先说一下这个AI节点要如何配置。
其实n8n里也内置了不少AI的模型。
我们在新建节点里点击Advanced AI,就可以进行选择了。


选择后,通过API key连接上你的AI模型即可。

不过我们今天不通过这种方法来用AI模型(主要是这些模型我都没有充值渠道,没法用 o(╥﹏╥)o )
我们直接用HTTP Request节点的方式来连接AI模型

这里我选择用阿里的通义千问AI模型来试试。因为通义千问的qwen-turbo模型,注册后的一个月内,提供了免费的1000000个token使用。还是很方便的。
官网:https://dashscope.console.aliyun.com/
在官网注册完成之后,创建一个API key,复制后妥善保管。

接下来我们通过API来使用通义千问。
可以参考API文档里的参数说明。

好的,那么我们在n8n的HTTP Request节点来配置



这几个配置项如下:
1、method:POST
2、URL:https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation 这个是AI模型的API地址
3、headers:把header的开关打开,需要配置两个参数
①name:Content-Type ;value:application/json
②name:Authorization ;value:Bearer [your api key]
4、body:把body的开关打开,body的类型选择json,然后在json的输入框内输入模型的信息。
这里需要两个字段:
model:数据类型是string,指定用于对话的通义千问模型名,如qwen-turbo
input:数据类型为object,输入模型的信息,这里重要是要输入prompt
大概得一个结构是这样的:
{
"model": "qwen-turbo",
"input": {
"prompt": "请输入你的prompt"
}
}
比如我先这样定义了我的prompt
{
"model": "qwen-turbo",
"input": {
"prompt": "以下是5个产品的产品名称Product Nam和对应的评论Comments {{ $json.escapedData }} .请对这5个产品的评论进行分析,分析内容包括:1.大家对该产品的整体评价是好还是坏。2.用户提到了哪些问题。3.用户提到了哪些需求或改进建议。4.请为每个产品给出一个总结性的结论。请用中文输出,并保持结构清晰."
}
}
注:{{ $json.escapedData }}是一个变量,数据是从前面节点中output出来的。 这里注意一定要是字符串的格式,不然整个json格式会有问题并且报错。
执行后大概是这样的一个效果:

这就是AI模型节点的一个配置方法。
然后我们看下其他节点的配置。
首先是prompt里的{{ $json.escapedData }},因为是字符串格式,所以从一开始的GraphQL接口输出的数据,就要在过程中进行一些加工。
接下来分别来讲讲(我这几个节点稍微麻烦了一点,主要过程中的各种调试加多了几个code节点,其实可以再简洁一点,不过没关系,我先按这样来说明逻辑,有时间可以做一些简洁和优化)

1、获取产品信息,合并评论文本
这一步主要是想把每个产品中的评论都合并在一起,为了后面统一丢给AI去分析。
因为GraphQL接口输出的数据,评论字段是如下的结构,每个评论都在一个node对象里。

所以这一步主要想把每个产品里的node的数据都分别合并起来

// 确保从名为 'GraphQL' 的节点获取输出数据
const graphqlOutput = $node['GraphQL'].json.data.posts.edges;
// 遍历产品数组,提取每个产品的评论内容,并生成新的结构
return graphqlOutput.map(edge => {
const product = edge.node; // 访问产品节点
// 检查是否有评论,如果有则提取评论内容
const commentsText = product.comments.edges.map(commentEdge => {
return commentEdge.node.body; // 提取每条评论的文本内容
}).join(" "); // 将所有评论文本合并成一个字符串,使用空格分隔
// 返回一个新的对象,包含产品信息和合并的评论文本
return {
json: {
product, // 完整的产品信息
commentsText // 合并后的评论文本
}
};
});
2、获取产品名称和评论
把产品名称和合并后的评论分别都提取出来。

return items.map(item => {
return {
json: {
productName: item.json.product.name,
commentsText: item.json.commentsText
}
};
});
3、合并产品名称和评论,并去掉特殊字符
这一步把产品名称和评论合并在一起,并且把里面的特殊表情字符都去掉。

const serializedArray = items.map(item => {
const sanitizedComments = item.json.commentsText.replace(/[^a-zA-Z0-9\s.,]/g, '');
return `Product Name: "${item.json.productName}", Comments: "${sanitizedComments}"`;
});
const serializedData = serializedArray.join("; ");
return [
{
serializedData
}
];
4、序列化内容,改为字符串格式
最后是需要把数据的格式改一下,变成字符串,后面给到AI模型节点,在prompt里面就不会出错。

// 获取输入数据
const items = $input.all();
// 创建一个空数组,用于存储处理后的数据
const result = [];
// 遍历每个输入项
items.forEach(item => {
// 提取 serializedData 字段
const serializedData = item.json.serializedData;
// 转义特殊字符并去掉外部的双引号
const escapedData = JSON.stringify(serializedData).slice(1, -1);
// 将处理后的数据添加到结果数组中
result.push({
json: {
escapedData
}
});
});
// 返回处理后的结果
return result;
好了,这些处理完了,就回到我们一开始介绍的http节点来实现AI模型的调用。
调用完成后,我们用code节点把内容变成表格的样式,然后通过gmail发送即可。

修改output格式节点
return items.map(item => {
const product = $node['GraphQL'].json.data.posts.edges.map(edge => edge.node);
// 获取上一个 n8n 节点输出的文本内容
let textContent = $node['AI模型引用'].json.output.text;
// 做一些换行的操作,让文本看着更清晰一点
textContent = textContent
.replace(/#### /g, '<br>#### ')
.replace(/- \*\*/g, '<br>- **');
const tableRows = product.map(prod => {
const comments = prod.comments.edges.map((comment, index) => `${index + 1}. ${comment.node.body}`).join("<br>");
return `<tr>
<td>${prod.name}</td>
<td>${prod.tagline}</td>
<td>${prod.description}</td>
<td>${prod.votesCount}</td>
<td><a href="${prod.website}">${prod.website}</a></td>
<td>${comments}</td>
</tr>`;
}).join("");
// 在表格末尾追加一个合并的text列
const tableHTML = `
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Tagline</th>
<th>Description</th>
<th>Votes Count</th>
<th>Website</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
${tableRows}
<tr>
<td colspan="6">${textContent}</td> <!-- 合并所有单元格的text列 -->
</tr>
</tbody>
</table>
`;
return {
json: {
tableHTML: tableHTML
}
};
});
gmail节点的配置方法我这里就不详细说了,之前这一篇文章有介绍,需要的话可以看这里:Get top5 on Product Hunt | n8n自动化工作流)
那么到此,这个流程就配置完成了。
最后还是提醒一句,记得保存并且把运行开关打开。这样流程才会开始自动化运行。

купить аккаунт перепродажа аккаунтов
купить аккаунт продажа аккаунтов соцсетей
заработок на аккаунтах маркетплейс аккаунтов
купить аккаунт маркетплейс аккаунтов
гарантия при продаже аккаунтов маркетплейс для реселлеров
Website for Buying Accounts Accounts marketplace
Account Trading https://accountsmarketplacepro.com/
Account Store Buy Account
Account Market Purchase Ready-Made Accounts
Guaranteed Accounts Account Selling Service
Account Exchange Service socialaccountsstore.com
Accounts market Sell Pre-made Account
Account Selling Service Account Acquisition
Sell Pre-made Account Accounts for Sale
Account Buying Platform Account market
Account Trading Platform Buy Pre-made Account
marketplace for ready-made accounts gaming account marketplace
accounts for sale secure account sales
accounts for sale guaranteed accounts
account trading secure account purchasing platform
ready-made accounts for sale account trading
account trading platform buy pre-made account
account market account trading platform
buy and sell accounts buy accounts
social media account marketplace ready-made accounts for sale
website for buying accounts account trading service
ready-made accounts for sale account trading platform
account trading platform account market
account trading platform account market
buy and sell accounts gaming account marketplace
accounts marketplace sell account
account market buy pre-made account
purchase ready-made accounts profitable account sales
website for selling accounts guaranteed accounts
account selling service account sale
website for selling accounts account selling service
account trading sell accounts
account acquisition account trading service
ready-made accounts for sale accounts for sale
secure account purchasing platform buy accounts
account buying platform account selling platform
sell account shop-social-accounts.org
guaranteed accounts guaranteed accounts
account trading platform accounts for sale
account selling platform https://accounts-offer.org/
buy account https://accounts-marketplace.xyz/
sell pre-made account https://buy-best-accounts.org/
marketplace for ready-made accounts https://social-accounts-marketplaces.live/
account trading service https://accounts-marketplace.live
account market social-accounts-marketplace.xyz
account market account marketplace