- Get started
- Build
- Deploy and run
- Examples
- Reference
Add an AI agent to a workflow
Build a workflow step by step that sends data to an Autonomous agent and branches on its decision with a Decision node.
What you build
A workflow that invokes an AI agent authored on the canvas, passes data to it, and routes the run based on the agent's response: approved, rejected, or failed.
The agent in this guide is an autonomous agent: its model, prompts, tools, and context all live on the node and travel with the workflow. To use an agent that already exists, such as a coded agent, select Agent > Published in the Add node panel instead.
Before you start
- A large language model (LLM) that the agent can use.
Nodes used
- Manual Trigger: starts the workflow on demand while you build
- Autonomous Agent: an AI agent you author on the canvas, returns its output
- Decision: branches the workflow based on the agent's response
- Terminate: ends the workflow on a failure path
Steps
With a coding agent set up, you can skip the manual steps. Ask it:
Build a Maestro Automate workflow that starts manually with a request text, sends it to an Autonomous Agent that returns a decision field set to approved or rejected, and branches on that decision with a Decision node. End the rejected path with a Terminate node.
Build a Maestro Automate workflow that starts manually with a request text, sends it to an Autonomous Agent that returns a decision field set to approved or rejected, and branches on that decision with a Decision node. End the rejected path with a Terminate node.
Then open the workflow on the canvas, check it against the steps below, and test it. Set up your coding agent describes the setup.
1. Create a new workflow and add a trigger
Create a project, as Your first workflow describes. The canvas opens with a Manual Trigger already on it.
A production workflow would use a scheduled or connector-based trigger instead. A Manual Trigger is enough while building.
2. Add an Agent node
- Select the + on the output handle of the Manual Trigger, and open the Agent category of the Add node panel.
- Select the autonomous agent node. The new node connects to the Manual Trigger automatically.
- In the properties panel, author the agent:
- Set the Model, or leave it on your organization's default agent model.
- Write the System prompt, the agent's role and standing instructions. The System prompt and User prompt are required.
- Write the User prompt, the task for this run. Reference workflow data with expressions; for example, the document text to classify:
$vars.manualTrigger1.output.documentText.
3. Return a structured result
By default the agent returns one field, content, holding its response text. To branch cleanly, have the agent return a structured field instead.
- Open the Outputs section on the agent's properties panel (Parameters tab).
- Add an output variable named
decisionwith typestring. - In the System prompt, instruct the agent to set
decisiontoapprovedorrejected.
4. Handle the agent's response
- Select the + on the output handle of the agent node, search for Decision, and select it.
- Set the condition to evaluate the agent's output, for example:
$vars.agent1.output.decision === "approved". - Connect the True branch to the next step in your automation (for example, a notification or data write).
- Connect the False branch to a Terminate node.
- To return the reason, select Add output variable on the Terminate node and give it a value such as
Agent returned: $vars.agent1.output.decision.
5. Debug the workflow
Select Run Debug (▶) in the bottom toolbar of the canvas. In the execution trace:
- Select the Agent node to inspect what inputs were sent and what the agent returned.
- Confirm the Decision node took the correct branch given the agent's output.
- If the agent's response isn't what you expected, review the System prompt, User prompt, and declared output before changing unrelated workflow logic.
Both branches can be exercised without waiting for real agent responses by replacing the agent's response with a fixed one, as Output mocking describes.
Result
The agent node returns a structured decision field, the Decision node branches on its value, and the Terminate node ends the workflow on the rejected path. The execution trace shows the agent's inputs and outputs, and the prompts can be adjusted on the node.
Extend this workflow
- Give the agent tools: connect tool resources (built-in tools, connector tools, RPA or API workflow tools, document extraction, or Model Context Protocol (MCP) servers) to the agent's Tools handle so it can act, not just reason.
- Ground the agent in your data: connect a context resource to the agent's Context handle so it answers from an indexed knowledge source instead of the model alone.
- Put a human in the loop: connect the agent's Escalations handle to an Escalation resource for cases the agent shouldn't decide alone.
- Add a loop: wrap the agent invocation in a Loop node to process a list of items with the same agent.
- Chain to another system: after the Decision node's True branch, add an HTTP Request or integration node to write the result to an external system.
Next steps
- Deploy a workflow: make the workflow run without you.
- Guides: more workflows to build.
- Community: share what you built, or ask other builders for help.