---
title: How Agents Works
slug: how-agents-works
docTags: 
createdAt: 2026-03-23T10:52:44.069Z
---

A Agent talks with users through messages and gives responses using AI.

When a user sends a message, the agent understands the request and generates a reply.

Sometimes the agent may also fetch data using workflows or APIs.

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
  'primaryColor': '#ffe5e5',
  'primaryBorderColor': '#d97b7b',
  'primaryTextColor': '#333333',
  'lineColor': '#d97b7b',
  'arrowheadColor': '#d97b7b',
  'background': '#fff5f5',
  'edgeLabelBackground': '#fff5f5'
}}}%%
graph LR
    A[User Message] --> B[Agent]
    B --> C[Workflow]
    C -- Input Attributes --> D[Path]
    D -- Output Attributes --> E[Agent]
    E --> F[Response]
```

### Explanation

- **User Message** – The user asks a question.
- **Agent** – Receives the message and processes it.
- **System Prompt** – Tells the agent how it should behave and respond.
- **Workflow (optional)** – Used when the agent needs to fetch or save data.
- **Path / API** – Retrieves information from external systems.
- **Response** – The agent sends the final answer to the user.

### Note

If the information is **small or fixed**, it can be added directly in the **System Prompt**.

If the agent needs to **fetch external data (APIs, database, search results)**, then **Workflows and Paths** should be used.

### Example

If a user asks to book a doctor appointment:

1. The agent understands the request.
2. It triggers a workflow to fetch available doctors.
3. The system returns doctor details and available slots.
4. The agent shows the available appointment times to the user.

