Ahrefs关键词研究工作流
中级
这是一个AI, Marketing领域的自动化工作流,包含 14 个节点。主要使用 Code, Aggregate, HttpRequest, Agent, ChatTrigger 等节点,结合人工智能技术实现智能自动化。 使用Ahrefs API和Gemini 1.5 Flash执行SEO关键词研究与洞察
前置要求
- •可能需要目标 API 的认证凭证
- •Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "OO4izN00xPfIPGaB",
"meta": {
"instanceId": "b3c467df4053d13fe31cc98f3c66fa1d16300ba750506bfd019a0913cec71ea3",
"templateCredsSetupCompleted": true
},
"name": "Ahrefs 关键词研究工作流",
"tags": [],
"nodes": [
{
"id": "4e420798-7523-4d47-af27-10f85d09f01d",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-300,
-60
],
"webhookId": "f40acbbc-ac03-43d1-9341-6c9e8c674293",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "0f71c28e-a11b-4aed-a342-e15d2714ab47",
"name": "Google Gemini 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
-160,
140
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-flash"
},
"credentials": {
"googlePalmApi": {
"id": "zT4YaNflEp2E6S3m",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "9b24fc9d-ac8d-4a9b-a7a5-00d1665f47af",
"name": "Google Gemini 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
980,
160
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-flash"
},
"credentials": {
"googlePalmApi": {
"id": "zT4YaNflEp2E6S3m",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "d0cbe978-040d-4663-895e-85844e203773",
"name": "关键词数据响应格式化器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
980,
-60
],
"parameters": {
"text": "Provide reponse according to the system message. ",
"options": {
"systemMessage": "=system_message:\n description: |\n Your role is to format and output the keyword data into a clean, readable text format. The input data consists of two main parts: **Main Keyword Data** and **Related Keywords Data**. Your task is to process and output this data in a way that is easy to read for the user. Each keyword and its associated details should be displayed clearly.\n\n Data:\n - **Main Keyword Data✨**:\n - **Keyword**: \"{{ $json.data[0].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[0].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[0].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[0].competition_value }}\"\n - **High CPC**: \"{{ $json.data[0].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[0].low_cpc }}\"\n\n - **Related Keywords🧰**:\n \n \n - **1. Keyword**: \"{{ $json.data[1].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[1].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[1].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[1].competition_value }}\"\n - **High CPC**: \"{{ $json.data[1].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[1].low_cpc }}\"\n \n - **2. Keyword**: \"{{ $json.data[2].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[2].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[2].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[2].competition_value }}\"\n - **High CPC**: \"{{ $json.data[2].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[2].low_cpc }}\"\n \n - **3. Keyword**: \"{{ $json.data[3].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[3].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[3].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[3].competition_value }}\"\n - **High CPC**: \"{{ $json.data[3].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[3].low_cpc }}\"\n \n - **4. Keyword**: \"{{ $json.data[4].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[4].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[4].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[4].competition_value }}\"\n - **High CPC**: \"{{ $json.data[4].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[4].low_cpc }}\"\n \n - **5. Keyword**: \"{{ $json.data[5].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[5].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[5].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[5].competition_value }}\"\n - **High CPC**: \"{{ $json.data[5].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[5].low_cpc }}\"\n \n - **6. Keyword**: \"{{ $json.data[6].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[6].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[6].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[6].competition_value }}\"\n - **High CPC**: \"{{ $json.data[6].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[6].low_cpc }}\"\n \n - **7. Keyword**: \"{{ $json.data[7].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[7].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[7].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[7].competition_value }}\"\n - **High CPC**: \"{{ $json.data[7].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[7].low_cpc }}\"\n \n - **8. Keyword**: \"{{ $json.data[8].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[8].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[8].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[8].competition_value }}\"\n - **High CPC**: \"{{ $json.data[8].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[8].low_cpc }}\"\n \n - **9. Keyword**: \"{{ $json.data[9].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[9].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[9].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[9].competition_value }}\"\n - **High CPC**: \"{{ $json.data[9].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[9].low_cpc }}\"\n\n - **10. Keyword**: \"{{ $json.data[10].keyword }}\"\n - **Average Monthly Searches**: \"{{ $json.data[10].avg_monthly_searches }}\"\n - **Competition Index**: \"{{ $json.data[10].competition_index }}\"\n - **Competition Value**: \"{{ $json.data[10].competition_value }}\"\n - **High CPC**: \"{{ $json.data[10].high_cpc }}\"\n - **Low CPC**: \"{{ $json.data[10].low_cpc }}\"\n"
},
"promptType": "define"
},
"typeVersion": 1.8
},
{
"id": "9cb26cde-dbff-4118-a141-ebd1fd7df1b1",
"name": "关键词查询提取与清理代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-80,
-60
],
"parameters": {
"options": {
"systemMessage": "You are a helpful assistant. You job is to check the user message and pick out the SEO keyword they have provided and output it. Make sure you output just one SEO keyword. No commentary. Do not rephrase, just correct grammar if it has been misspelt."
}
},
"typeVersion": 1.8
},
{
"id": "6a59bf1f-68a3-433c-9cf7-47cadc1a77eb",
"name": "提取主关键词和 10 个相关关键词数据",
"type": "n8n-nodes-base.code",
"position": [
540,
-60
],
"parameters": {
"jsCode": "// Get the main keyword data (Global Keyword Data)\nconst mainKeywordData = $input.first().json['Global Keyword Data']?.[0] || {};\n\n// Get the related keywords array\nconst relatedKeywords = $input.first().json['Related Keyword Data (Global)'] || [];\n\n// Create an output array that includes the main keyword data first\nconst output = [\n {\n keyword: mainKeywordData.keyword || 'N/A',\n avg_monthly_searches: mainKeywordData.avg_monthly_searches || 'N/A',\n competition_index: mainKeywordData.competition_index || 'N/A',\n competition_value: mainKeywordData.competition_value || 'N/A',\n high_cpc: mainKeywordData['High CPC'] || 'N/A',\n low_cpc: mainKeywordData['Low CPC'] || 'N/A'\n },\n // Map up to 10 related keywords with selected fields\n ...relatedKeywords.slice(0, 10).map(item => ({\n keyword: item.keyword,\n avg_monthly_searches: item.avg_monthly_searches,\n competition_index: item.competition_index,\n competition_value: item.competition_value,\n high_cpc: item['High CPC'],\n low_cpc: item['Low CPC']\n }))\n];\n\nreturn output;\n"
},
"typeVersion": 2
},
{
"id": "a2b1b9ff-a425-4c99-bd36-a4bb0e0cd84e",
"name": "聚合关键词数据",
"type": "n8n-nodes-base.aggregate",
"position": [
800,
-60
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "36d4c962-71f2-473a-841c-053c6c36bcda",
"name": "Ahrefs 关键词 API 请求",
"type": "n8n-nodes-base.httpRequest",
"maxTries": 2,
"position": [
280,
-60
],
"parameters": {
"url": "https://ahrefs-keyword-tool.p.rapidapi.com/global-volume",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"queryParameters": {
"parameters": [
{
"name": "keyword",
"value": "={{ $json.output }}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "x-rapidapi-host",
"value": "ahrefs-keyword-tool.p.rapidapi.com"
},
{
"name": "x-rapidapi-key",
"value": "\"your_rapid_api_key_here\""
}
]
}
},
"retryOnFail": true,
"typeVersion": 4.2
},
{
"id": "47898c8e-37e7-4abc-beb2-64fc546a7c03",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-260
],
"parameters": {
"color": 6,
"width": 260,
"content": "## 关键词查询提取"
},
"typeVersion": 1
},
{
"id": "c83f2813-d57c-48d6-8c66-6a057ca9cfc9",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
280,
-260
],
"parameters": {
"color": 4,
"content": "## API 请求"
},
"typeVersion": 1
},
{
"id": "98ad64ea-d023-49c0-ab05-21bd87c322b9",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
600,
-260
],
"parameters": {
"content": "## 提取关键词数据"
},
"typeVersion": 1
},
{
"id": "1f1d15f3-36f7-4bad-be63-ce74c70580f1",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
-260
],
"parameters": {
"width": 260,
"content": "## 触发器节点"
},
"typeVersion": 1
},
{
"id": "a5e0b305-ebc7-44e2-ada2-8d5cf60a1fe2",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
980,
-260
],
"parameters": {
"content": "## 响应格式化器"
},
"typeVersion": 1
},
{
"id": "00ce5fc5-aff8-4cde-871e-ffea5aa5ffb3",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
40,
140
],
"parameters": {},
"typeVersion": 1.3
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "e2857a0c-4473-4d3d-9c63-6b02337bccf0",
"connections": {
"Simple Memory": {
"ai_memory": [
[]
]
},
"Aggregate Keyword Data": {
"main": [
[
{
"node": "Keyword Data Response Formatter",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Keyword Query Extraction & Cleaning Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Google Gemini Chat Model1": {
"ai_languageModel": [
[
{
"node": "Keyword Data Response Formatter",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Ahrefs Keyword API Request": {
"main": [
[
{
"node": "Extract Main Keyword & 10 related Keyword data",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Keyword Query Extraction & Cleaning Agent",
"type": "main",
"index": 0
}
]
]
},
"Keyword Query Extraction & Cleaning Agent": {
"main": [
[
{
"node": "Ahrefs Keyword API Request",
"type": "main",
"index": 0
}
]
]
},
"Extract Main Keyword & 10 related Keyword data": {
"main": [
[
{
"node": "Aggregate Keyword Data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 人工智能, 营销
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
音乐生成工作流
使用 Suno API、Flux、Runway 和 Creatomate 生成 AI 歌曲和音乐视频
Set
Wait
Merge
+16
60 节点Joseph
其他
YouTube短视频生成器
使用Flux、Runway、Eleven Labs和Creatomate生成AI YouTube短视频
Set
Code
Wait
+11
32 节点Joseph
人工智能
⚡📽️ 终极AI驱动的YouTube摘要与分析聊天机器人
⚡📽️ 用于YouTube摘要与分析的全能AI聊天机器人
Set
Code
Merge
+11
29 节点Joseph LePage
人工智能
测验短视频生成器
使用Sonnet 3.5、Pinecone和Creatomate生成谜语短视频并发布到YouTube
If
Code
Wait
+13
32 节点Joseph
其他
新闻通讯管理 (n8n + Bolt.new)
职位通讯自动化系统 (N8N, Bolt.new, RapidAPI, Mails.so & ChatGPT)
If
Code
Gmail
+12
43 节点Joseph
人工智能
完成YouTube
基于细分领域的AI YouTube趋势发现器
If
Set
Code
+10
18 节点Leonardo Grigorio
人工智能
工作流信息
难度等级
中级
节点数量14
分类2
节点类型8
作者
Joseph
@mjombaAutomation expert specializing in building smart, scalable workflows using tools like n8n, Make, and Airtable. I help businesses save time, reduce manual work, and grow faster with tailored automation solutions. Feel free to reach out at joseph@uppfy.com to discuss your project.
外部链接
在 n8n.io 查看 →
分享此工作流