8
n8n 中文网amn8n.com

使用OpenRouter AI和Google Sheets分析浏览历史并生成自动化建议

中级

这是一个Personal Productivity, AI Summarization领域的自动化工作流,包含 12 个节点。主要使用 Code, Filter, GoogleSheets, ManualTrigger, SplitInBatches 等节点。 使用OpenRouter AI和Google Sheets分析浏览历史并生成自动化建议

前置要求
  • Google Sheets API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "9e2be6ba5ff8dd7a908d0b8006c046764e7b3f15c79d121bf914d51a0b406e85",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0b829d80-6090-460d-bc0e-5d0ff925251b",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -380,
        -20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b2114f33-6fab-4e0b-9c03-63b54faf166f",
      "name": "获取表格中的行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -160,
        -20
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1592379591,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc/edit#gid=1592379591",
          "cachedResultName": "history"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc/edit?usp=drivesdk",
          "cachedResultName": "Untitled spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "c7TYv7ZcF6y7LGEQ",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a81bbc84-5d25-42fa-b8d5-0ef4d97517b2",
      "name": "移除不需要的域名",
      "type": "n8n-nodes-base.filter",
      "position": [
        280,
        -20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5d9d468c-cdc3-40c8-94ac-05260397ff1e",
              "operator": {
                "type": "string",
                "operation": "notRegex"
              },
              "leftValue": "={{ $json.group[0].domain }}",
              "rightValue": "=/(?:youtube\\.com|google\\.(com|[a-z]{2})|chatgpt\\.com|openai\\.com|chromewebstore.google.com)/i"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "323337f3-3aec-4b25-9777-e50ce77d088f",
      "name": "按域名分组历史记录",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        -20
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst grouped = {};\n\n// Group items by domain\nfor (const item of items) {\n  const url = item.json.url;\n  const domain = url.split(\"/\")[2]; // Extract domain\n  item.json.domain = domain;\n\n  if (!grouped[domain]) {\n    grouped[domain] = [];\n  }\n\n  grouped[domain].push(item.json); // Store just the data part\n}\n\n// Convert grouped object to n8n-friendly format\nconst result = [];\n\nfor (const group of Object.values(grouped)) {\n  result.push({\n   \n      group: group, // Now `group` is the array under an object\n    \n  });\n}\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "dfa4698f-ced5-48ff-89db-c8f15705aeda",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1000,
        0
      ],
      "parameters": {
        "text": "=Here is a grouped browsing history from one domain. Analyze whether it's automatable and why.\n\nHistory:{{ $json.prompt }}\n\n\nPlease analyze and tell me:\n- Is this automatable?\n- What should be automated?\n- What is the automation rating?\n-save result on google sheet",
        "options": {
          "systemMessage": "You are an expert automation analyst AI that uses tools to analyze web browsing history and determine if tasks can be automated.\n\nYou have access to tools such as:\n- Google Sheets (to save recommendations)\n- Web automation platforms (e.g., browser scripts, Apify, Puppeteer, n8n)\n- APIs and schedulers (to trigger tasks periodically)\n-search n8n templates\n\nYour responsibilities:\n1. Analyze the user's browsing history grouped by domain.\n2. Identify repetitive, frequent, or structured browsing behavior.\n3. Determine whether automation is possible.\n4. If yes, describe the specific action(s) to automate using available tools.\n5. Record your output in a structured format for use with Google Sheets.\n\nUse your tools wisely:\n- Save automation suggestions into a structured row (domain, automatable, what to automate, reason, automation rating).\n- Suggest appropriate tools (e.g., \"Use Apify to scrape dashboard\", \"Use n8n to schedule login\").\n\nOutput format:\n```json\n{\n  \"domain\": \"<example.com>\",\n  \"automatable\": true,\n  \"what_to_automate\": \"<Brief, tool-aware suggestion>\",\n  \"reason\": \"<Why it's suitable or not>\",\n  \"tool\": \"<Suggested tool: n8n, Apify, Google Apps Script, etc.>\",\n  \"automation_rating\": \"High\" // Or Medium, Low, Not Automatable,\nn8n_template:templates urls\n}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "01bc75db-8254-4165-96f5-06a0c4bd682f",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        500,
        -20
      ],
      "parameters": {
        "options": {},
        "batchSize": "={{ $input.all().length }}"
      },
      "typeVersion": 3
    },
    {
      "id": "b9d674fe-6c2e-4359-a415-98233caaa342",
      "name": "OpenRouter聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1000,
        340
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "tC9q2VizRVbSvlww",
          "name": "OpenRouter account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8833b3b4-36c6-4ab9-a72a-5955b7d4427d",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        760,
        0
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nreturn {\n  prompt:JSON.stringify($json)}"
      },
      "typeVersion": 2
    },
    {
      "id": "1ea2312d-5b13-4d7c-971c-81ac6598f1de",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1280,
        240
      ],
      "parameters": {
        "sessionKey": "={{ $('Loop Over Items').item.json.group[0].domain }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "ca69ff37-653a-4d40-b030-3439735e9289",
      "name": "在Google Sheets中附加行",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1160,
        480
      ],
      "parameters": {
        "columns": {
          "value": {
            "domain": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('domain__using_to_match_', ``, 'string') }}",
            "reason": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('reason', ``, 'string') }}",
            "automatable": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('automatable', ``, 'string') }}",
            "n8n_template": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('n8n_template', ``, 'string') }}",
            "what_to_automate": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('what_to_automate', ``, 'string') }}",
            "automation_rating": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('automation_rating', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "domain",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "automatable",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "automatable",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "what_to_automate",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "what_to_automate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "automation_rating",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "automation_rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "n8n_template",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "n8n_template",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "domain"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1970061780,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc/edit#gid=1970061780",
          "cachedResultName": "automations"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V26KDJLBZno6e_VxaBqhsK_JOOOn_5N6uww2apcAeoc/edit?usp=drivesdk",
          "cachedResultName": "history"
        },
        "descriptionType": "manual",
        "toolDescription": "use this to save analyse result to google sheet "
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "c7TYv7ZcF6y7LGEQ",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "0e2fceb0-4498-4ee3-8a72-0611d7ba5afd",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1300,
        440
      ],
      "parameters": {
        "url": "https://n8n.io/workflows/?sort=views:desc",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "get n8n template list from search page"
      },
      "typeVersion": 4.2
    },
    {
      "id": "93f68db2-7ba5-4ade-941d-d5309a70fb78",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        180
      ],
      "parameters": {
        "width": 740,
        "height": 2440,
        "content": "# 🧠 浏览历史自动化分析器 – 自动化工具包(Google Sheets + AI)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "groupe history by domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "remove unwanted domains": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "groupe history by domain": {
      "main": [
        [
          {
            "node": "remove unwanted domains",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 个人效率, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量12
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Msaid Mohamed el hadi

Msaid Mohamed el hadi

@mohamedgb00714

Hi! I’m Mohamed El Hadi, a passionate developer and automation expert from Algeria. I specialize in building smart, scalable workflows using n8n to streamline business operations, save time, and drive innovation. 🌍 Open to collaborations | 🤖 Automation lover | 💼 Founder of EcoPetDZ & AADL Auto Reload

外部链接
在 n8n.io 查看

分享此工作流