# Your first workflow

> Build an order intake workflow with two API calls, an AI agent that decides, and two branches, then test it and deploy it, with a coding agent or on the canvas.

In this tutorial, you build the order intake workflow that [What is Maestro Automate?](what-is-maestro-automate.md) describes. For every new order, the workflow checks the stock and the customer's credit, lets an AI agent decide whether to accept the order, and then either creates the order or notifies a sales representative.

![The order intake workflow you build: New order, Check stock, Check credit, Review order, and Accepted?, which branches to Create order in CRM and Notify sales rep. The screenshot shows Notify sales rep as a Slack connector.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/flow-get-order-example-automate-1f14df06.webp)

The tutorial takes about 15 minutes. The stock and credit checks call dummyjson.com, a free sample API, so you don't need an account or an API key for another app. The last two steps are scripts that stand in for the customer relationship management (CRM) and Slack, so the workflow runs without connections to those apps. The screenshot above shows **Notify sales rep** as a Slack connector, which is what it would be in a real workflow.

You can build the workflow in two ways. Pick one, and the rest of the page follows your choice:

- **With a coding agent:** describe the workflow, and the agent builds it for you.
- **Manually on the canvas:** add and set up each node yourself.

## Before you start

:::::tabs{groupId="how-you-build"}

::::tab[With a coding agent]{default}
- A UiPath account. [Sign up](sign-up.md) describes how to create one.
- A coding agent with the UiPath CLI and skills. [Set up your coding agent](set-up-your-coding-agent.md) gets it ready in three steps.
- VS Code with the UiPath Maestro extension, to see the workflow on the canvas. [Build in VS Code](build-in-vs-code.md) describes how to install it.
::::

::::tab[Manually on the canvas]
- A UiPath account. [Sign up](sign-up.md) describes how to create one.
- VS Code, Studio Web, or Studio Desktop. Studio Web runs in your browser and needs no installation. [Where to build](where-to-build.md) compares them.
::::

:::::

## 1. Build the workflow

:::::tabs{groupId="how-you-build"}

::::tab[With a coding agent]{default}
1. Create an empty folder for the project, and open it in VS Code.
2. Start your coding agent in that folder. For example, for Claude Code, run `claude` in the VS Code terminal.
3. Paste this prompt:

   ```text
   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.
   ```

   The agent creates the project, adds the nodes, and validates the workflow. It may ask you questions along the way. Answer them from the prompt.

