UiPath Documentation
maestro-automate
latest
false
Maestro Automate 用户指南

构建 Slack 通知工作流

逐步构建一个工作流,该工作流使用脚本节点写入消息,并通过 Slack 连接器将其发布到 Slack 频道。

您构建的内容​

此工作流根据工作流数据撰写动态 Slack 消息并将其发送到频道。该模式适用于任何触发器,例如已计划的作业、传入的 Webhook 或来自其他系统的事件,并可为任何自动化添加实时通知。

开始之前​

  • 您有权在其中添加应用程序的 Slack 工作区。Slack描述了连接器。
  • Slack 连接,用于将 UiPath 登录到您的 Slack 工作区。创建连接介绍了如何创建连接。

使用的节点​

  • 手动触发器:按需启动工作流,稍后将其替换为真实触发器。
  • 脚本:动态编写消息文本。
  • Slack连接器节点:将消息发送到 Slack 频道。

步骤​

提示:

编码智能体设置后,您可以跳过手动步骤。询问:

Build a Maestro Automate workflow that starts manually with a title and a message, composes a Slack message from them, and posts it to a channel through my Slack connection.
Build a Maestro Automate workflow that starts manually with a title and a message, composes a Slack message from them, and posts it to a channel through my Slack connection.

然后在画布上打开工作流,根据以下步骤进行检查并进行测试。“设置编码智能体”描述了相关设置。

1. 新建工作流并添加触发器​

  1. 按照您的第一个工作流所述创建项目。画布将打开,画布上已有“手动触发器” 。
  2. 在触发器的属性面板中,为要包含在消息中的每项数据选择“添加输入参数” ,例如recordName (字符串)和status (字符串)。

2. 撰写消息​

  1. Select the + on the output handle of the Manual Trigger.
  2. Search for Script, and select it.
  3. 在代码编辑器中,使用输入变量编写消息文本:
return `✅ Update: *${$vars.manualTrigger1.output.recordName}* is now ${$vars.manualTrigger1.output.status}.\nTriggered at: ${new Date().toISOString()}`;
return `✅ Update: *${$vars.manualTrigger1.output.recordName}* is now ${$vars.manualTrigger1.output.status}.\nTriggered at: ${new Date().toISOString()}`;
  1. On the Advanced tab of the properties panel, rename the node ID to formatSlackMessage. Later nodes read the message text as $vars.formatSlackMessage.output.

格式可以遵循团队的约定。Slack 支持消息中的基本 Markdown( *bold* 、 _italic_和\n ,用于换行符)。

3. 添加“Slack 发送消息”节点​

  1. Select the + on the output handle of the Script node.
  2. In the Add node panel, open the Connector category, and find the Slack connector.
  3. 选择“发送消息”操作。
  4. 在“属性”面板中:
    • 选择您的 Slack连接。
    • 将“频道”设置为应发送消息的频道 ID 或名称(例如#alerts )。
    • 将消息映射到{{ $vars.formatSlackMessage.output }} 。

4. 测试和调试​

  1. 在画布底部工具栏中选择“运行调试”。
  2. 在触发器对话框中,为recordName和status输入示例值。
  3. 运行测试。

运行完成后,请查看 Slack 频道。如果未出现此消息:

  • 检查 Slack 连接是否仍处于活动状态,如创建连接所述。
  • 检查频道名称。如果出现“未找到频道”错误,以C开头的频道 ID 比显示名称效果更好。
  • 检查执行追踪记录中 Slack 节点的输出,以获取 Slack API 中的任何错误详细信息。

结果​

工作流按需启动,根据触发器输入撰写 Slack 消息,并将其发布到配置的频道。执行追踪中的频道和 Slack 节点的输出均确认成功。

扩展此工作流​

  • 添加条件:在 Slack 节点之前添加一个决策节点,以便仅在满足特定阈值时发送消息(例如,仅在Failed状态下通知)。
  • 替换触发器:将手动触发器替换为集成触发器或计划的触发器,以自动发送通知。
  • 发送到多个频道:添加“切换”节点,以根据优先级或团队将消息路由到不同的频道。

后续步骤​

  • 部署工作流:让工作流在没有您的情况下运行。
  • 指南: 更多待构建的工作流。
  • 社区: 共享您构建的内容,或向其他构建器寻求帮助。

此页面有帮助吗?

连接

需要帮助? 支持(opens in new window)

想要了解详细内容? UiPath Academy(opens in new window)

有问题? UiPath 论坛(opens in new window)

保持更新