8
n8n 中文网amn8n.com

Slack AI代理基础

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 34 个节点。主要使用 Set, Merge, Slack, Switch, HttpRequest 等节点。 支持语音、图像和视频处理的多模态Slack AI助手

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • Anthropic API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "0sz7800El6YsOEhI",
  "meta": {
    "instanceId": "e3f5b14dd829b60d7a052fff9dcdd349fd20ca18d74a872c51a793bc94cd4aaa",
    "templateCredsSetupCompleted": true
  },
  "name": "Slack AI 代理基础",
  "tags": [],
  "nodes": [
    {
      "id": "ce4185b8-002f-4d1a-afb5-7b92f72a6654",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        224,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2c19aba8-aba2-4cf2-aefc-1f1af9277f5d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.files[0].media_display_type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "picture",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5e324898-f3d5-4a84-8ca4-94a33849cd6d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.files[0].mimetype }}",
                    "rightValue": "image/png"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "video",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7b448a1b-5f96-42e3-bfce-dad6b5c45f01",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.files[0].mimetype }}",
                    "rightValue": "video/mp4"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ef6ba691-a321-4458-af08-6b9f2f39b18a",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.blocks[0].elements[0].elements[1].type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "f8764c3f-e0d7-4409-825d-805ed9fcb987",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1616,
        144
      ],
      "parameters": {
        "text": "={{ $json[\"User Input\"] }}",
        "options": {
          "systemMessage": "You are a helpful, intelligent assistant.\n\nOutput ONLY a plain UTF-8 string for Telegram. \nNo JSON. No code fences. No prefaces. \nIf content is empty, output \"…\"."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "222d87bc-66ae-48d4-8272-29aae5ce9f03",
      "name": "转录录音",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        976,
        16
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "nNUPQt28U7stZkxv",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "e5041fd3-f5e7-4351-b539-364f51ed37f3",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1728,
        448
      ],
      "parameters": {
        "sessionKey": "={{ $('Slack Trigger').item.json.channel }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "21dc9d8d-c911-469b-9b93-92ee88c25a96",
      "name": "日期与时间",
      "type": "n8n-nodes-base.dateTimeTool",
      "position": [
        1968,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "ddff0cde-feb3-415e-9357-33a1d52f8004",
      "name": "Anthropic 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1456,
        448
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude Sonnet 4"
        },
        "options": {
          "maxTokensToSample": 10000
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "y5udJNdCdTzH3Zy2",
          "name": "Keith's Anthropic Connection"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f52eba8b-f1e1-4b58-8dbd-5070673c809b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 560,
        "content": "# 说明"
      },
      "typeVersion": 1
    },
    {
      "id": "ffa1adaa-36e0-488b-a1da-42c11a4c0f6c",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 496,
        "content": "### 等待 Slack 消息以启动工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "bb7289d3-db39-416f-baec-e3fb131b81f3",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 496,
        "content": "### 确定发送的消息类型"
      },
      "typeVersion": 1
    },
    {
      "id": "b31e49df-04c8-498f-80e4-33e400007b22",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 208,
        "content": "### 获取音频文件"
      },
      "typeVersion": 1
    },
    {
      "id": "f3db8810-569e-4bf7-8147-76aa6e2e4a25",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 208,
        "content": "### 使用 OpenAI 转录录音"
      },
      "typeVersion": 1
    },
    {
      "id": "8f0822c6-9479-4aa1-92c6-cc0cb43079bc",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        352
      ],
      "parameters": {
        "width": 224,
        "height": 224,
        "content": "### 在此处选择任意 LLM"
      },
      "typeVersion": 1
    },
    {
      "id": "a39401d6-fed8-47ea-82af-de561df1b32e",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 288,
        "height": 368,
        "content": "### 基础 AI 代理。调整\"系统提示\"以根据您的需求个性化此代理"
      },
      "typeVersion": 1
    },
    {
      "id": "d8b86141-a03a-419c-854d-a57269cc4898",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 224,
        "height": 368,
        "content": "### 将 AI 代理输出发送到您的 Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "3fefd42d-52cc-438c-b4cb-99620e58f6a6",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1664,
        352
      ],
      "parameters": {
        "width": 208,
        "height": 224,
        "content": "### 选择 LLM 可以读取的消息数量"
      },
      "typeVersion": 1
    },
    {
      "id": "028b7ead-a437-470e-920e-5d0d1c9cae98",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        352
      ],
      "parameters": {
        "width": 224,
        "height": 224,
        "content": "### 在此处添加 LLM 可以访问的工具"
      },
      "typeVersion": 1
    },
    {
      "id": "f9b36773-7ded-446d-86ac-889740af3699",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        192
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 208,
        "content": "### 获取照片文件"
      },
      "typeVersion": 1
    },
    {
      "id": "d49cb62d-917f-4cb9-9080-363f3259d861",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        192
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 208,
        "content": "### 使用 Gemini 分析照片"
      },
      "typeVersion": 1
    },
    {
      "id": "2f40620a-0c0b-4f99-ba5a-6700c3cc38b3",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        1232,
        112
      ],
      "parameters": {
        "numberInputs": 4
      },
      "typeVersion": 3.2
    },
    {
      "id": "20c873b1-a8ea-40ce-a0e6-0b424a76ff8d",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 160,
        "height": 368,
        "content": "### 创建统一输入传递给 AI 代理"
      },
      "typeVersion": 1
    },
    {
      "id": "db7460e7-6c91-40de-989c-aa729d26bd85",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        432
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 208,
        "content": "### 获取视频文件"
      },
      "typeVersion": 1
    },
    {
      "id": "25433506-93df-4a6b-91c1-65bbe24427f5",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        432
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 208,
        "content": "### 使用 Gemini 分析视频"
      },
      "typeVersion": 1
    },
    {
      "id": "1c3a6c58-96b3-46be-9a48-8a8d951076c2",
      "name": "分析视频",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        976,
        496
      ],
      "parameters": {
        "text": "={{ $('Slack Trigger').item.json.text }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "video",
        "inputType": "binary",
        "operation": "analyze"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "82HZGtRNVMLV9eBr",
          "name": "Keith's Gemini API Key"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "695ac1ab-48bd-48f3-9797-482fb4bb5ade",
      "name": "分析图片",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        976,
        256
      ],
      "parameters": {
        "text": "={{ $('Slack Trigger').item.json.text }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "image",
        "inputType": "binary",
        "operation": "analyze"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "82HZGtRNVMLV9eBr",
          "name": "Keith's Gemini API Key"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dfbb869b-c80b-40c8-8df8-11a951a93b77",
      "name": "Slack 触发器",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -16,
        208
      ],
      "webhookId": "576e2393-f193-42e2-9146-a1e175b495c6",
      "parameters": {
        "options": {},
        "trigger": [
          "app_mention",
          "message"
        ],
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09HD4Z93T7",
          "cachedResultName": "ai-agent"
        }
      },
      "credentials": {
        "slackApi": {
          "id": "r8tdAw7UpbSrIbTT",
          "name": "N8N Slack Bot"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4e18fc91-e742-4da4-8416-9a9b57cb2de0",
      "name": "发送消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        1968,
        144
      ],
      "webhookId": "83da047c-6fef-4a62-9789-5e840fde3d4b",
      "parameters": {
        "text": "={{ $('AI Agent').item.json.output }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "C09HD4Z93T7"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "r8tdAw7UpbSrIbTT",
          "name": "N8N Slack Bot"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1e78889b-6686-4f45-91cc-72df6843df10",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        16
      ],
      "parameters": {
        "url": "={{ $json.url_private }}",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer [Your bot token here]"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0623e545-fa6c-4162-80ff-85a9ec99b148",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 688,
        "content": "### 下载文件"
      },
      "typeVersion": 1
    },
    {
      "id": "e9328967-f8c6-4654-89b0-e5ddf4945b3a",
      "name": "HTTP请求1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        256
      ],
      "parameters": {
        "url": "={{ $json.url_private }}",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer [Your bot token here]"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "68b9c45f-b20a-42ce-9158-000c43763128",
      "name": "HTTP 请求2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        496
      ],
      "parameters": {
        "url": "={{ $json.url_private }}",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer [Your bot token here]"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b00f89d5-d32c-4417-a2d7-ffed1b1b8572",
      "name": "获取音频文件",
      "type": "n8n-nodes-base.slack",
      "position": [
        528,
        16
      ],
      "webhookId": "f3c959b8-80b6-43cd-8881-774685e86e06",
      "parameters": {
        "fileId": "={{ $json.files[0].id }}",
        "resource": "file",
        "operation": "get"
      },
      "credentials": {
        "slackApi": {
          "id": "r8tdAw7UpbSrIbTT",
          "name": "N8N Slack Bot"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "afa71e24-0ea2-464b-bb8d-c6af2c09cfab",
      "name": "获取图片文件",
      "type": "n8n-nodes-base.slack",
      "position": [
        528,
        256
      ],
      "webhookId": "f3c959b8-80b6-43cd-8881-774685e86e06",
      "parameters": {
        "fileId": "={{ $json.files[0].id }}",
        "resource": "file",
        "operation": "get"
      },
      "credentials": {
        "slackApi": {
          "id": "r8tdAw7UpbSrIbTT",
          "name": "N8N Slack Bot"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ab84c6ee-0704-4846-85ae-c94d3b69d12b",
      "name": "获取视频文件",
      "type": "n8n-nodes-base.slack",
      "position": [
        528,
        496
      ],
      "webhookId": "f3c959b8-80b6-43cd-8881-774685e86e06",
      "parameters": {
        "fileId": "={{ $json.files[0].id }}",
        "resource": "file",
        "operation": "get"
      },
      "credentials": {
        "slackApi": {
          "id": "r8tdAw7UpbSrIbTT",
          "name": "N8N Slack Bot"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1753c69a-cf19-41d9-b65a-e75d1dd685c0",
      "name": "为 AI 代理设置\"用户输入\"",
      "type": "n8n-nodes-base.set",
      "position": [
        1424,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4f68c522-dd1e-45dc-ab39-f5b640bfe274",
              "name": "User Input",
              "type": "string",
              "value": "={{$json.text     || $json.message?.text     || $json.content     || $json[\"data\"]     || $json.result     || $json.transcription     || \"\"}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6c042ce2-b81b-4765-9f11-e16f5cb33755",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Set \"User Input\" for AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get Audio File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get a Picture File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Video File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze video": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Analyze an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "Analyze video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Slack Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Audio File": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video File": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze an image": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get a Picture File": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set \"User Input\" for AI Agent": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量34
分类2
节点类型13
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流