8
n8n 中文网amn8n.com

我的工作流19

高级

这是一个Support Chatbot领域的自动化工作流,包含 22 个节点。主要使用 If, Code, Switch, SplitInBatches, EvolutionApi 等节点。 通过Evolution API将Chatwoot消息转发到WhatsApp,支持媒体文件

前置要求
  • 无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Qh4rHuzaTQXDAaEI",
  "meta": {
    "instanceId": "9701ac1bcc28a7bbd58ce846fc70e46821a295729f112af5fc2c583b18299aa9"
  },
  "name": "我的工作流 19",
  "tags": [],
  "nodes": [
    {
      "id": "b4822297-d783-40cd-bf18-1a6f0e6810ff",
      "name": "当被另一个工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -3040,
        880
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "nm_instancia_evolution"
            },
            {
              "name": "ds_msg",
              "type": "object"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "312e21b2-e354-4e7f-89ae-09e2275b551f",
      "name": "无操作,不执行任何动作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2128,
        896
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6dda1da0-0a6b-437a-8b1a-dbd3741c2b7b",
      "name": "网关",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1872,
        608
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Incoming message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e1f0b76c-0729-4bfa-9320-51c0212d4052",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Object message').item.json.message_type }}",
                    "rightValue": "incoming"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Outgoing message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "588062af-c938-4fee-821f-8d2b6fba48cf",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Object message').item.json.message_type }}",
                    "rightValue": "outgoing"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Satisfaction Survey Message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2b0e5dd4-f690-4e2d-99ec-d583380e4d6a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Object message').item.json.content_type }}",
                    "rightValue": "=input_csat"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d18c977e-b2ac-44a7-b549-e688ee194e89",
      "name": "包含文本吗?",
      "type": "n8n-nodes-base.if",
      "position": [
        -592,
        1216
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f85eee76-5371-44a1-a19f-4741beb1cf30",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $('Object message').first().json.content }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0f353380-8619-4afe-aaf2-7e8086fe82a4",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -2832,
        880
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "NOVA MENSAGEM",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9bf3e1ce-3c66-45b2-900f-187fa3cc41b9",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ds_msg?.event }}",
                    "rightValue": "message_created"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "AGENTE ATRIBUÍDO",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "dae8c81d-0230-47eb-bdf0-6d53551fc648",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ds_msg?.event }}",
                    "rightValue": "assignee_changed"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "6ab998d5-482d-4aee-af87-db414f313936",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        336
      ],
      "parameters": {
        "width": 384,
        "height": 208,
        "content": "## 消息是否包含文件?"
      },
      "typeVersion": 1
    },
    {
      "id": "6424524a-5001-4a8a-994f-697ec1567ef6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1984,
        400
      ],
      "parameters": {
        "width": 336,
        "content": "## 消息类型"
      },
      "typeVersion": 1
    },
    {
      "id": "8acb8387-0ba2-403a-aa0d-c8c3ac76362e",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2432,
        400
      ],
      "parameters": {
        "width": 336,
        "content": "## 检查消息是否为私密消息"
      },
      "typeVersion": 1
    },
    {
      "id": "432312be-45da-4166-a231-af60a2e4a9ad",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 384,
        "height": 208,
        "content": "## 文件循环"
      },
      "typeVersion": 1
    },
    {
      "id": "78293e7e-5a6f-4922-be9d-73850538d957",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3120,
        672
      ],
      "parameters": {
        "width": 336,
        "content": "## 输入"
      },
      "typeVersion": 1
    },
    {
      "id": "e7f3356b-89d0-4a41-bab6-11b3f1eb3a56",
      "name": "检查消息是否为私密",
      "type": "n8n-nodes-base.if",
      "position": [
        -2336,
        640
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f32d9376-a128-42d9-b8e4-15e8b85565f6",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.private }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ee05ff9e-32ba-44f5-a635-0507571eb359",
      "name": "有附件吗?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1456,
        624
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c7745c75-0d6a-4339-b756-bed41144bf27",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.attachments.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "eed49873-5ff8-4864-be1e-0c1dbbdb7935",
      "name": "附件数组",
      "type": "n8n-nodes-base.code",
      "position": [
        -576,
        240
      ],
      "parameters": {
        "jsCode": "return $input.first().json.attachments;"
      },
      "typeVersion": 2
    },
    {
      "id": "5e81b55f-631c-4d88-9123-5d2da8672063",
      "name": "发送消息文本",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        880,
        1216
      ],
      "parameters": {
        "resource": "messages-api",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "messageText": "={{ $('Object message').first().json.content }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {
          "delay": 5000,
          "quoted": {
            "messageQuoted": {
              "messageId": "={{ $('Object message').item.json.content_attributes.in_reply_to_external_id.split(':')[1] }}"
            }
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "31b9f881-e48e-4ba1-8594-f4461cf7059a",
      "name": "发送视频消息",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        880,
        960
      ],
      "parameters": {
        "media": "={{ $json.data_url }}",
        "resource": "messages-api",
        "operation": "send-video",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {
          "quoted": {
            "messageQuoted": {
              "messageId": "={{ $('Object message').item.json.content_attributes.in_reply_to_external_id.split(':')[1] }}"
            }
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "45454744-a936-4992-b656-fabb4e96e085",
      "name": "发送音频消息",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        896,
        736
      ],
      "parameters": {
        "media": "={{ $json.data_url }}",
        "resource": "messages-api",
        "operation": "send-audio",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {
          "delay": 1200
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c90e33a2-de5e-4bbb-ae44-30040f94ecc6",
      "name": "发送图片消息",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        896,
        528
      ],
      "parameters": {
        "media": "={{ $json.data_url }}",
        "caption": "={{ $('Object message').first().json.content }}",
        "resource": "messages-api",
        "operation": "send-image",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {
          "quoted": {
            "messageQuoted": {
              "messageId": "={{ $('Object message').item.json.content_attributes.in_reply_to_external_id.split(':')[1] }}"
            }
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "df9cb908-9b6e-42f3-b5ed-3fc5e416580d",
      "name": "发送文档消息",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        896,
        304
      ],
      "parameters": {
        "media": "={{ $json.data_url }}",
        "caption": "={{ $('Object message').first().json.content }}",
        "fileName": "={{ decodeURIComponent($json.data_url.split('/').pop()) }}",
        "resource": "messages-api",
        "operation": "send-document",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {
          "quoted": {
            "messageQuoted": {
              "messageId": "={{ $('Object message').item.json.content_attributes.in_reply_to_external_id.split(':')[1] }}"
            }
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9dd6f7a1-dd6f-4095-95a3-dbeb46c65d18",
      "name": "检查附件文件类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        208,
        256
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "File (PDF, Word, Excel and etc...)",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "af3b3471-982c-4903-a340-80657b66d4cc",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.file_type }}",
                    "rightValue": "file"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image ",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0e5902d4-1cb0-4334-9abf-29397a078c73",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.file_type }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c23ed758-1739-4595-ba8b-b1b0af3c00c1",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "=FixedExpression{{ $json.file_type }}FixedExpressionRename Output FixedExpressionOutput Name FixedExpression{{ $json.file_type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Video",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6e3b2557-0b88-432b-a9ec-1f0adb83b790",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.file_type }}",
                    "rightValue": "video"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d304f7ca-685d-4c20-a400-c9e62e6c2850",
      "name": "循环附件数组",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -16,
        240
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5acb48f5-17e2-46ad-b42a-ad456629039e",
      "name": "对象消息",
      "type": "n8n-nodes-base.code",
      "position": [
        -2560,
        640
      ],
      "parameters": {
        "jsCode": "let res = $('When Executed by Another Workflow').first().json.ds_msg;\n\nreturn res;"
      },
      "typeVersion": 2
    },
    {
      "id": "dbd8e3fe-deb9-4677-88df-3f076bfe078f",
      "name": "发送文本 - 满意度调查(Chatwoot 链接)",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        -1568,
        1056
      ],
      "parameters": {
        "resource": "messages-api",
        "remoteJid": "={{ $('Object message').first().json.conversation.meta.sender.phone_number }}",
        "messageText": "={{ $('Object message').first().json.content }}",
        "instanceName": "={{ $('When Executed by Another Workflow').first().json.nm_instancia_evolution }}",
        "options_message": {}
      },
      "credentials": {
        "evolutionApi": {
          "id": "KO9PVs8kvAt2hWOa",
          "name": "Evolution account 2"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7726f27a-9101-465e-9610-d3d11a4b0787",
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Object message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gateway": {
      "main": [
        [],
        [
          {
            "node": "Has attachment?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send text - Satisfaction Survey (Link chatwoot)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Possui texto?": {
      "main": [
        [
          {
            "node": "Send message text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Object message": {
      "main": [
        [
          {
            "node": "Check if message is private",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has attachment?": {
      "main": [
        [
          {
            "node": "Array of attachments",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Possui texto?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send audio message": {
      "main": [
        [
          {
            "node": "Loop array of attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send image message": {
      "main": [
        [
          {
            "node": "Loop array of attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send video message": {
      "main": [
        [
          {
            "node": "Loop array of attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Array of attachments": {
      "main": [
        [
          {
            "node": "Loop array of attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send document message": {
      "main": [
        [
          {
            "node": "Loop array of attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop array of attachments": {
      "main": [
        [],
        [
          {
            "node": "Check attachment file type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check attachment file type": {
      "main": [
        [
          {
            "node": "Send document message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send image message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send audio message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send video message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if message is private": {
      "main": [
        [
          {
            "node": "Gateway",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人

需要付费吗?

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

工作流信息
难度等级
高级
节点数量22
分类1
节点类型8
难度说明

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

作者
Thiago Vazzoler Loureiro

Thiago Vazzoler Loureiro

@thiagovazzoler

Building Custom Automations with n8n | Node.js Developer | Integration Specialist | Open Source Contributor If you need help with n8n workflows, API integrations, or custom nodes, feel free to connect on LinkedIn: http://linkedin.com/in/thiago-vazzoler-loureiro-24056227

外部链接
在 n8n.io 查看

分享此工作流