Skip to content

Slack 触发器节点#

¥Slack Trigger node

使用 Slack 触发器节点响应 Slack 中的事件,并将 Slack 与其他应用集成。n8n 内置支持 Slack 的多种事件,包括新消息、反应和新通道。

¥Use the Slack Trigger node to respond to events in Slack and integrate Slack with other applications. n8n has built-in support for a wide range of Slack events, including new messages, reactions, and new channels.

在此页面,你可以找到 Slack 触发器节点可以响应的事件列表以及更多资源的链接。

¥On this page, you'll find a list of events the Slack Trigger node can respond to and links to more resources.

Credentials

你可以在 此处 中找到此节点的身份验证信息。

¥You can find authentication information for this node here.

Examples and templates

有关使用示例和模板以帮助你入门,请参阅 n8n 的 Slack 集成 页面。

¥For usage examples and templates to help you get started, refer to n8n's Slack integrations page.

事件#

¥Events

  • 任何事件:此节点会在 Slack 中发生任何事件时触发。

¥Any Event: The node triggers on any event in Slack.

  • 机器人/应用提及:当你的机器人或应用在所在通道中处于 mentioned 状态时,此节点会触发。

¥Bot / App Mention: The node triggers when your bot or app is mentioned in a channel the app is in.

  • 文件已公开:当文件被标记为 已公开 时,此节点会触发。

¥File Made Public: The node triggers when a file is made public.

  • 文件已共享:当应用所在的通道中有文件被标记为 shared 时,此节点会触发。

¥File Shared: The node triggers when a file is shared in a channel the app is in.

  • 通道发布新消息:当应用所在的通道发布新消息时,此节点会触发。

¥New Message Posted to Channel: The node triggers when a new message is posted to a channel the app is in.

  • 新建公共通道:当创建新的 公共通道 时,此节点会触发。

¥New Public Channel Created: The node triggers when a new public channel is created.

  • 新建用户:当 Slack 中添加新用户时,此节点会触发。

¥New User: The node triggers when a new user is added to Slack.

  • 已添加回复:当应用所在的消息中添加了 reaction 时,此节点会触发。

¥Reaction Added: The node triggers when a reaction is added to a message the app is added to.

参数#

¥Parameters

设置好触发事件后,使用剩余参数进一步定义节点的行为:

¥Once you've set the events to trigger on, use the remaining parameters to further define the node's behavior:

  • 监控整个工作区:节点是否应监视工作区中所有通道的选定事件(已启用)或不监视(已禁用,默认)。

¥Watch Whole Workspace: Whether the node should watch for the selected Events in all channels in the workspace (turned on) or not (turned off, default).

Caution

1
This will use one execution for every event in any channel your bot or app is in. Use with caution!
  • 关注通道:选择你的节点应监视所选事件的通道。仅当你未启用“监视整个工作区”时,才会显示此参数。你可以选择一个通道:

¥Channel to Watch: Select the channel your node should watch for the selected Events. This parameter only appears if you don't turn on Watch Whole Workspace. You can select a channel:

  • 从列表获取:此节点使用你的凭据在工作区中查找通道列表,以便你可以选择所需的通道。

    ¥From list: The node uses your credential to look up a list of channels in the workspace so you can select the channel you want.

  • 按 ID:输入要监控的通道的 ID。Slack 会在通道详情底部显示通道 ID,并提供一键复制按钮。

    ¥By ID: Enter the ID of a channel you want to watch. Slack displays the channel ID at the bottom of the channel details with a one-click copy button.

  • 按 URL:输入你要观看的通道 URL,格式为 https://app.slack.com/client/<channel-address>

    ¥By URL: Enter the URL of the channel you want to watch, formatted as https://app.slack.com/client/<channel-address>.

  • 下载文件:是否下载文件并将其用于节点输出(已启用)或不下载(已禁用,默认)。将此参数与“文件公开”和“文件共享”事件一起使用。

¥Download Files: Whether to download files and use them in the node's output (turned on) or not (turned off, default). Use this parameter with the File Made Public and File Shared events.

选项#

¥Options

你可以通过添加选项来进一步细化节点的行为:

¥You can further refine the node's behavior when you Add Options:

  • 解析 ID:是否将 ID 解析为相应的名称并返回(已启用)或不返回(已禁用,默认)。

¥Resolve IDs: Whether to resolve the IDs to their respective names and return them (turned on) or not (turned off, default).

  • 要忽略的用户名或 ID:选择要忽略的事件的用户名,或输入以逗号分隔的编码用户 ID 字符串。从列表中选择,或使用 expression 指定 ID。

¥Usernames or IDs to ignore: Select usernames or enter a comma-separated string of encoded user IDs to ignore events from. Choose from the list, or specify IDs using an expression.

