# Workflows with Agents

### How Agents Fit into Workflows

Workflows handle defined steps, while agents evaluate context and determine the next action during execution. This allows you to build multi-step processes that can adapt without relying on complex conditional logic.

#### Example: Processing Orders from Input

In this example, a user submits order details through the app, and a workflow uses an agent to process and store the data.

{% stepper %}
{% step %}

#### Add Input Components

Add the following to your app in JetAdmin:

* A **multi-line text input** (for order details)
* A **button** (e.g. “Process Order”)

<figure><img src="/files/H6b7CVV9BwuBkn1rgZNo" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Configure the Trigger

Set the button action to:

* Trigger a **workflow**
* Pass the text input as a parameter

{% content-ref url="/pages/qmG6B8DT5DDHSkQXDhhM" %}
[Triggers](/user-guide/workflow/triggers.md)
{% endcontent-ref %}
{% endstep %}

{% step %}

#### Build Workflow Steps

In the workflow canvas:

1. **Agent: Process Input**
   * Read the submitted text
   * Extract structured order data (e.g. name, items, quantity)
   * Clean and format the data
2. **Create Record**
   * Save the structured data into the Orders table
3. **Send Email**
   * Generate a confirmation message
   * Send it to the customer or internal team

<figure><img src="/files/7fBgKvSSzgJOAQpCTXtF" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Test the Workflow

Enter sample order data and click the button to verify:

* The agent correctly parses and structures the input
* The record is created in the database
* The email is generated and sent successfully
  {% endstep %}
  {% endstepper %}

### Why Use Agents in Workflows

Workflows provide structured execution, while agents introduce flexible decision-making.

Together, they enable automations that are both reliable and adaptable without requiring complex logic or extensive conditions.

{% hint style="success" %}

#### Agent Chaining

In more advanced setups, multiple agents can work together.

You can create specialized agents for different tasks and use them as tools within a main agent. The main agent can then delegate specific responsibilities to sub-agents when needed.

Clear and focused instructions for each agent are essential to ensure reliable coordination.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jetadmin.io/agents/workflows-with-agents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
