Line消息API演示

中级

这是一个Building Blocks领域的自动化工作流,包含 8 个节点。主要使用 If、Set、Webhook、HttpRequest、ManualTrigger 等节点。 Line消息API:推送消息与回复

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "a5tCsfMzJPd8WDUj",
  "meta": {
    "instanceId": "fddb3e91967f1012c95dd02bf5ad21f279fc44715f47a7a96a33433621caa253",
    "templateCredsSetupCompleted": true
  },
  "name": "Line 消息 API 演示",
  "tags": [],
  "nodes": [
    {
      "id": "2bc1cc31-136c-46a4-a789-476e33c76f3d",
      "name": "Line:使用令牌回复",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -540,
        -460
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook from Line Message').item.json.body.events[0].replyToken }}\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"收到您的訊息 : {{ $('Webhook from Line Message').item.json.body.events[0].message.text }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "xB2Ip7YKSIDq7BoI",
          "name": "Line n8n demo auth"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a1d9c986-4712-4d40-955d-40d1b19d74db",
      "name": "来自 Line 消息的 Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1020,
        -440
      ],
      "webhookId": "638c118e-1c98-4491-b6ff-14e2e75380b6",
      "parameters": {
        "path": "638c118e-1c98-4491-b6ff-14e2e75380b6",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "a0c94852-290f-48b9-8e11-b498ada90c8f",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -620
      ],
      "parameters": {
        "width": 720,
        "height": 340,
        "content": "## Line 消息 API 回复"
      },
      "typeVersion": 1
    },
    {
      "id": "278aff13-c081-47f0-a1f6-67920642e991",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        -800,
        -440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b63773bb-f010-4018-8142-240c9aaa4570",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.events[0].type }}",
              "rightValue": "message"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cff2f1d3-b7a4-4940-a1d1-1e5a80d6ea28",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -200
      ],
      "parameters": {
        "width": 720,
        "height": 340,
        "content": "## Line 消息 API 发送消息"
      },
      "typeVersion": 1
    },
    {
      "id": "9348fc83-0aeb-4591-85b6-48f556512478",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1020,
        -20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "74db3e1b-9a22-4033-bf04-a8ff485a5d3b",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -800,
        -20
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6278f340-6287-4e89-b774-f6c584954d5b",
              "name": "line_uid",
              "type": "string",
              "value": "Uxxxxxxxxxxxx"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c593bd58-8f6a-4689-bb12-e71256ccf6e6",
      "name": "Line:推送消息",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -560,
        -20
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/push",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"to\": \"{{ $json.line_uid }}\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"推播測試\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "xB2Ip7YKSIDq7BoI",
          "name": "Line n8n demo auth"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "240dc848-8803-4776-b01d-5f10c765f72b",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Line : Reply with token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Line : Push Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook from Line Message": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个中级难度的工作流,适用于Building Blocks等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

需要付费吗?

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

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

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
darrell_tw

darrell_tw

@darrelltw

Martech Engineer with automation. here is my website: https://www.darrelltw.com/

外部链接
在 n8n.io 上查看 →

分享此工作流