通过 Slack 与 OpenAI 助手通信(直接消息和@提及)

中级

这是一个Support、Building Blocks、AI领域的自动化工作流,包含 10 个节点。主要使用 If、Set、Code、Slack、Switch 等节点,结合人工智能技术实现智能自动化。 Slack-OpenAI 助手集成,支持直接消息和@提及

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "lmNh18di1V7RK6CU",
  "meta": {
    "instanceId": "28bd95de2c15632ac4fbb9a674b8e7a0156e242a724a5996b55587928eb6fb92",
    "templateCredsSetupCompleted": true
  },
  "name": "通过 Slack 与 OpenAI 助手通信(直接消息和@提及)",
  "tags": [
    {
      "id": "nxrsK8AuqtblfrtR",
      "name": "💪 Official template",
      "createdAt": "2025-05-23T14:32:31.457Z",
      "updatedAt": "2025-05-23T14:32:31.457Z"
    }
  ],
  "nodes": [
    {
      "id": "1b13f888-f10a-473d-be57-c2aa78d0d5ca",
      "name": "什么类型的事件?",
      "type": "n8n-nodes-base.switch",
      "position": [
        -60,
        -140
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "31f486c1-595b-4807-81a3-132812157348",
      "name": "子类型是否为 assistant_app_thread?",
      "type": "n8n-nodes-base.if",
      "position": [
        160,
        -340
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "d6ce3d5a-f796-429d-a540-6d0754584cb7",
      "name": "忽略",
      "type": "n8n-nodes-base.noOp",
      "position": [
        380,
        -440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "84647328-c093-4ffb-8b69-0e64886949f8",
      "name": "设置变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -280,
        -140
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "571ffcae-d95c-4ef3-b555-79c777ee0e6c",
      "name": "新消息或应用提及",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -500,
        -140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e186d855-efa5-447e-97a8-1f6d935a4863",
      "name": "生成响应",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        600,
        -120
      ],
      "parameters": {},
      "typeVersion": 1.8
    },
    {
      "id": "7241f01b-f1b9-464c-9eaf-f13377c5413d",
      "name": "从输出中移除引用",
      "type": "n8n-nodes-base.code",
      "position": [
        980,
        -120
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "bf6f05b3-7a43-4830-a787-b4504e8ed20b",
      "name": "记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        800,
        80
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "a7381bb1-2a7d-419a-8957-a4d3e4483ff9",
      "name": "在主题中回复直接消息或@提及",
      "type": "n8n-nodes-base.slack",
      "position": [
        1200,
        -120
      ],
      "webhookId": "fa744121-41f8-4539-9ba2-be6861d7a78c",
      "parameters": {},
      "typeVersion": 2.3
    },
    {
      "id": "dc8b03f2-b78f-4146-b9f5-00795c324cbc",
      "name": "设置状态和输入动画 [Slack]",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        380,
        -220
      ],
      "parameters": {},
      "typeVersion": 4.2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "96ba907d-b147-412e-acd3-dc370d7a29b8",
  "connections": {
    "Memory": {
      "ai_memory": [
        [
          {
            "node": "Generate response",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Set variables": {
      "main": [
        [
          {
            "node": "What type of event?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate response": {
      "main": [
        [
          {
            "node": "Remove citations from output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "What type of event?": {
      "main": [
        [
          {
            "node": "Is subtype assistant_app_thread?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New message or app mention": {
      "main": [
        [
          {
            "node": "Set variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove citations from output": {
      "main": [
        [
          {
            "node": "Reply to direct message or @mention in thread",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is subtype assistant_app_thread?": {
      "main": [
        [
          {
            "node": "Ignore",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set status and typing animation [Slack]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set status and typing animation [Slack]": {
      "main": [
        [
          {
            "node": "Generate response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量10
分类3
节点类型10
难度说明

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

作者
Bartosz

Bartosz

@supbarty

Automation consultant helping teams eliminate repetitive work. Successfully implemented n8n within an ISO27001-certified environment. Available for consulting on custom implementations, particularly around AI integrations.

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

分享此工作流