凤凰AI七社 Logo 凤凰AI七社

Ultramsg + n8n 辅助文档

发布于 2025-05-29 08:04

WhatsApp API平台 Ultramsg

Ultramsg 是一款基于 WhatsApp API 平台的 WhatsApp 辅助工具。它可以帮助你快速、高效地管理和组织你的 WhatsApp 群组、联系人、消息。

点击这里打开 Ultramsg官网。需要注意的是这个平台目前只有三天的免费试用期,到期后就要付费,否在会停止服务。

docker compose 新增挂载和环境变量

如果你是在上一个视频的指导下安装的n8n,可以直接复制下方的命令。

进入n8n的数据目录

cd /root/dockers-data/n8ndata

创建data目录

mkdir data  

编辑docker-compose.yml文件

vim docker-compose.yml

在volumes下新增挂载

- ./data:/files

在environment下新增环境变量

- N8N-FILESSYSTEM_NODES_ALLOWED_PATH=/files

n8n容器重新部署命令

docker compose down
docker compose up -d

产品目录文件存放路径,把testData.txt修改为你自己的产品信息文件名

/files/testData.txt

http request send headers 节点配置

name Content-Type

value application/x-www-form-urlencoded

工作流json,复制json粘贴到n8n画布即可(需要自行配置凭证)

{
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "=客户问题: {{ $('接收消息').item.json.body.data.body }}",
        "options": {
          "systemMessage": "=你是一个懂产品的客服,会严格按照产品目录的内容回答客户问题。\n {{ $json.data }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        220,
        -180
      ],
      "id": "dfacf168-55f0-4168-a9b3-bea9cf70a491",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "typeVersion": 1,
      "position": [
        80,
        100
      ],
      "id": "e35fe348-5324-4e59-bf47-89b2000f344a",
      "name": "DeepSeek Chat Model",
      "credentials": {
        "deepSeekApi": {
          "id": "ikOtrHsx645oEF7X",
          "name": "DeepSeek account 2"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "test-whatsapp",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -780,
        -420
      ],
      "id": "bfa35d12-ca79-4182-be98-e610ad51c607",
      "name": "接收消息",
      "webhookId": "84654826-222f-4a5c-8b56-0f8cfb84ebe9"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "0246fd4e-4180-49b1-97e1-82a7cc4812b5",
              "leftValue": "={{ $json.body.data.to }}",
              "rightValue": "={{ $json.body.data.from }}",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -460,
        -320
      ],
      "id": "f06b6b24-efbb-49b8-b9e2-b28d07235ad0",
      "name": "判断接收方和发送方是否不同"
    },
    {
      "parameters": {
        "fileSelector": "/files/testData.txt",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        -220,
        -180
      ],
      "id": "65469f21-4391-4f58-b143-9fcea021a7d4",
      "name": "读取产品目录",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "operation": "text",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        0,
        -180
      ],
      "id": "e96a6331-b469-41c9-8889-b96024c6f4ee",
      "name": "产品目录转json"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.ultramsg.com/instance122007/messages/chat",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/x-www-form-urlencoded"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "token",
              "value": ""
            },
            {
              "name": "to",
              "value": "={{ $('接收消息').item.json.body.data.from }}"
            },
            {
              "name": "body",
              "value": "={{ $json.output }}"
            },
            {
              "name": "priority",
              "value": "1"
            },
            {
              "name": "referenceId",
              "value": "={{ $('接收消息').item.json.body.data.id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        580,
        -180
      ],
      "id": "111eb19d-f207-4dda-a45e-7f90e2505abe",
      "name": "回复消息"
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "回复消息",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepSeek Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "接收消息": {
      "main": [
        [
          {
            "node": "判断接收方和发送方是否不同",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "判断接收方和发送方是否不同": {
      "main": [
        [
          {
            "node": "读取产品目录",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "读取产品目录": {
      "main": [
        [
          {
            "node": "产品目录转json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "产品目录转json": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "5c9bb470a8bc7c91b45be0e860d80a31820afbd5edb74be3e7b91bb79ba053b3"
  }
}

相关视频

【0基础系列-00】手摸手教你配置服务器|n8n/Docker/AI系统的基石!

【零基础系列01】Linux 快速部署 Docker 和 n8n | 新手也能一键搭建自动化神器!

【零基础系列02】不裸奔了!给 n8n 配上专属域名和 HTTPS 安全通道

返回首页 上传文章 编辑文章