8
n8n 中文网amn8n.com

使用 GPT-4o、Whisper 转录和 Redis 缓冲创建 WhatsApp 聊天机器人

高级

这是一个自动化工作流,包含 35 个节点。主要使用 Set, Code, Wait, Merge, Redis 等节点。 使用 GPT-4o、Whisper 转录和 Redis 缓冲创建 WhatsApp 聊天机器人

前置要求
  • Redis 服务器连接信息
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "7de9c03c5df732f2294cfa53379db42b70689739afb5ed84c40dd844fed72f02"
  },
  "nodes": [
    {
      "id": "ffb21e8f-9568-4e5f-a7dc-9ede3cb3529d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        4080,
        416
      ],
      "parameters": {
        "text": "={{ $json.chat_input }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "5598448f-1646-4299-923a-2dcf6707b4f2",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        4240,
        656
      ],
      "parameters": {
        "sessionKey": "={{ $('Set fields1').item.json.message.chat_id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "9929d34c-2954-4272-861a-57b441c7eec0",
      "name": "等待3",
      "type": "n8n-nodes-base.wait",
      "position": [
        1456,
        544
      ],
      "webhookId": "96c27c05-96e6-490e-ac24-3c38c75c7d9b",
      "parameters": {
        "amount": 7
      },
      "typeVersion": 1.1
    },
    {
      "id": "9975c463-56c0-463c-8311-2d56b20e0684",
      "name": "无操作,不执行任何操作3",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1456,
        112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c21ec32e-ad73-4fac-8442-30d8906e1a5e",
      "name": "切换类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        2288,
        304
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a1ae30d8-caca-41ff-857b-ed9f55b09ca1",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.content_type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "11e0f3f8-1dd2-4efd-aad1-cf42c96bbc5d",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.content_type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c338dd6b-e18d-4528-95e7-990cd94d5da7",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.content_type }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5371ce24-b650-47de-a77c-5b8438cbcca4",
      "name": "转录录音",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2960,
        384
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "Kviz2ptGHoqK8BIL",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "a8a2f5e1-d9d1-46ab-8b1b-af95fcb1a3d8",
      "name": "音频内容",
      "type": "n8n-nodes-base.set",
      "position": [
        3152,
        384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5f4831a4-5837-492f-b7a9-84b8e9f1f3a9",
              "name": "content",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "85531cdf-5fc0-41f6-bed9-da0dfaa517ba",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Code in JavaScript').item.json.timestamp }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "45c98f8a-81ac-4e99-a85b-3401b04e5c40",
      "name": "获取所有 img_url",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2912,
        656
      ],
      "parameters": {
        "text": "What's in the image?",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "resource": "image",
        "imageUrls": "={{ $json.publicUrl }}",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "id": "Kviz2ptGHoqK8BIL",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "0347c99c-b10b-49cb-acc4-6bb1522fe85c",
      "name": "图片内容",
      "type": "n8n-nodes-base.set",
      "position": [
        3136,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac66cc5d-a460-43d6-8932-7a5fb3c63daf",
              "name": "=Image",
              "type": "string",
              "value": "=Caption written by User: {{ $('Code in JavaScript').item.json.content }}\n\nImage analysis: {{ $json.content }}\n\n"
            },
            {
              "id": "3a54bf57-8d27-4857-bef9-614e505ec802",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Code in JavaScript').item.json.timestamp }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e147bb2c-4b47-43d4-891f-3307afb7046c",
      "name": "文本内容",
      "type": "n8n-nodes-base.set",
      "position": [
        2864,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5f4cdc1a-fc80-4aed-9493-38caeb7103f9",
              "name": "content",
              "type": "string",
              "value": "={{ $('Code in JavaScript').item.json.content }}"
            },
            {
              "id": "203a7e05-03f0-413a-90ac-aade62096999",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Code in JavaScript').item.json.timestamp }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a78497d6-29ec-4019-a8c8-fb3eebc76e53",
      "name": "聊天输入",
      "type": "n8n-nodes-base.set",
      "position": [
        3872,
        416
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "866095be-3f42-4f6a-a7f1-67adec82bf58",
              "name": "chat_input",
              "type": "string",
              "value": "={{ $json.Content.map(msg => msg.content || msg.Image).join('\\n') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "078ca1b6-4baf-42f3-bef5-6fca9f8dad7a",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        1232,
        288
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Ignore",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "81c7205c-84c9-480e-8b5a-1a12b5ff7baa",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "leftValue": "={{ JSON.parse($json.Mensaje.last()).message_id }}",
                    "rightValue": "={{ $('Set fields1').item.json.message.message_id }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Continue",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4fca4c39-e8bf-490b-8e2e-176c95d9156e",
                    "operator": {
                      "type": "dateTime",
                      "operation": "before"
                    },
                    "leftValue": "={{ DateTime.fromISO(JSON.parse($json.Mensaje.last()).timestamp).toUTC().toISO() }}",
                    "rightValue": "={{ $now.minus(7, 'seconds').toUTC().toISO() }}"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Wait"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "bf1f8bcc-2cf6-4fb9-9a07-29196c621701",
      "name": "JavaScript代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        320
      ],
      "parameters": {
        "jsCode": "// Code node in n8n\n// Loops through all input items and parses the \"Mensaje\" field\nreturn items.map(item => {\n  let parsed = {};\n  try {\n    parsed = JSON.parse(item.json.Mensaje);\n  } catch (error) {\n    // If parsing fails, log it and continue\n    parsed = { error: 'Invalid JSON', raw: item.json.Mensaje };\n  }\n  \n  return {\n    json: parsed\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2de4aea2-00fa-4f32-9172-420b59c96e93",
      "name": "向用户发送消息",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4768,
        416
      ],
      "parameters": {
        "url": "https://www.wasenderapi.com/api/send-message",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "to",
              "value": "={{ $('Set fields1').item.json.message.chat_id }}"
            },
            {
              "name": "text",
              "value": "={{ $json.output }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR API KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "33193b50-0af9-4883-abd5-55a087dcca6a",
      "name": "获取音频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2608,
        384
      ],
      "parameters": {
        "url": "https://www.wasenderapi.com/api/decrypt-media",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"data\": {\n    \"messages\": {\n      \"key\": {\n        \"id\": \"{{ $json.message_id }}\"\n      },\n      \"message\": {\n        \"audioMessage\": {\n          \"url\": \"{{ $json.url }}\",\n          \"mimetype\": \"{{ $json.mimetype }}\",\n          \"mediaKey\": \"{{ $json.mediaKey }}\",\n          \"fileSha256\": \"{{ $json.fileSha256 }}\",\n          \"fileLength\": \"{{ $json.fileLength }}\",\n          \"fileName\": \"audio/mpeg\"\n        }\n      }\n    }\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR API KEY "
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c87722c-fac4-48ff-9d51-3747211dfa0a",
      "name": "下载音频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2784,
        384
      ],
      "parameters": {
        "url": "={{ $json.publicUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "04c92b95-1756-4b11-8829-224ebcc5686b",
      "name": "分离输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1872,
        320
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "Mensaje"
      },
      "typeVersion": 1
    },
    {
      "id": "0c0914f9-c5c4-49a7-a1d4-7b59ea71fe54",
      "name": "获取照片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2704,
        656
      ],
      "parameters": {
        "url": "https://www.wasenderapi.com/api/decrypt-media",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"data\": {\n    \"messages\": {\n      \"key\": {\n        \"id\": \"{{ $json.message_id }}\"\n      },\n      \"message\": {\n        \"imageMessage\": {\n          \"url\": \"{{ $json.url }}\",\n          \"mimetype\": \"{{ $json.mimetype }}\",\n          \"mediaKey\": \"{{ $json.mediaKey }}\",\n          \"fileSha256\": \"{{ $json.fileSha256 }}\",\n          \"fileLength\": \"{{ $json.fileLength }}\",\n          \"fileName\": \"image.jpg\"\n\n        }\n      }\n    }\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR API KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "22c600ee-a27d-4619-8f83-a4f70a221b3a",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        4048,
        624
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Kviz2ptGHoqK8BIL",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "217076f7-8505-48a0-80f3-f3160c09f99a",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        4560,
        416
      ],
      "webhookId": "a8ae67f6-7e4d-4647-9511-30040d764dc6",
      "parameters": {
        "amount": 6
      },
      "typeVersion": 1.1
    },
    {
      "id": "72c7bc0f-827d-4f17-b83c-c7df897e4235",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        3440,
        400
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "Content"
      },
      "typeVersion": 1
    },
    {
      "id": "d3b853a8-0318-4e70-b742-56e0b394efb8",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        3648,
        400
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "7781dec5-b1db-4e85-8033-fd232f98fb3c",
      "name": "Redis",
      "type": "n8n-nodes-base.redis",
      "position": [
        736,
        304
      ],
      "parameters": {
        "list": "={{ $json.message.chat_id }}_buffer",
        "tail": true,
        "operation": "push",
        "messageData": "={{ JSON.stringify({\n  message_id: $('Set fields1').item.json.message.message_id,\n  chat_id: $('Set fields1').item.json.message.chat_id,\n  content_type: $('Set fields1').item.json.message.content_type,\n  content: $('Set fields1').item.json.message.content,\n  timestamp: $('Set fields1').item.json.message.timestamp,\n  url: $('Set fields1').item.json.url,\n  mimetype: $('Set fields1').item.json.mimetype,\n  mediaKey: $('Set fields1').item.json.mediaKey,\n  fileSha256: $('Set fields1').item.json.fileSha256,\n  fileLength: $('Set fields1').item.json.fileLength,\n  jpegThumbnail: $('Set fields1').item.json.jpegThumbnail,\n  user: $('Set fields1').item.json.user\n}) }}"
      },
      "credentials": {
        "redis": {
          "id": "kzytmvxt89OIjX1i",
          "name": "Redis account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "627b5411-38d2-4399-b71d-3e11ad01ff6e",
      "name": "Redis1",
      "type": "n8n-nodes-base.redis",
      "position": [
        976,
        304
      ],
      "parameters": {
        "key": "={{ $('Set fields1').item.json.message.chat_id }}_buffer",
        "options": {},
        "operation": "get",
        "propertyName": "Mensaje"
      },
      "credentials": {
        "redis": {
          "id": "kzytmvxt89OIjX1i",
          "name": "Redis account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e6ab5949-7386-4a93-bc37-019f554f83da",
      "name": "Redis2",
      "type": "n8n-nodes-base.redis",
      "position": [
        1456,
        304
      ],
      "parameters": {
        "key": "={{ $('Set fields1').item.json.message.chat_id }}_buffer",
        "operation": "delete"
      },
      "credentials": {
        "redis": {
          "id": "kzytmvxt89OIjX1i",
          "name": "Redis account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "01c8625c-a36a-45d9-b27d-dfc85e093e38",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        64
      ],
      "parameters": {
        "width": 320,
        "height": 480,
        "content": "## WasenderAPI设置"
      },
      "typeVersion": 1
    },
    {
      "id": "a29ed058-4dfa-433e-b653-7a642fbeee82",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        64
      ],
      "parameters": {
        "width": 320,
        "height": 592,
        "content": "## 设置字段节点"
      },
      "typeVersion": 1
    },
    {
      "id": "0c3a30af-c954-4378-84c4-795069c8b80b",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -288
      ],
      "parameters": {
        "color": 3,
        "width": 848,
        "height": 1072,
        "content": "## 消息缓冲系统"
      },
      "typeVersion": 1
    },
    {
      "id": "e02f45ab-8b2a-4a3c-81b2-3db89912663d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -16
      ],
      "parameters": {
        "width": 624,
        "height": 576,
        "content": "## 消息处理"
      },
      "typeVersion": 1
    },
    {
      "id": "0e8c3e7a-7f5b-4e18-a1ca-63e9bb4ec89d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2480,
        -464
      ],
      "parameters": {
        "color": 4,
        "width": 896,
        "height": 1392,
        "content": "## 内容处理"
      },
      "typeVersion": 1
    },
    {
      "id": "9d02f39c-2589-4bb0-8a45-6b30c67e44e8",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3424,
        -128
      ],
      "parameters": {
        "width": 944,
        "height": 896,
        "content": "## AI对话系统"
      },
      "typeVersion": 1
    },
    {
      "id": "f1048ef3-8096-4569-bdb8-2d398e37ae2f",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4480,
        -112
      ],
      "parameters": {
        "width": 464,
        "height": 720,
        "content": "## 响应传递"
      },
      "typeVersion": 1
    },
    {
      "id": "d800b3f3-d8ba-43ac-b7b6-b14e6843da95",
      "name": "设置字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        496
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d3a9a053-6bc1-4b06-bd1d-66619c92154d",
              "name": "message.message_id",
              "type": "string",
              "value": "={{ $json.body.data.messages.key.id }}"
            },
            {
              "id": "00682555-4e80-4351-8ed3-71812ecd54f6",
              "name": "message.chat_id",
              "type": "string",
              "value": "={{ $json.body.data.messages.key.remoteJid }}"
            },
            {
              "id": "d28e7894-2df8-4ea4-bd01-8e4f285e3068",
              "name": "url",
              "type": "string",
              "value": "={{ $json.body?.data?.messages?.message?.imageMessage?.url || '' }}{{ $json.body?.data?.messages?.message?.audioMessage?.url || '' }}"
            },
            {
              "id": "c1e1ce53-ac41-4989-9f8d-e03f2a5395bf",
              "name": "message.content_type",
              "type": "string",
              "value": "={{ ($json.body.data.messages.message.extendedTextMessage && $json.body.data.messages.message.extendedTextMessage.text) || ($json.body.data.messages.message.conversation) ? 'text' : '' }}{{ $json.body.data.messages.message.audioMessage && $json.body.data.messages.message.audioMessage.mimetype ? 'audio' : '' }}{{ $json.body.data.messages.message.imageMessage && $json.body.data.messages.message.imageMessage.url ? 'image' : '' }}"
            },
            {
              "id": "46117b1c-4557-4354-8581-c5368b7b1bcf",
              "name": "message.content",
              "type": "string",
              "value": "={{ $json.body.data.messages.message.conversation || '' }}{{ $json.body.data.messages.message.extendedTextMessage?.text || ''}}{{ $json.body.data.messages.message.imageMessage?.caption || ''}}"
            },
            {
              "id": "2911cef7-00f5-4cf0-9e12-75509faf543a",
              "name": "message.timestamp",
              "type": "string",
              "value": "={{ DateTime.fromMillis($json.body.timestamp).toUTC().toISO() }}"
            },
            {
              "id": "23fd732c-6575-4b85-a3ba-b94ee137035f",
              "name": "mimetype",
              "type": "string",
              "value": "={{ $json.body?.data?.messages?.message?.audioMessage?.mimetype || '' }}{{ $json.body?.data?.messages?.message?.imageMessage?.mimetype || '' }}"
            },
            {
              "id": "db3fcae5-e030-4369-8738-08141e5a5184",
              "name": "mediaKey",
              "type": "string",
              "value": "={{ $json.body?.data?.messages?.message?.audioMessage?.mediaKey || '' }}{{ $json.body?.data?.messages?.message?.imageMessage?.mediaKey || '' }}"
            },
            {
              "id": "b629f260-390a-471b-8892-adb85a720ed1",
              "name": "fileSha256",
              "type": "string",
              "value": "={{ $json.body?.data?.messages?.message?.audioMessage?.fileSha256 || '' }}{{ $json.body?.data?.messages?.message?.imageMessage?.fileSha256 || '' }}"
            },
            {
              "id": "6b3ec16e-5e18-485a-9791-645ab1a49d98",
              "name": "fileLength",
              "type": "string",
              "value": "={{ $json.body?.data?.messages?.message?.audioMessage?.fileLength || '' }}{{ $json.body?.data?.messages?.message?.imageMessage?.fileLength || '' }}"
            },
            {
              "id": "759584be-888e-46b4-bf7c-0e9db2b39887",
              "name": "jpegThumbnail",
              "type": "string",
              "value": "={{ $json.body.data.messages.message.imageMessage?.jpegThumbnail ||''}}"
            },
            {
              "id": "019920f4-ce87-4c9a-be61-b11f4b0e13d7",
              "name": "user.name",
              "type": "string",
              "value": "={{ $json.body.data.messages.pushName }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ab0149b7-c162-427b-9d11-6a8f4866be7b",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        48,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6e8a5c44-6a18-40e9-9b81-ed002c4473fe",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -16
      ],
      "parameters": {
        "height": 80,
        "content": "## 更改为Webhook触发器"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Send Message to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Chat Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis": {
      "main": [
        [
          {
            "node": "Redis1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "Redis1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis1": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis2": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "No Operation, do nothing3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Redis2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Input": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set fields1": {
      "main": [
        [
          {
            "node": "Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Type": {
      "main": [
        [
          {
            "node": "Text Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get the audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get the photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Content": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Image Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio Content": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get the audio": {
      "main": [
        [
          {
            "node": "Download the audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get the photo": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Content": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Switch Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the audio": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Audio Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Set fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级

需要付费吗?

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

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

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

作者
Jose Bossa

Jose Bossa

@bossa

AI consultant with over 3 months and high ticket salesman over 2 years.

外部链接
在 n8n.io 查看

分享此工作流