4. When the agent finishes, open the `.flow` file from the Explorer. It opens on the Flow canvas.
5. Check the result:
   - The canvas matches the workflow at the top of this page.
   - No node shows a warning icon, and the **Problems** panel is empty.
   - The bottom toolbar shows **Maestro Automate**. If it shows **Maestro Orchestrate**, select it and choose **Maestro Automate**.

   ![VS Code with the order intake workflow that the coding agent built. The canvas shows New order, Check stock, Check credit, Review order, and Accepted?, which branches to Create order in CRM and Notify sales rep. The bottom toolbar shows Maestro Automate, the Variables panel lists each node with its ID, and the terminal below shows the agent's summary of a successful test run.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/flow-vscode-automate-c925ebd8.webp)

If something doesn't match, tell the agent what's different, for example: "Check credit is missing. Add it between Check stock and Review order."

**Result:** your canvas matches the workflow at the top of this page.
::::

::::tab[Manually on the canvas]
**Create the project**

Create a Maestro Automate project wherever you build:

| Where you build | How to create the project |
|---|---|
| VS Code | Open the UiPath Maestro view with the **UiPath** icon in the Activity Bar. Select **Create New**, then select **Maestro Automate** in the **New Project** list. |
| Studio Web | Select the arrow next to **Create New**, then select **Flow** under **Maestro Automate**. |
| Studio Desktop | Open a solution. In the **Explorer**, select **Add a project**, then select **Maestro Automate** under **Add to Solution**. |

The project opens on the Flow canvas, with a **Manual trigger** already on it. The bottom toolbar shows **Maestro Automate** as the build mode.

:::note
Each tool also offers a project for Maestro Orchestrate: **Maestro Orchestrate** in VS Code, **Flow** under **Maestro Orchestrate** in Studio Web, and **Maestro Flow** in Studio Desktop. Make sure you select the one for **Maestro Automate**.
:::

**Start with a trigger**

When building a workflow, the first question to answer is how it starts. A trigger is the step that starts every run. This workflow starts on demand, which is the easiest way to test it, so it uses the **Manual trigger** that is already on the canvas.

1. Double-click the name of the **Manual trigger** and type **New order**. You rename every node the same way.
2. On the **Advanced** tab, set its ID to `newOrder`. Expressions in later steps use this ID.
3. On the **Parameters** tab, select **Add input argument** twice to add the order's details:
   - `productId`, of type number.
   - `customerId`, of type string.

**Result:** the workflow accepts a product ID and a customer ID each time it starts.

**Check the stock**

The first question about an order is whether the product is in stock. An HTTP Request node asks another system by calling its API, the interface that apps use to exchange data.

1. Select the **+** on the outgoing handle of **New order**, search for **HTTP Request**, and select it.

   ![The Add node panel opened from the trigger, listing the categories Agent, Connector, Data, Document, Human, Control, Tool, and Wait for event, with Maestro Automate shown as the build mode in the bottom toolbar.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/new-project-flow-automate-eca2c861.webp)

2. Rename the node **Check stock**, and on the **Advanced** tab set its ID to `checkStock`.
3. On the **Parameters** tab, leave **Authentication** set to **Manual authentication** and **Method** set to `GET`.
4. Switch the **URL** field to expression mode, so that it shows `=` at the start, and enter:

   ```javascript
   "https://dummyjson.com/products/" + $vars.newOrder.output.productId
   ```

   The web address is in quotes, and `$vars.newOrder.output.productId` adds the product ID from the trigger to the end of it. You can add the `$vars` part with **{ } Insert** instead of typing it.

   If the editor suggests `productId` as you type, accept the suggestion with `Enter` instead of typing the name, or it's entered twice.

![The Check stock properties panel with Authentication set to Manual authentication, Method set to GET, and the URL expression that joins the dummyjson.com address with the product ID from New order.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/check-stock-properties-automate-a2532ee2.webp)

:::note
`$vars` holds the output of earlier nodes. An expression reads it as `$vars.<node ID>.output`. A field in expression mode is JavaScript, so text such as a web address goes in quotes. [Variables and data flow](variables-and-data-flow.md) describes how data moves between nodes.
:::

**Test what you have so far**

1. Select **Run Debug** (▶) in the bottom toolbar of the canvas, enter `1` for **productId** and `c-100` for **customerId**, then start the run. In Studio Web, start it with **Save & Debug**.
2. In the panel below the canvas, on the **Variables** tab, expand **Check stock**. Its **Outputs** show `code` set to `200`, and the product's data in `body`, including its `stock`.

If **Check stock** fails, select it in the **Execution trace** to see the error. The most common cause is a URL expression without quotes around the web address.

**Result:** the workflow already reads real data from an API. You can run it again the same way after each node you add.

**Check the customer's credit**

1. Select the **+** on the outgoing handle of **Check stock**, add another **HTTP Request**, rename it **Check credit**, and set its ID to `checkCredit`.
2. Leave **Method** set to `GET`, and in **URL**, enter `https://dummyjson.com/users/1`.

In this tutorial, the sample user record stands in for the customer's credit record.

**Let an agent decide**

An agent is an AI model that you give instructions and tools. Instead of following fixed rules, it reads the data and decides.

1. Select the **+** on the outgoing handle of **Check credit**, open the **Agent** category, and select **Autonomous agent**.
2. Rename the node **Review order**, and set its ID to `reviewOrder`.
3. Leave **Model** set to the default model.
4. In **System prompt**, enter the agent's instructions:

   ```text
   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.
   ```

5. In **User prompt**, enter `Product: `, add `$vars.checkStock.output.body` with **{ } Insert**, then enter ` Customer: ` and add `$vars.checkCredit.output.body` the same way. Each inserted value appears as a chip in the prompt.
6. Under **Outputs**, select **Add output variable** twice:
   - `accepted`, of type boolean.
   - `reason`, of type string.

![The Review order properties panel with the system prompt, the user prompt with the inserted Check stock and Check credit outputs, and the accepted and reason output variables.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/review-order-properties-automate-99a24e94.webp)

**Result:** the agent returns `accepted` and `reason`, which the next nodes can read.

**Branch on the decision**

1. Select the **+** on the outgoing handle of **Review order**, open the **Control** category, and select **Decision**. Rename it **Accepted?** and set its ID to `accepted`.
2. In the condition, enter `$vars.reviewOrder.output.accepted`. The Decision node gets a **True** and a **False** handle.
3. On the **True** handle, add a **Script** node named **Create order in CRM**, with the ID `createOrderInCrm`, and enter this code:

   ```javascript
   return { orderCreated: true, productId: $vars.newOrder.output.productId };
   ```

4. On the **False** handle, add a **Script** node named **Notify sales rep**, with the ID `notifySalesRep`, and enter this code:

   ```javascript
   return { notified: true, reason: $vars.reviewOrder.output.reason };
   ```

:::tip
In a real workflow, **Create order in CRM** and **Notify sales rep** would be connectors, ready-made connections to apps such as your CRM and Slack. [Connector](integration-nodes.md) lists every connector.
:::

**Result:** your canvas matches the workflow at the top of this page, and no node shows a warning icon.
::::

:::::

## 2. Test it

Testing runs the workflow on the canvas with sample data.

:::::tabs{groupId="how-you-build"}

::::tab[With a coding agent]{default}
1. Ask the agent: "Debug the workflow with productId 1 and customerId c-100."
2. The agent runs the workflow and reports the result. Each node should complete, and the run should take the **True** path to **Create order in CRM**, because the sample product is in stock.
3. Check the agent's decision in the report: `accepted` is `true`, with a short reason, such as "Product is in stock and customer record is present."

To see the run yourself, select **Run Debug** (▶) in the bottom toolbar of the canvas instead, and follow the steps on the **Manually on the canvas** tab.
::::

::::tab[Manually on the canvas]
1. Select **Run Debug** (▶) in the bottom toolbar of the canvas. A dialog asks for the values of the trigger's inputs.
2. Enter `1` for **productId** and `c-100` for **customerId**, then start the run. In Studio Web, the dialog is **Debug configuration**, and you start the run with **Save & Debug**.

   ![The Debug configuration dialog on the Entrypoint arguments tab, with productId set to 1 and customerId set to c-100, the Deploy resources before debugging and Show before debugging switches turned on, and the Save & Debug button.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/debug-configuration-entrypoint-arguments-automate-b6d0c0d1.webp)

   In Studio Web, the values are saved for the next run.

3. Wait for the run to finish. Each node shows a green check mark, and the run takes the **True** path to **Create order in CRM**, because the sample product is in stock.
4. In the **Execution trace**, expand **Review order** and select **Agent output**. The **Result** tab shows the agent's decision, `accepted: true`, and its reason.

![A completed debug run of the order intake workflow. The execution trace lists every node, with Review order expanded into Agent run, LLM call, Governance evaluation, Model run, and Agent output, and the Result tab shows accepted set to true with the agent's reason.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/debug-run-ooutput-automate-d4baf176.webp)

Select **Review order** itself to see the data that the agent received: the full product record from **Check stock** and the user record from **Check credit**.

If a node fails, select it in the **Execution trace** to see the error. [Debugging basics](debugging-basics.md) covers the debug tools in detail.

**Result:** your workflow runs from the trigger to the branch, and the agent's decision is visible in the trace.
::::

:::::

## 3. Deploy and run it

So far, the workflow has only run as a test. Deploying it makes it a live workflow that runs without the canvas. Each run counts toward your plan's monthly runs.

:::::tabs{groupId="how-you-build"}

::::tab[With a coding agent]{default}
1. Ask the agent:

   ```text
   Deploy this workflow, then start one run with productId 1 and customerId c-100, and tell me where I can see the run.
   ```

   The agent packages the project, deploys it, and starts a run with those inputs.

2. When the run has had time to finish, ask: "Is the run finished? Tell me its final status and which branch it took."

The agent reports that the run is **Successful** and took the **True** path to **Create order in CRM**.
::::

::::tab[Manually on the canvas]
1. Deploy the workflow:
   - **Studio Web:** select **Deploy**, and wait for **Deployment successful**.
   - **VS Code or Studio Desktop:** follow [Deploy a workflow](deploy-a-workflow.md#deploy).
2. Open **Start job**:
   - **Studio Web:** on the success screen, select **Start job**.
   - **VS Code or Studio Desktop:** in Orchestrator, select **Solutions**, select the folder you deployed to, then select your solution. In its panel, select **Start job**.
3. Under **Input**, enter `1` for **productId** and `c-100` for **customerId**, then select **Start**.
4. To follow the run, select the product launcher, the grid icon at the top left of the page, then select **Maestro**.
5. Select **Flow instances**, then the name of your workflow.
6. Select the run to see each step it took on the canvas.
::::

:::::

**Result:** your workflow is deployed, and its first run took the **True** path to **Create order in CRM**.

## What you learned

- **Triggers:** every workflow starts with one, and input arguments carry the data that each run starts with.
- **HTTP requests:** a node calls another system's API and makes the response available to later nodes.
- **Expressions:** `$vars.<node ID>.output` reads the output of an earlier node.
- **Agents:** an agent reads data, decides, and returns the output variables you define.
- **Decisions:** one condition sends each run down one of two paths.
- **Testing:** a debug run shows what every node received and returned.
- **Coding agents:** an agent can build the same workflow from a description, and you check it on the canvas.
- **Deploying:** a deployed workflow runs without the canvas, and each run is listed with its status.

## Next steps

- [Evaluations](evaluations.md): check the agent's decisions against a set of sample orders. The **Add to evaluations** button on a trace entry is a quick way to start.
- [Deploy a workflow](deploy-a-workflow.md): make the workflow run without you.
- [Connector](integration-nodes.md): replace the two scripts with real apps.
- [Node reference](node-reference.md): every node and how to configure it.
- [Community](community.md): ask questions and share workflows with other builders.
