# Script task

> ![script task icon](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-script-task-icon-587071-2866390b.webp)

![script task icon](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-script-task-icon-587071-2866390b.webp)

The Script Task in Maestro allows you to execute inline JavaScript to manipulate data, enrich payloads, apply conditional logic, or transform input before passing it to the next component in the process. This is particularly useful when you want to prepare data for Schema Queues, API calls, agents, or storage systems.

**Implementation >** Type: Run inline script.

![script task configuration](https://dev-assets.cms.uipath.com/assets/images/maestro/script_task_config-be0c482e.png)

## When to use Script tasks

Use a Script task when:

* You need to transform or restructure incoming data.
* You want to validate fields or reject invalid input.
* You need to combine multiple inputs into a single object.
* You want to filter, clean, or reformat data before forwarding.

  :::note
  Maestro currently supports JavaScript only inside the expression editor.
  :::

## Setting up a Script task in Maestro

1. Add a **Script task** node from the process toolbar (drag it onto the canvas or double-select it to insert it at the center).
2. Add input arguments under the **Inputs** section in the right-hand panel.

The input arguments can be literal values, context variables, or previous node outputs (e.g., `vars.inArg`).
3. Write your script in the editor:
   * Select the **Script** input field, then expand into the full editor view.
   * JavaScript expressions must `return` an object or value, as in this example:
     ```
     return {
       param1: inputString,
       param2: "staticValue"
     };
     ```
4. Map outputs from the return object into Maestro variables using the **Outputs** section.

**Result:** The script is configured and its outputs are available as Maestro variables for use in subsequent process nodes.

## Testing script logic

You can test expressions inline by selecting the **fx** icon to open the **JS Function Expression editor** The editor includes:

* A **test input panel** where you can paste sample inputs.
* A real-time **Expression output** panel to preview what your return object will look like.

Runtime errors (e.g., `JSON.parse` failures) will be shown to help you debug.
  ![JS function expression editor](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-js-function-expression-editor-587296-417d12f8.webp)

## Available actions for Script tasks

The **Action** dropdown in a Script task allows you to define the type of external execution the process should call. Each option maps to a specific UiPath capability or integration method. Below is a brief overview of each option:

* **None**

   No implementation is configured for the Script task.
* **Create action app task**

   Creates a task in an Action App for user interaction, without waiting for task completion.
* **Start and wait for RPA workflow**

   Starts a deployed RPA workflow (e.g., UiPath Studio project) and waits for it to complete before continuing.
* **Start and wait for agent**

   Starts a UiPath agent (a reusable logic block) and waits for it to finish execution.
* **Start and wait for external agent**

   Triggers an agent hosted outside UiPath, such as CrewAI, Salesforce, or ServiceNow, and waits for the result.
* **Start and wait for API workflow**

   Executes an API-based workflow and waits for a response.
* **Start agentic process**

   Starts a process based on agentic design (modular logic), without waiting for it to finish.
* **Start and wait for agentic process**

   Starts an agentic process and pauses until it completes execution.
* **Execute business rule [Preview]**

   Evaluates a business rule and uses the outcome in the process (currently in preview).
* **Create queue item**

   Adds a new item to a UiPath Queue for asynchronous processing, without waiting for result.
* **Create and wait for queue item**

   Adds an item to a Queue and waits until it is processed before moving forward.
* **Execute connector activity**

   Runs a preconfigured Integration Service connector activity (e.g., Salesforce or Slack).
* **Wait for connector event**

   Pauses the process until a specific event is received from a connector (e.g., form submission or external trigger).
* **Execute script**

   Runs a short script (JavaScript or similar) during the process for lightweight logic or transformation.

  ![Available actions dropdown in the Script task Properties panel](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-service-task-properties-actions-588752-2a9937e7.webp)

The **Add variable** dialog lets you define a new variable by specifying its name, type (such as String, Number, Boolean, etc.), and optional default value. Once saved, the variable becomes available for use in inputs, outputs, or expressions within the Script task.

  ![Add Variable dialog](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-variable-588799-b9342575.webp)

## Autopilot support for Script tasks

The **JS Function Expression editor** includes Autopilot for Maestro assistance that helps you write and refine JavaScript expressions directly in Script tasks. You can describe the logic you need in plain language, and Autopilot generates a function that you can review, edit, and test in place. The editor shows a live preview of the expression output and lets you insert variables from your workflow, so you can build and validate custom logic without leaving the canvas.

![autopilot for script tasks](https://dev-assets.cms.uipath.com/assets/images/maestro/autopilot_maestro_script_task-88d43ea9.webp)

For more information about tasks, visit [Tasks in BPMN modeling](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/tasks-in-bpmn-modeling).

:::note
Access to agents integration and API workflows depends on the cloud offering you use. For details, refer to [Maestro feature availability](https://docs.uipath.com/automation-ops/automation-cloud/latest/user-guide/maestro-feature-availability).
:::
