> For the complete documentation index, see [llms.txt](https://docs.infotopics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infotopics.com/trulyp/ai/ai-agents/ai-agent-builder.md).

# AI Agent Builder

The **AI Agent Builder** allows you to create AI flows visually. Each flow consists of connected blocks, with data moving through the flow from left to right.

You can use the builder to:

* Receive input
* Process data with AI
* Add knowledge and context
* Make decisions and route requests
* Query data services
* Call other agents
* Process lists of items
* Transform data
* Return a final result

## Building your flow

The left side of the Visual builder contains all available blocks.

Drag a block onto the canvas to add it to your flow. Click a block to select it and configure its settings on the right side of the screen.

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2FG2AeJPbspjCQovGqZ1hu%2Fimage.png?alt=media&amp;token=c2719b69-f137-48c7-9773-90442504f2eb" alt=""><figcaption><p>An example block, with the settings on the right side of the screen.</p></figcaption></figure>

### Connecting blocks

To connect two blocks:

1. Click the **output circle** on the right side of the first block.
2. Click the block that should run next.

A connection is created between the two blocks.

Your flow should move in **one direction** and should not loop back to earlier blocks.

{% hint style="info" %}
Most flows should start with an **Input payload** block and end with a **Workflow** block.
{% endhint %}

A **basic** flow looks like this:

`Input payload → AI action → Workflow`

### Navigating the canvas

You can:

* **Move blocks** by dragging them around the canvas. Blocks automatically align to the grid.
* **Zoom** in and out using your mouse wheel.
* **Pan** around the canvas by clicking and dragging an empty area.
* **Auto-layout** the flow to automatically arrange blocks from left to right.

### Removing blocks and connections

To remove a block, select it and press **Delete** or **Backspace**, or use the delete button in the block settings.

Removing a block also removes its connections.

To remove a connection, **double-click the connection line**.

### Undo, redo, and clear

Use **Undo** and **Redo** to restore recent changes.

Use **Clear** to remove all blocks and connections from the canvas.

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2FeofrNfkCm8yO9SwXpeao%2Fimage.png?alt=media&amp;token=959eca2d-bb1c-4c48-8a2d-8005a71b1baf" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
After making changes, save the agent to save the updated flow.
{% endhint %}

***

## Blocks

This section explains all the different blocks available, and what they do.

### Input payload

The **Input payload** block is the starting point of your flow.

When an agent runs, the incoming request data enters the flow through this block. You do not need to configure it.

For example, if your agent receives a customer question, that question becomes available to the blocks connected after the Input payload block.

A typical flow starts with:

`Input payload → AI action → Workflow`

***

### AI action

The **AI action** block sends data to an AI model and returns its response.

#### AI Configuration

First, select an **AI Configuration**. This determines which AI provider and model the block uses.

{% hint style="warning" %}\
An AI action without an AI Configuration cannot run.\
{% endhint %}

#### Prompt template

Enter the instructions for the AI in the **Prompt template**.

You can reference data from earlier blocks using:

```
{{ variable }}
```

For example:

```
Summarise the following customer request:

{{ question }}
```

If the incoming payload contains a `question` value, that value is inserted into the prompt when the AI action runs.

#### MCP tools

You can also connect **MCP tools** to an AI action.

MCP tools allow the AI to use supported backend functionality, such as data, schema, connection, or other available tools.

Click **Connect** next to a tool to make it available to the AI action.

{% hint style="info" %}\
Some tools may require confirmation before they can run.\
{% endhint %}

***

### Condition

The **Condition** block sends data down different paths based on rules.

You can create one or more branches. Each branch contains:

* **Label** — the name of the branch
* **Path** — the field to check
* **Operator** — how the field should be evaluated
* **Value** — the value to compare against

For example, you could create a branch that checks whether:

```
priority equals high
```

#### Available operators

| Operator       | Description                                            |
| -------------- | ------------------------------------------------------ |
| `equals`       | Checks whether two values are the same.                |
| `not_equals`   | Checks whether two values are different.               |
| `contains`     | Checks whether a value contains text or another value. |
| `starts_with`  | Checks whether text starts with a value.               |
| `ends_with`    | Checks whether text ends with a value.                 |
| `greater_than` | Checks whether a value is greater than another value.  |
| `less_than`    | Checks whether a value is less than another value.     |

#### Default branch

Keep a **Default** branch for requests that do not match any of the other conditions.

Connect each branch to the blocks that should run for that outcome.

***

### Intent router

The **Intent router** uses AI to determine which route should be followed.

Use this block when you want to classify an incoming request and send it to the appropriate route or agent.

For example, a router could classify requests as:

* Sales
* Support
* Billing

The available routes are defined as part of the agent configuration.

{% hint style="info" %}\
Use clear and descriptive route names so the AI can distinguish between them reliably.\
{% endhint %}

Connect each route to the blocks that should handle that intent.

***

### Knowledge

The **Knowledge** block provides information that an AI action can use when generating its response.

Connect a Knowledge block to an **AI action**. The connected knowledge is added to the AI action's system instructions.

#### Summary

Use the **Summary** field for written:

* Background information
* Instructions
* Reference material
* Product information
* Company policies
* Support documentation

#### JSON documents

You can also add JSON documents to a Knowledge block.

Their content is included when the connected AI action runs.

{% hint style="info" %}\
Use Knowledge blocks for information the AI should consistently have available when processing a request.\
{% endhint %}

***

### Structure builder

The **Structure builder** tells an AI action to return its response in a specific JSON format.

Use this block when you need predictable structured output, such as:

* Classification results
* Extracted fields
* Metadata
* Lists of objects
* Values consumed by later blocks

Enter a valid JSON schema in the **Schema** field.

For example:

```json
{
  "type": "object",
  "properties": {
    "category": {
      "type": "string"
    },
    "confidence": {
      "type": "number"
    }
  }
}
```

The builder checks whether the JSON is valid. Use **Format JSON** to make the schema easier to read.

Connect the Structure builder to the **AI action** that should return the structured result.

The connected AI action will then be instructed to return data using this structure.

***

### Data service

The **Data service** block allows the flow to call configured schema or data query services.

Use this block when your agent needs to retrieve data before continuing to another block.

The incoming data determines which datasource or query can be used.

For example:

`Input payload → Data service → AI action → Workflow`

This allows the AI action to use the data returned by the Data service in its prompt.

***

### Workflow

The **Workflow** block passes the current data through to the end of the flow.

Use it as the final block when the result from the previous block should be returned by the agent.

For a simple AI agent:

`Input payload → AI action → Workflow`

***

### Agent

The **Agent** block runs another saved AI agent.

Use this block when you want to reuse an existing agent as part of a larger flow.

For example, a main agent could call separate agents for:

* Summarisation
* Classification
* Data analysis
* Specialized tasks

Select the agent you want to run and configure its instructions where needed.

The result from the selected agent is added to the flow payload and can be used by later blocks.

***

### Loop

The **Loop** block runs an agent once for every item in a list.

Use it when the incoming data contains multiple items that need to be processed individually.

For example, you could:

* Summarise every customer message in a list
* Classify every row in a file
* Process each product separately

#### Items path

Choose the agent to run, then enter the **Items path**.

This is the location of the list in the incoming data.

For example, if your input contains a list called `rows`, enter:

```
rows
```

#### Item key

The **Item key** determines the name used for the current item while the agent runs.

The default value is:

```
item
```

#### Concurrency

You can also configure the **concurrency** value.

Concurrency controls how many items the flow is configured to process at the same time.

***

### Expression

The **Expression** block evaluates an expression using the data currently available in the flow.

Use it for simple:

* Calculations
* Comparisons
* Data transformations

The expression result is stored under an **output key**.

By default, the output key is:

```
result
```

Later blocks can use this result as part of their input.

***

## Example: Create a simple support agent

This example creates an agent that receives a customer question, sends it to an AI model, and returns the generated answer.

### 1. Add the Input payload

Add an **Input payload** block to the canvas.

This receives the incoming customer question.

### 2. Add an AI action

Add an **AI action** block and connect the Input payload block to it:

`Input payload → AI action`

Select an **AI Configuration** in the AI action settings.

Then enter a prompt such as:

```
You are a helpful support assistant.

Answer the following customer question clearly and accurately:

{{ question }}
```

### 3. Add the Workflow block

Add a **Workflow** block and connect the AI action to it.

Your complete flow should now look like:

`Input payload → AI action → Workflow`

### 4. Save and activate the agent

Save the agent.

When the agent is ready to use, change its status to **Active**.

### 5. Run the agent

For example, the agent could receive the following payload:

```json
{
  "question": "How do I reset my password?"
}
```

The flow then works as follows:

1. **Input payload** receives the `question`.
2. **AI action** inserts the question into `{{ question }}` and sends the completed prompt to the configured AI model.
3. **Workflow** returns the resulting answer.

{% hint style="success" %}\
You now have a basic AI agent. From here, you can add Conditions, Knowledge, Data services, Intent routers, other Agents, Loops, and Expressions to build more advanced flows.\
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.infotopics.com/trulyp/ai/ai-agents/ai-agent-builder.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
