8
n8n 中文网amn8n.com

使用GPT和TTS通过WhatsApp将网站转换为音频摘要

高级

这是一个Personal Productivity, AI Summarization领域的自动化工作流,包含 23 个节点。主要使用 If, Set, Code, Html, Merge 等节点。 使用GPT和TTS通过WhatsApp将网站转换为音频摘要

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "42bde649da4575cc0d49afcf8affcdbece40e5e40061aa2c9b7a8b3639284dfe",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "3ac9465d-b69c-422e-a538-dbf9abbc7642",
      "name": "从消息中提取 URL",
      "type": "n8n-nodes-base.code",
      "position": [
        -576,
        240
      ],
      "parameters": {
        "jsCode": "// Extract URL from WhatsApp message\nconst item = $input.item.json;\n\n// Check if this is a message (not a status update)\nif (!item.messages || !Array.isArray(item.messages) || item.messages.length === 0) {\n  // This is a status update or empty, skip processing\n  return null;\n}\n\nconst message = item.messages[0];\nconst messageText = message.text?.body || '';\nconst from = message.from;\n\n// Simple URL extraction\nconst urlRegex = /(https?:\\/\\/[^\\s]+)/gi;\nconst urls = messageText.match(urlRegex);\n\nif (!urls || urls.length === 0) {\n  // No URL found, return error message\n  return {\n    error: true,\n    from: from,\n    message: \"⚠️ Please send a valid URL to summarize. Example: https://example.com\"\n  };\n}\n\nreturn {\n  URL: urls[0],\n  from: from,\n  original_message: messageText,\n  error: false\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "2da6a2a7-6bd3-4681-909a-d39fb1244d4b",
      "name": "检查是否为有效 URL",
      "type": "n8n-nodes-base.if",
      "position": [
        -432,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-url",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "660545af-20f0-467b-851b-d210c82ac48f",
      "name": "发送错误消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -208,
        416
      ],
      "webhookId": "9dfc84ae-12e0-4f63-8820-4ec2dc4db02f",
      "parameters": {
        "textBody": "={{ $json.message }}",
        "operation": "send",
        "phoneNumberId": "={{ $('WhatsApp Trigger').item.json.metadata.phone_number_id }}",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $json.from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Lf4s3r55bG6RFGLw",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "a5a5d844-ff22-48df-8c3d-11e897aa1408",
      "name": "发送处理中消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -208,
        224
      ],
      "webhookId": "8a404dac-179c-4e06-bd47-fbb214730f06",
      "parameters": {
        "textBody": "🔍 Fetching and analyzing webpage...\nThis may take 10-30 seconds.",
        "operation": "send",
        "phoneNumberId": "={{ $('WhatsApp Trigger').item.json.metadata.phone_number_id }}",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $json.from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Lf4s3r55bG6RFGLw",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "68da6673-0e21-4a6f-b631-167748249777",
      "name": "获取网页摘要",
      "type": "n8n-nodes-base.executeWorkflow",
      "notes": "This calls your existing '[SUB] Get Webpage Summary' workflow",
      "position": [
        112,
        224
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "QglZjvjdZ16BisPN",
          "cachedResultUrl": "/workflow/QglZjvjdZ16BisPN",
          "cachedResultName": "[SUB] Get Webpage Summary"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b505c2b7-368b-4577-b7c8-7d1bdfba73a2",
      "name": "将摘要转换为音频",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        288,
        224
      ],
      "parameters": {
        "input": "={{ $json.summary }}",
        "options": {
          "speed": 1,
          "response_format": "opus"
        },
        "resource": "audio"
      },
      "credentials": {
        "openAiApi": {
          "id": "mDGcGh1b3ALbNE4K",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "8c75eb4b-c9b2-48a4-9e49-d71195110915",
      "name": "发送音频摘要",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        448,
        224
      ],
      "webhookId": "cb67c7fb-dd7e-423f-893c-f26266cde026",
      "parameters": {
        "mediaPath": "useMedian8n",
        "operation": "send",
        "messageType": "audio",
        "phoneNumberId": "={{ $('WhatsApp Trigger').item.json.metadata.phone_number_id }}",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Extract URL from Message').item.json.from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Lf4s3r55bG6RFGLw",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "d82c4465-e3d2-43ea-b61a-f93c39b2e5b1",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 380,
        "height": 1132,
        "content": "## 🎤 WhatsApp 语音研究助手"
      },
      "typeVersion": 1
    },
    {
      "id": "35194f26-35c9-401e-88c4-b09102c0fafd",
      "name": "WhatsApp触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -720,
        240
      ],
      "webhookId": "1c4d0dd4-3820-4fc9-8926-b692c22509f1",
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "Kng74VNxItdZDRjm",
          "name": "WhatsApp OAuth account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3eef648b-506d-4a1e-8494-2892fab999b6",
      "name": "获取 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        -48,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "32b5ebf5-67a4-4be9-b659-221c354a4957",
              "name": "URL",
              "type": "string",
              "value": "={{ $('Check if Valid URL').item.json.URL }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1e575c6d-c3a0-4426-a044-4d3b11711c5a",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        608
      ],
      "parameters": {
        "width": 1265,
        "height": 495,
        "content": "## [子流程] 获取网页摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "ef8b7ac7-09aa-49d2-98f0-491762d52370",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        96,
        992
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "mDGcGh1b3ALbNE4K",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f8637017-8352-4034-bebc-a306bf90bab2",
      "name": "提取标题",
      "type": "n8n-nodes-base.html",
      "position": [
        -80,
        624
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d2bc9ef2-fdde-4549-b8e6-1f7611376d3c",
      "name": "摘要链",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        -160,
        784
      ],
      "parameters": {
        "options": {},
        "operationMode": "documentLoader"
      },
      "typeVersion": 2
    },
    {
      "id": "75a23c01-9746-48d8-b63f-17f5029e6841",
      "name": "清理",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        768
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7b337b47-a1c6-470e-881f-0c038b4917e5",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "ca820521-4fff-4971-84b5-e6e2dbd8bb7a",
              "name": "summary",
              "type": "string",
              "value": "={{ $json.response.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dc6be66b-f9a5-422a-9158-f3183d7c5f1b",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        768
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "bc556f6b-1f69-46dc-bfee-0c3dc32e8644",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        -160,
        896
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $('Extract Text Only').item.json.data }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "17be0ba5-0e78-4a59-8dfc-745ba92e8037",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        96,
        864
      ],
      "parameters": {
        "options": {},
        "chunkSize": 6000
      },
      "typeVersion": 1
    },
    {
      "id": "e2efdfe7-203c-4eb6-a2e5-9027a3886173",
      "name": "仅提取文本",
      "type": "n8n-nodes-base.html",
      "position": [
        -336,
        784
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "data",
              "cssSelector": "body",
              "skipSelectors": "img,nav"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3f6398b1-c16c-4f3e-b601-dd65efe98771",
      "name": "子流程执行",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -672,
        784
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "32e45648-f0c0-4d1b-8dae-1a090fc468e3",
      "name": "获取网站文本",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -544,
        784
      ],
      "parameters": {
        "url": "=https://r.jina.ai/{{ $json.URL }}",
        "options": {
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0e76e32f-270e-4714-839b-b490d0bbdaf7",
      "name": "上传和路径处理1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 448,
        "height": 224,
        "content": "## WhatsApp 触发器 -> 提取 URL -> 检查是否有效"
      },
      "typeVersion": 1
    },
    {
      "id": "18c324d6-0a56-4903-a0ab-8641eec897eb",
      "name": "分享链接管理1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -16
      ],
      "parameters": {
        "color": 2,
        "width": 768,
        "height": 224,
        "content": "## 总结网页并以音频消息回复到 WhatsApp"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Clean up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get URL": {
      "main": [
        [
          {
            "node": "Get Webpage Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub Execute": {
      "main": [
        [
          {
            "node": "Fetch site texts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract title": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch site texts": {
      "main": [
        [
          {
            "node": "Extract title",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract Text Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Extract URL from Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text Only": {
      "main": [
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check if Valid URL": {
      "main": [
        [
          {
            "node": "Send Processing Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Get Webpage Summary": {
      "main": [
        [
          {
            "node": "Convert Summary to Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarization Chain": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Send Processing Message": {
      "main": [
        [
          {
            "node": "Get URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Summary to Audio": {
      "main": [
        [
          {
            "node": "Send Audio Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URL from Message": {
      "main": [
        [
          {
            "node": "Check if Valid URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者

I write code to save you headaches. I post workflows, that I had a hard time with or find was really needed. If you pay for one of my workflows, congratulations... it probably took me 10x the $$ amount in my personal time, figuring the darn thing out.

外部链接
在 n8n.io 查看

分享此工作流