- 开始使用
- 构建
- HTTP 请求
- 连接器节点的工作方式
- 创建连接
- Sales and customer relationships
- Customer support and help desk
- Messaging and meetings
- 电子邮件
- Marketing
- Social media
- Files, documents, and e-signature
- Projects, collaboration, and code
- People and recruiting
- Finance and commerce
- AI models and agents
- Speech, vision, and language
- Data and location
- Cloud, identity, and security
- 部署并运行
- 示例
- 参考
您的第一个工作流
构建包含两个 API 调用、一个做出决策的 AI 智能体以及两个分支的订单接收工作流,然后使用编码智能体或画布上进行测试并部署。
在本教程中,您将构建什么是 Maestro 自动化?描述。对于每个新订单,工作流会检查库存和客户信用,让 AI 智能体决定是否接受订单,然后创建订单或通知销售代表。
整个教程大约需要 15 分钟。库存和信用检查将调用 dummyjson.com,免费的示例 API,因此您不需要其他应用程序的帐户或 API 密钥。最后两个步骤是代表客户关系管理 (CRM) 和 Slack 的脚本,因此工作流无需连接到这些应用程序即可运行。上面的屏幕截图显示了通知销售代表为 Slack 连接器,这就是真实工作流中的情况。
您可以通过两种方式构建工作流。请选择其中一个,页面的其余部分将遵循您的选择:
- 使用编码智能体:描述工作流,智能体为您构建工作流。
- 在画布上手动:自行添加和设置每个节点。
开始之前
- UiPath 帐户。“注册”介绍了如何创建注册。
- 具有 UiPath CLI 和技能的编码智能体。设置编码智能体,只需三个步骤即可使其准备就绪。
- 带有 UiPath Maestro 扩展的 VS Code,用于在画布上查看工作流。“在 VS Code 中构建”介绍了如何安装该程序。
1. 构建工作流
-
为项目创建一个空文件夹,然后在 VS Code 中打开。
-
在该文件夹中启动编码智能体。例如,对于 Claude Code,请在 VS Code 终端中运行
claude。 -
粘贴此提示词:
Create a Maestro Automate project named OrderIntake with a workflow that does exactly this. Don't add, remove, or rename nodes. 1. Rename the Manual trigger to "New order", set its ID to newOrder, and add two input arguments: productId (number) and customerId (string). 2. Add an HTTP Request node "Check stock" (ID checkStock), GET, with the URL as an expression: "https://dummyjson.com/products/" + $vars.newOrder.output.productId 3. Add an HTTP Request node "Check credit" (ID checkCredit), GET https://dummyjson.com/users/1 4. Add an Autonomous Agent node "Review order" (ID reviewOrder) with the default model. System prompt: "You review new customer orders. Accept an order only if the product has stock greater than 0 and the customer record is present. Otherwise reject it. Always give a short reason." Give the agent the response body of Check stock as the product, and the response body of Check credit as the customer. Output variables: accepted (boolean) and reason (string). 5. Add a Decision node "Accepted?" (ID accepted) with the condition $vars.reviewOrder.output.accepted 6. On True, add a Script node "Create order in CRM" (ID createOrderInCrm): return { orderCreated: true, productId: $vars.newOrder.output.productId }; 7. On False, add a Script node "Notify sales rep" (ID notifySalesRep): return { notified: true, reason: $vars.reviewOrder.output.reason }; The order is: New order → Check stock → Check credit → Review order → Accepted? → True: Create order in CRM, False: Notify sales rep. dummyjson.com is a public sample API, so these URLs work as they are. Then validate the workflow and fix any problems.Create a Maestro Automate project named OrderIntake with a workflow that does exactly this. Don't add, remove, or rename nodes. 1. Rename the Manual trigger to "New order", set its ID to newOrder, and add two input arguments: productId (number) and customerId (string). 2. Add an HTTP Request node "Check stock" (ID checkStock), GET, with the URL as an expression: "https://dummyjson.com/products/" + $vars.newOrder.output.productId 3. Add an HTTP Request node "Check credit" (ID checkCredit), GET https://dummyjson.com/users/1 4. Add an Autonomous Agent node "Review order" (ID reviewOrder) with the default model. System prompt: "You review new customer orders. Accept an order only if the product has stock greater than 0 and the customer record is present. Otherwise reject it. Always give a short reason." Give the agent the response body of Check stock as the product, and the response body of Check credit as the customer. Output variables: accepted (boolean) and reason (string). 5. Add a Decision node "Accepted?" (ID accepted) with the condition $vars.reviewOrder.output.accepted 6. On True, add a Script node "Create order in CRM" (ID createOrderInCrm): return { orderCreated: true, productId: $vars.newOrder.output.productId }; 7. On False, add a Script node "Notify sales rep" (ID notifySalesRep): return { notified: true, reason: $vars.reviewOrder.output.reason }; The order is: New order → Check stock → Check credit → Review order → Accepted? → True: Create order in CRM, False: Notify sales rep. dummyjson.com is a public sample API, so these URLs work as they are. Then validate the workflow and fix any problems.智能体创建项目,添加节点并验证工作流。它可能会在此过程中询问您问题。根据提示回答问题。
-
智能体运行完成后,从资源管理器中打开
.flow文件。它将在流画布上打开。 -
查看结果:
- 画布与此页面顶部的工作流相符。
- 没有节点显示警告图标,并且“问题”面板为空。
- 底部工具栏会显示Maestro Automate。如果显示“Maestro Orchestrate” ,请将其选中,然后选择“Maestro Automate” 。
如果某些内容不匹配,请告诉智能体不同之处,例如:“缺少检查信用”。将其添加到“查看库存”和“审核订单”之间。
结果:您的画布与此页面顶部的工作流相符。
创建项目
在您构建的任意位置创建一个 Maestro Automate 项目:
| 构建的位置 | 如何创建项目 |
|---|---|
| VS 代码 | 使用活动栏中的UiPath图标打开 UiPath Maestro 视图。选择“新建” ,然后在“新建项目”列表中选择“Maestro Automate” 。 |
| Studio Web | 选择“新建”旁边的箭头,然后选择“Maestro Automate”下的“流” 。 |
| Studio 桌面 | 打开一个解决方案。在资源管理器中,选择“添加项目” ,然后选择“添加到解决方案”下的“Maestro Automate” 。 |
项目在流画布上打开,项目上已包含“手动”触发器。底部工具栏将Maestro Automate显示为构建模式。
每个工具还为 Maestro Orchestrate 提供了一个项目:VS Code 中的Maestro Orchestrate 、Studio Web 中的Maestro Orchestrate下的流以及 Studio Desktop 中的Maestro Flow 。确保选择适用于Maestro Automate的许可证。
从触发器开始
构建工作流时,首先要回答的问题是工作流如何启动。触发器是指每次运行的开始步骤。此工作流按需启动,这是最简单的测试方法,因此它使用画布上已有的“手动”触发器。
- 双击“手动”触发器的名称,然后输入“新订单” 。可以以相同的方式重命名每个节点。
- 在“高级”选项卡上,将其 ID 设置为
newOrder。后续步骤中的表达式将使用此 ID。 - 在参数选项卡上,选择选择添加输入参数两次,以添加订单详细信息:
productId,属于数字类型。customerId,类型为字符串。
结果:工作流在每次启动时接受产品 ID 和客户 ID。
查看库存
有关订单的第一个问题是该产品是否有库存。HTTP 请求节点通过调用其 API(应用程序用于交换数据的接口)来询问另一个系统。
-
选择新订单的传出句柄上的+ ,搜索“ HTTP 请求 ” ,然后选中。
-
将节点重命名为“检查库存” ,并在“高级”选项卡上将其 ID 设置为
checkStock。 -
在参数选项卡上,将身份验证设置为手动身份验证,将方法设置为
GET。 -
将“URL”字段切换到表达式模式,以便在开头显示
=,然后输入:"https://dummyjson.com/products/" + $vars.newOrder.output.productId"https://dummyjson.com/products/" + $vars.newOrder.output.productId该网址用引号括起,
$vars.newOrder.output.productId将触发器中的产品 ID 添加到其末尾。您可以使用{ } 插入添加$vars部分,而不必输入。如果编辑器建议使用
productId,请使用Enter接受建议,而不要输入名称,否则需要输入两次名称。
$vars保存较早节点的输出。表达式将其读取为$vars.<node ID>.output 。表达式模式下的字段是 JavaScript,因此文本(如网址)会用引号括起。变量和数据流描述了数据如何在节点之间移动。
测试目前为止拥有的内容
- 在画布底部的工具栏中选择“运行调试” (▸),为“产品 ID”输入
1,为“客户 ID”输入c-100,然后开始运行。在 Studio Web 中,单击保存并调试将其启动。 - 在画布下方面板中的“变量”选项卡上,展开“检查库存” 。其输出显示
code设置为200,以及body中的产品数据,包括其stock。
如果检查库存失败,请在“执行追踪”中选择它以查看错误。最常见的原因是 URL 表达式中没有给网址加上引号。
结果:工作流已从 API 读取实际数据。您可以在添加每个节点后,以相同的方式再次运行它。
查看客户的信用
- 选择“检查库存”的传出句柄上的+ ,添加另一个HTTP 请求,将其重命名为“检查信用” ,然后将其 ID 设置为
checkCredit。 - 将“方法”设置为
GET,并在“URL”中输入https://dummyjson.com/users/1。
在本教程中,示例用户记录代表客户的信用记录。
让智能体做出决定
智能体是您提供指令和工具的 AI 模型。它不会遵循固定规则,而是读取数据并做出决策。
-
选择检查信用的传出句柄上的+ ,打开“智能体”类别,然后选择“自主智能体” 。
-
将节点重命名为“审核订单” ,并将其 ID 设置为
reviewOrder。 -
将“模型”设置为默认模型。
-
在系统提示中,输入智能体指令:
You review new customer orders. Accept an order only if the product has stock greater than 0 and the customer record is present. Otherwise reject it. Always give a short reason.You review new customer orders. Accept an order only if the product has stock greater than 0 and the customer record is present. Otherwise reject it. Always give a short reason. -
在用户提示中,输入
Product:,使用{ } 插入添加$vars.checkStock.output.body,然后输入Customer:并以相同的方式添加$vars.checkCredit.output.body。每个插入的值在提示词中显示为芯片。 -
在“输出”下,选择“添加输出变量”两次:
- Boolean 类型的
accepted。 reason,类型为字符串。
- Boolean 类型的
结果:智能体返回下一个节点可以读取的accepted和reason 。
决策的分支
-
选择审核订单的传出句柄上的+ ,打开控制类别,然后选择决策。重命名是否接受?并将其 ID 设置为
accepted。 -
在条件中,输入
$vars.reviewOrder.output.accepted。决策节点获取句柄True和False 。 -
在“True”句柄上,添加一个名为在 CRM 中创建订单、ID 为
createOrderInCrm脚本节点,然后输入以下代码:return { orderCreated: true, productId: $vars.newOrder.output.productId };return { orderCreated: true, productId: $vars.newOrder.output.productId }; -
在“False”句柄上,添加一个名为通知销售代表 的脚本节点,ID 为
notifySalesRep,然后输入以下代码:return { notified: true, reason: $vars.reviewOrder.output.reason };return { notified: true, reason: $vars.reviewOrder.output.reason };
在真实的工作流中, “在 CRM 中创建订单”和“通知销售代表”将是连接器,是与 CRM 和 Slack 等应用程序的现成连接。连接器列出了每个连接器。
结果:您的画布与此页面顶部的工作流相符,并且没有节点显示警告图标。
2. 进行测试
测试使用示例数据在画布上运行工作流。
- 询问智能体:“调试产品 ID 为 1、客户 ID 为 c-100 的工作流。”
- 智能体运行工作流并报告结果。每个节点都应完成,并且运行应为True路径到CRM 中的“创建订单” ,因为示例产品有库存。
- 在报告中查看智能体的决策:
accepted为true,并简要说明原因,例如“产品有库存,并且存在客户记录”。
要自行查看运行情况,请选择画布底部工具栏中的“运行调试”(▸),然后在画布选项卡上按照“手动”中的步骤操作。
-
在画布底部工具栏中选择“运行调试”。对话框询问触发器的输入值。
-
在“产品 ID”中输入
1,在“客户 ID”中输入c-100,然后开始运行。在 Studio Web 中,对话框为调试配置,您可以使用保存并调试开始运行。在 Studio Web 中,系统会保存这些值,以供下次运行使用。
-
等待运行完成。每个节点都显示绿色复选标记,并且运行采用“True”路径到“在 CRM 中创建订单” ,因为示例产品有库存。
-
在“执行追踪”中,展开“审核顺序” ,然后选择“智能体输出” 。“结果”选项卡显示了智能体的决策
accepted: true及其原因。
选择审核订单本身,以查看智能体收到的数据: “检查库存”中的完整产品记录和“ 检查信用”中的用户记录。
如果节点发生故障,请在“执行追踪”中选择该节点以查看错误。调试基础知识详细介绍了调试工具。
结果:工作流从触发器到分支运行,智能体的决策显示在追踪记录中。
3. 部署并运行
到目前为止,此工作流仅作为测试运行。部署后,它成为无需画布即可运行的实时工作流。每次运行都计入计划的每月运行次数。
-
询问智能体:
Deploy this workflow, then start one run with productId 1 and customerId c-100, and tell me where I can see the run.Deploy this workflow, then start one run with productId 1 and customerId c-100, and tell me where I can see the run.智能体打包项目,进行部署,并使用这些输入开始运行。
-
在运行有时间完成时,询问:“运行是否完成?告诉我它的最终状态以及它采用的分支。”
智能体报告运行成功,并采用了True路径,前往在 CRM 中创建订单。
- 部署工作流:
- Studio Web:选择“部署” ,然后等待“部署成功” 。
- VS Code 或 Studio 桌面版:按照“部署工作流”进行操作。
- 打开“开始”作业:
- Studio Web:在成功画面上,选择“开始作业” 。
- VS Code 或 Studio Desktop:在 Orchestrator 中,选择“解决方案” ,选择您的部署文件夹,然后选择您的解决方案。在其面板中选择“开始作业” 。
- 在“输入”下,输入
1作为“产品 ID” ,输入c-100作为“客户 ID” ,然后选择“开始” 。 - 要关注运行,请选择产品启动器,即页面左上方的网格图标,然后选择Maestro 。
- 选择流程实例,然后选择您的工作流名称。
- 选择该运行,以在画布上查看该运行执行的每个步骤。
结果:您的工作流已部署,其首次运行采取了“True”路径,前往“在 CRM 中创建订单” 。
您学到了什么
- 触发器:每个工作流都从一个触发器开始,输入参数包含每次运行开始的数据。
- HTTP 请求:节点调用另一个系统的 API,并将响应提供给后续节点。
- 表达式:
$vars.<node ID>.output读取上一个节点的输出。 - 智能体:智能体读取数据,做出决策,然后返回您定义的输出变量。
- 决策:一个条件沿两条路径之一发送每次运行。
- 测试:调试运行显示每个节点接收和返回的内容。
- 编码智能体:智能体可以根据描述构建相同的工作流,您可以在画布上进行查看。
- 正在部署:部署的工作流在没有画布的情况下运行,并且每次运行都会列出其状态。