> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lyzn.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Agent Deep Dive

> Mastering AI agents: Chat triggers, memory, and tools

# AI Agents in LyznFlow

Building an AI Agent is one of the most powerful features of LyznFlow. It transforms a standard workflow into an intelligent conversational bot.

## The Agent Architecture

An AI Agent workflow consists of three key components working together:

```mermaid theme={null}
graph LR
    User[User Message] --> Trigger[Chat Trigger]
    Trigger --> Agent[AI Agent Node]
    Agent <--> Tools[Tools]
    Agent --> Response[Response]
```

### 1. Chat Trigger

This is the entry point. It listens for messages from the chat widget.

* **Session ID**: Automatically generated for each user conversation.
* **Message**: The user's text input.
* **History**: Previous messages in the conversation (handled automatically).

### 2. AI Agent Node

The brain of the operation.

* **System Prompt**: You define the persona (e.g., "You are a helpful customer support assistant").
* **Model**: Choose the LLM (e.g., GPT-4, Claude).
* **Memory**: The agent remembers the conversation context using the `Session ID`.

### 3. Tools

Tools give your agent "hands". Without them, it can only talk. With them, it can:

* Search the web (`Live Search`).
* Check your database (`LyznDB Query`).
* Send emails (`Send Email Tool`).

## Building Your First Agent

1. **Start Needs**: Drag a **Chat Trigger** onto the canvas.
2. **Add Brain**: Connect it to an **AI Agent** node.
3. **Equip Tools**:
   * Add tool nodes (e.g., **Google Search Tool**).
   * Connect the tool's output to the **AI Agent's "Tools" input port**.
   * <Note>You can connect multiple tools to the same Agent!</Note>

### The Execution Loop

When a user asks a question like *"What's the weather in Tokyo?"*:

1. **AI Thinks**: The Agent receives the message.
2. **Tool Decision**: It realizes it doesn't know the weather, but it has a `Weather Tool`.
3. **Tool Call**: It pauses execution and calls the tool with `{ location: "Tokyo" }`.
4. **Tool Result**: The tool runs and returns `"Sunny, 25°C"`.
5. **Final Response**: The AI uses this data to answer: *"It is currently sunny and 25°C in Tokyo."*

***

**Next Steps**: Want to build your own custom tools? Check out the [Custom Tool Builder](/lyznflow/guides/custom-tool-builder).