相关资源#

¥Related resources

n8n 提供 Slack 的应用节点。你可以找到节点文档 此处

¥n8n provides an app node for Slack. You can find the node docs here.

在 n8n 网站上查看 示例工作流及相关内容

¥View example workflows and related content on n8n's website.

有关其 API 的详细信息,请联系 Slack 文档

¥Refer to Slack's documentation for details about their API.

必填范围#

¥Required scopes

要使用此节点,你需要在 Slack 中创建一个应用并启用事件订阅。有关更多信息,请参阅 Slack 凭证 | Slack 触发器配置

¥To use this node, you need to create an application in Slack and enable event subscriptions. Refer to Slack credentials | Slack Trigger configuration for more information.

你必须向 Slack 应用添加相应的权限范围,此触发节点才能正常工作。

¥You must add the appropriate scopes to your Slack app for this trigger node to work.

该节点至少需要 conversations.listusers.list 方法的作用域。请参阅 范围 | Slack 凭据 列表,了解更完整的范围列表。

¥The node requires scopes for the conversations.list and users.list methods at minimum. Check out the Scopes | Slack credentials list for a more complete list of scopes.

验证 Webhook#

¥Verify the webhook

在配置 Slack 凭据 时,你可以从 版本 1.106.0 设置 Slack 签名密钥。设置后,Slack 触发节点会自动验证请求是否来自 Slack 并包含可信签名。n8n 建议你进行此设置,以确保你仅处理来自 Slack 的请求。

¥From version 1.106.0, you can set a Slack Signing Secret when configuring your Slack credentials. When set, the Slack trigger node automatically verifies that requests are from Slack and include a trusted signature. n8n recommends setting this to ensure you only process requests sent from Slack.

常见问题#

¥Common issues

以下是 Slack 触发器节点的一些常见错误和问题,以及解决或故障排除步骤。

¥Here are some common errors and issues with the Slack Trigger node and steps to resolve or troubleshoot them.

工作流仅在测试或生产环境中运行#

¥Workflow only works in testing or production

Slack 每个应用只允许注册一个 Webhook。这意味着你无法在不重新配置已注册的 Webhook URL 的情况下,从测试 URL 切换到生产 URL(反之亦然)。

¥Slack only allows you to register a single webhook per app. This means that you can't switch from using the testing URL to the production URL (and vice versa) without reconfiguring the registered webhook URL.

如果你尝试测试一个在生产环境中也处于活动状态的工作流,则可能会遇到问题。Slack 只会将事件发送到两个 Webhook URL 中的一个,因此另一个 URL 将永远不会收到事件通知。

¥You may have trouble with this if you try to test a workflow that's also active in production. Slack will only send events to one of the two webhook URLs, so the other will never receive event notifications.

要解决此问题,你可以在测试时禁用工作流:

¥To work around this, you can disable your workflow when testing:

Halts production traffic

此信息会暂时禁用你的生产工作流以进行测试。你的工作流在停用期间将不再接收生产流量。

¥This temporarily disables your production workflow for testing. Your workflow will no longer receive production traffic while it's deactivated.

  1. 前往你的工作流页面。

¥Go to your workflow page. 2. 切换顶部面板中的“激活”开关以暂时禁用工作流。

¥Toggle the Active switch in the top panel to disable the workflow temporarily. 3. 编辑 Slack 触发器配置 中的请求 URL,使其使用测试 Webhook URL 而不是生产 Webhook URL。

¥Edit the Request URL in your the Slack Trigger configuration to use the testing webhook URL instead of the production webhook URL. 4. 使用测试 Webhook URL 测试你的工作流。

¥Test your workflow using the test webhook URL. 5. 测试完成后,请编辑 Slack 触发器配置 中的“请求 URL”,使其使用生产环境的 Webhook URL 而不是测试环境的 Webhook URL。

¥When you finish testing, edit the Request URL in your the Slack Trigger configuration to use the production webhook URL instead of the testing webhook URL. 6. 切换“非活动”开关以重新启用工作流。生产环境的 webhook URL 应该恢复正常工作。

¥Toggle the Inactive toggle to enable the workflow again. The production webhook URL should resume working.

Token 已过期#

¥Token expired

Slack offers token rotation that you can turn on for bot and user tokens. This makes every tokens expire after 12 hours. While this may be useful for testing, n8n credentials using tokens with this enabled will fail after expiry. If you want to use your Slack credentials in production, this feature must be off.

To check if your Slack app has token rotation turned on, refer to the Slack API Documentation | Token Rotation.

If your app uses token rotation

Please note, if your Slack app uses token rotation, you can't turn it off again. You need to create a new Slack app with token rotation disabled instead.