8
n8n 中文网amn8n.com

Spotify情感转新闻卡片生成器(APITemplate.io + Slack)

高级

这是一个Content Creation, AI Summarization领域的自动化工作流,包含 21 个节点。主要使用 Set, Code, Slack, Spotify, RssFeedRead 等节点。 使用LLM、谷歌新闻和APITemplate.io从Spotify情感生成新闻卡片

前置要求
  • Slack Bot Token 或 Webhook URL
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "OMGFOlTIKsAAAwUG",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
    "templateCredsSetupCompleted": true
  },
  "name": "Spotify情感转新闻卡片生成器(APITemplate.io + Slack)",
  "tags": [],
  "nodes": [
    {
      "id": "773130e9-c130-4276-b4f5-6fa0cd79ba91",
      "name": "情感分析器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        304,
        -16
      ],
      "parameters": {
        "text": "=You are an emotion analyst.\nGiven the following song title and artist, infer the main emotion it conveys \n(e.g., joyful, nostalgic, melancholic, energetic, angry, romantic).\nReturn JSON.\n\nInput:\n\"{{ $json.track.name }} - {{ $json.track.album.artists[0].name }}\"\n\nOutput:\n{\n  \"emotion\": \"nostalgic\",\n  \"reason\": \"The song's tone and lyrics evoke reflection and memory.\"\n}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "734a0e4f-1a01-4bfd-8877-4629ef89d1a4",
      "name": "按计划启动(Cron)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -144,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3c9cf5ff-747e-436c-b47d-8d55b2fdde40",
      "name": "获取Spotify最近播放",
      "type": "n8n-nodes-base.spotify",
      "position": [
        80,
        -16
      ],
      "parameters": {
        "operation": "recentlyPlayed"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "NBaU7bOuJl4YNkeB",
          "name": "Spotify account 3"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e051c66b-fdfb-4ef7-860a-9a14c9c29f9e",
      "name": "LLM:从曲目推断情感",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        384,
        208
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "fMR5QJezr3tD108w",
          "name": "簡易デモ"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ee6e19e5-8843-4669-87e6-432d0c944db7",
      "name": "对于每个曲目(批量)",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        656,
        -16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "282fbf38-97c2-4510-bed4-08072dea9f71",
      "name": "构建Google新闻RSS查询",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -16
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{\n  (() => {\n    const raw =\n      $json.emotion ||\n      (JSON.parse($json.output || '{}').emotion) ||\n      'music';\n    const clean = String(raw).replace(/\\s+/g,' ').replace(/\\u3000/g,' ').trim();\n    const base = 'https://news.google.com/rss/search?hl=en-US&gl=US&ceid=US%3Aen&q=';\n    return { feedUrl: base + encodeURIComponent(clean) }; // ← オブジェクトで返す\n  })()\n}}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "1636d83b-5ff3-4360-b70c-c469691e7d15",
      "name": "获取Google新闻RSS",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        1104,
        -16
      ],
      "parameters": {
        "url": "={{\n  (() => {\n    const emotionRaw =\n      $json.emotion ||\n      (JSON.parse($json.output || '{}').emotion) ||\n      'music';\n\n    const q = encodeURIComponent(String(emotionRaw).trim());\n    const url = `https://news.google.com/rss/search?hl=en-US&gl=US&ceid=US%3Aen&q=${q}`;\n    return url.trim();\n  })()\n}}\n",
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "89aab605-b6bb-4206-8866-c6bb97f269e5",
      "name": "选择顶部新闻并格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        -16
      ],
      "parameters": {
        "jsCode": "return items.slice(0, 1);"
      },
      "typeVersion": 2
    },
    {
      "id": "20707f6c-fbec-45a8-94e0-a42574e9c90e",
      "name": "生成新闻卡片(APITemplate)",
      "type": "n8n-nodes-base.apiTemplateIo",
      "position": [
        1552,
        -16
      ],
      "parameters": {
        "overridesJson": "={{ JSON.stringify([\n  { \"name\": \"text_emotion\", \"text\": $json.emotion ?? \"neutral\" },\n  { \"name\": \"text_url\",     \"text\": $json.link ?? \"https://example.com\" },\n  { \"name\": \"text_1\",       \"text\": $json.contentSnippet ?? \"Unknown source\" },\n  { \"name\": \"text_2\",       \"text\": $json.title ?? \"No title\" }\n]) }}\n",
        "jsonParameters": true,
        "imageTemplateId": "="
      },
      "credentials": {
        "apiTemplateIoApi": {
          "id": "whAPW33pjYrGW6Cb",
          "name": "APITemplate.io account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "abed781e-894c-4239-8f89-34532fe17022",
      "name": "发布到Slack(标题 + 链接 + 卡片URL)",
      "type": "n8n-nodes-base.slack",
      "position": [
        1776,
        -16
      ],
      "webhookId": "b33a2d51-5fd8-460f-8ea8-0fabfdcf359b",
      "parameters": {
        "text": "={{\n  $(\"Pick Top News & Format\").item.json.title + \"\\n\" +\n  $(\"Pick Top News & Format\").item.json.link + \"\\n\" +\n  \"📰 ニュースカード\\n\" +\n  ( $(\"Generate News Card (APITemplate)\").item.json.download_url_png || $(\"Generate News Card (APITemplate)\").item.json.download_url )\n}}\n",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "CKUCBTG0H",
          "cachedResultName": "general"
        },
        "otherOptions": {
          "unfurl_links": false,
          "unfurl_media": false
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "2kyw7TSL5VT4S3md",
          "name": "Slack account 8"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "259a3bb9-d297-442c-b998-ea7aed02d1d1",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -352
      ],
      "parameters": {
        "width": 416,
        "height": 1344,
        "content": "## 📄 工作流概述"
      },
      "typeVersion": 1
    },
    {
      "id": "930501ea-23fc-4014-b2e1-8547d609680e",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -240
      ],
      "parameters": {
        "color": 7,
        "content": "## 按计划启动(Cron)"
      },
      "typeVersion": 1
    },
    {
      "id": "4b84f0fc-1f3f-4ebf-934e-3092759aae9f",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        192
      ],
      "parameters": {
        "color": 7,
        "height": 176,
        "content": "## 获取Spotify最近播放"
      },
      "typeVersion": 1
    },
    {
      "id": "8fe180e8-594c-470b-9b1d-fa754582ae19",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -208
      ],
      "parameters": {
        "color": 7,
        "height": 128,
        "content": "## 情感分析器"
      },
      "typeVersion": 1
    },
    {
      "id": "7017bd67-3219-492c-9334-16883310c843",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        160
      ],
      "parameters": {
        "color": 7,
        "height": 176,
        "content": "## 对于每个曲目(批量)"
      },
      "typeVersion": 1
    },
    {
      "id": "c0ad00c2-c320-41c2-ad1e-982c192fc81c",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        -256
      ],
      "parameters": {
        "color": 7,
        "height": 176,
        "content": "## 构建Google新闻RSS查询"
      },
      "typeVersion": 1
    },
    {
      "id": "ab9563f1-d47a-49fc-ba02-149b251e8a0e",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        160
      ],
      "parameters": {
        "color": 7,
        "content": "## 获取Google新闻RSS"
      },
      "typeVersion": 1
    },
    {
      "id": "1d92ea4b-bba2-4be9-8401-1174cbefef9a",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -240
      ],
      "parameters": {
        "color": 7,
        "content": "## 选择顶部新闻并格式化"
      },
      "typeVersion": 1
    },
    {
      "id": "afe292e6-24aa-42c8-9de5-e1d78b7acf30",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        176
      ],
      "parameters": {
        "color": 7,
        "height": 208,
        "content": "## 生成新闻卡片(APITemplate)"
      },
      "typeVersion": 1
    },
    {
      "id": "9914e9fa-6135-40ce-abf3-053a3c798c03",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        -208
      ],
      "parameters": {
        "color": 7,
        "content": "## 发布到Slack(标题 + 链接 + 卡片URL)"
      },
      "typeVersion": 1
    },
    {
      "id": "842092ca-795b-4330-b1c8-b83b6c8652e8",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 752,
        "content": "## 设置(逐步指南)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b0b1e713-4148-491c-ba26-71d4520280bf",
  "connections": {
    "Emotion Analyzer": {
      "main": [
        [
          {
            "node": "For Each Track (Batch)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Google News RSS": {
      "main": [
        [
          {
            "node": "Pick Top News & Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "For Each Track (Batch)": {
      "main": [
        [],
        [
          {
            "node": "Build Google News RSS Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick Top News & Format": {
      "main": [
        [
          {
            "node": "Generate News Card (APITemplate)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start on Schedule (Cron)": {
      "main": [
        [
          {
            "node": "Fetch Spotify Recently Played",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Google News RSS Query": {
      "main": [
        [
          {
            "node": "Fetch Google News RSS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Spotify Recently Played": {
      "main": [
        [
          {
            "node": "Emotion Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LLM: Infer Emotion from Track": {
      "ai_languageModel": [
        [
          {
            "node": "Emotion Analyzer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate News Card (APITemplate)": {
      "main": [
        [
          {
            "node": "Post to Slack (Title + Link + Card URL)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Slack (Title + Link + Card URL)": {
      "main": [
        []
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, AI 摘要总结

需要付费吗?

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

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

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流