8
n8n 中文网amn8n.com

Strava社交管理器(AI标题与描述生成)

中级

这是一个Other, AI领域的自动化工作流,包含 13 个节点。主要使用 Set, Code, Strava, StravaTrigger, Agent 等节点,结合人工智能技术实现智能自动化。 使用DeepSeek AI生成个性化Strava骑行标题和描述

前置要求
  • AI 服务 API Key(如 OpenAI、Anthropic 等)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "SoJXbESQ4lWQWcVt",
  "meta": {
    "instanceId": "89af474e60c70a1e45bf242e266e9ca1446dd974ab86f6d185b8ccded3effed2",
    "templateCredsSetupCompleted": true
  },
  "name": "Strava社交管理器(AI标题与描述生成)",
  "tags": [
    {
      "id": "NabIyPgRf7ZggE5B",
      "name": "Showcase",
      "createdAt": "2025-06-03T15:41:30.076Z",
      "updatedAt": "2025-06-03T15:41:30.076Z"
    }
  ],
  "nodes": [
    {
      "id": "58ef8481-49d7-4522-9797-f191db60fa33",
      "name": "合并所有内容",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        340
      ],
      "parameters": {
        "jsCode": "// Recursive function to flatten JSON into a single string\nfunction flattenJson(obj, prefix = '') {\n    let str = '';\n    for (const key in obj) {\n        if (typeof obj[key] === 'object' && obj[key] !== null) {\n            str += flattenJson(obj[key], `${prefix}${key}.`);\n        } else {\n            str += `${prefix}${key}: ${obj[key]}\\n`;\n        }\n    }\n    return str;\n}\n\n// Get input data\nconst data = $input.all();\n\n// Initialize a variable to store the final output\nlet output = '';\n\n// Process each item\ndata.forEach(item => {\n    output += flattenJson(item.json);\n    output += '\\n---\\n'; // Separator between records\n});\n\n// Return the merged string as output\nreturn [{ json: { data: output } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d81a3699-09c6-4114-ad6e-652ce34854e8",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        -300,
        340
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "ee87a5ae-331f-4066-84e8-43acdfaaf038",
      "name": "OpenRouter聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        160,
        520
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "3wCQ4jmvYFl3hV0y",
          "name": "OpenRouter account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7690c43e-282c-4fc6-af91-ba468040fdba",
      "name": "Strava触发器",
      "type": "n8n-nodes-base.stravaTrigger",
      "position": [
        -520,
        340
      ],
      "webhookId": "d5e76c3e-5828-45f6-ae2a-ab70d8bfa93f",
      "parameters": {
        "event": "create",
        "object": "activity",
        "options": {}
      },
      "credentials": {
        "stravaOAuth2Api": {
          "id": "Em3MTnOr8JDr8Wnk",
          "name": "Strava account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b0dbf6f6-d3c9-43e3-997a-3593229e891e",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        520,
        340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fe37d921-5f51-4809-8fa9-e93b0983a566",
              "name": "Name",
              "type": "string",
              "value": "={{ $json.output.split('\\n')[0].split(': ')[1] }}"
            },
            {
              "id": "528a732c-7b96-47c1-8c8e-4354258569d9",
              "name": "Description",
              "type": "string",
              "value": "={{ $json.output.split('\\n')[1].split(': ')[1] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "38316beb-1f92-43e5-ac48-ac982be6407f",
      "name": "Strava",
      "type": "n8n-nodes-base.strava",
      "position": [
        740,
        340
      ],
      "parameters": {
        "operation": "update",
        "activityId": "={{ $('Strava Trigger').item.json.object_id }}",
        "updateFields": {
          "name": "={{ $json.Name }}",
          "description": "={{ $json.Description }}"
        }
      },
      "credentials": {
        "stravaOAuth2Api": {
          "id": "Em3MTnOr8JDr8Wnk",
          "name": "Strava account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4be1f7de-7f50-45fb-8aa0-4707d25a23fb",
      "name": "Strava社交管理器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        140,
        340
      ],
      "parameters": {
        "text": "=Tu es un assistant virtuel passionné de cyclisme.  \nÀ partir des informations ci-dessous sur ma sortie vélo, génère :\n- Un **titre accrocheur** (max 10 mots), original et adapté au contexte de la sortie.\n- Une **description** motivante, détaillée et personnalisée (3 à 5 phrases), qui met en valeur les aspects marquants de la sortie (lieux traversés, météo, performance, sensations, anecdotes, etc.).  \n\nUtilise un ton positif, dynamique et inspirant, comme si tu écrivais pour un carnet d’aventure cycliste.  \n\n**Données de la sortie :**\n- Distance : [X] km\n- Durée : [X] h [X] min\n- Dénivelé : [X] m\n- Vitesse moyenne : [X] km/h\n- Lieu/départ : [Ville/lieu]\n- Météo : [ensoleillé, pluvieux, vent, etc.]\n- Ressenti : [facile, difficile, super sensations, etc.]\n- Particularités : [découverte d’un nouveau parcours, sortie en groupe, crevaison, etc.]\n\n**Format attendu :**\n```\nTitre : [Titre généré]\nDescription : [Description générée]\n```\n\n---\n\nVoici les données de l'activité : \n{{ $json.data }}",
        "agent": "conversationalAgent",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "f2941949-f743-4214-88a6-37899770e4df",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 680,
        "content": "### **步骤0 – 连接Strava API**"
      },
      "typeVersion": 1
    },
    {
      "id": "885370b1-7f2f-4411-b35e-3090dcbec2b8",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        0
      ],
      "parameters": {
        "width": 220,
        "height": 680,
        "content": "### **步骤1 – Strava触发器**"
      },
      "typeVersion": 1
    },
    {
      "id": "28121d2d-ddd0-422b-b56d-099a32708216",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        0
      ],
      "parameters": {
        "width": 420,
        "height": 680,
        "content": "### **步骤2a – 数据处理(代码)**"
      },
      "typeVersion": 1
    },
    {
      "id": "fb1139ae-b154-49fa-a2f0-dd9e1d440f17",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        0
      ],
      "parameters": {
        "width": 340,
        "height": 680,
        "content": "### **步骤3 – AI生成标题和描述(Strava社交管理器)**"
      },
      "typeVersion": 1
    },
    {
      "id": "c2897c26-5e64-44a4-8201-12f25f3a8e13",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        0
      ],
      "parameters": {
        "height": 680,
        "content": "### **步骤4 – 提取AI结果(编辑字段)**"
      },
      "typeVersion": 1
    },
    {
      "id": "88418116-adc3-4438-8fa5-0fbfd399495b",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        0
      ],
      "parameters": {
        "height": 680,
        "content": "### **步骤5 – 自动更新Strava上的活动**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "faf93495-ffbf-40f8-8dfe-89be52af5ba1",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Combine Everything",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Strava",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Strava Trigger": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Everything": {
      "main": [
        [
          {
            "node": "Strava Social Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Strava Social Manager",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Strava Social Manager": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 其他, 人工智能

需要付费吗?

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

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

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

作者
Thibaud

Thibaud

@tderouze

Automation consultant with over 10 years experience helping Sales & Marketing teams to streamline their processes.

外部链接
在 n8n.io 查看

分享此工作流