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

# AI Agents Overview

> Automate customer conversations with intelligent AI-powered agents

# AI Agents Overview

AI Agents allow you to automate customer conversations using large language models. When a customer sends a message to your sender, the agent can respond intelligently, answer questions from your knowledge base, and execute actions via webhooks.

## When to Use AI Agents

AI Agents are ideal for:

| Use Case                | Description                                                              |
| ----------------------- | ------------------------------------------------------------------------ |
| **Customer Support**    | Answer common questions, troubleshoot issues, and escalate complex cases |
| **Lead Qualification**  | Collect contact information and qualify leads through conversation       |
| **Appointment Booking** | Guide customers through scheduling via conversational flows              |
| **FAQ Answering**       | Provide instant answers using your knowledge base documents              |
| **Order Status**        | Look up orders and provide updates via webhook integrations              |

## Supported Providers

Configure your agent with any of these LLM providers:

| Provider      | Models                              | Notes                                     |
| ------------- | ----------------------------------- | ----------------------------------------- |
| **OpenAI**    | gpt-4o, gpt-4o-mini, gpt-4-turbo    | Most popular, great general-purpose       |
| **Anthropic** | claude-3-5-sonnet, claude-3-5-haiku | Excellent reasoning capabilities          |
| **Google**    | gemini-1.5-pro, gemini-1.5-flash    | Cost-effective for high volume            |
| **Mistral**   | mistral-large, mistral-small        | European data residency option            |
| **Zavu**      | Managed models                      | No API key needed, billed to your account |

<Info>
  Using the **Zavu** provider means we handle the LLM API calls for you. Costs are charged directly to your Zavu balance at pass-through rates with no markup.
</Info>

## Quick Start

Here's how to create an AI agent for a sender:

<CodeGroup>
  ```typescript TypeScript theme={null}
  import Zavudev from "@zavudev/sdk";

  const zavu = new Zavudev({
    apiKey: process.env["ZAVUDEV_API_KEY"],
  });

  // Create an agent for your sender
  const agent = await zavu.senders.agent.create("sender_abc123", {
    enabled: true,
    provider: "openai",
    model: "gpt-4o-mini",
    systemPrompt: `You are a helpful customer support agent for Acme Corp.
  Be friendly and concise. If you don't know the answer, say so.
  For billing questions, ask the customer to email billing@acme.com.`,
    temperature: 0.7,
    contextWindowMessages: 10,
    triggerOnChannels: ["sms", "whatsapp"],
  });

  console.log("Agent created:", agent.id);
  ```

  ```python Python theme={null}
  import os
  from zavudev import Zavudev

  zavu = Zavudev(
      api_key=os.environ.get("ZAVUDEV_API_KEY"),
  )

  # Create an agent for your sender
  agent = zavu.senders.agent.create(
      "sender_abc123",
      enabled=True,
      provider="openai",
      model="gpt-4o-mini",
      system_prompt="""You are a helpful customer support agent for Acme Corp.
  Be friendly and concise. If you don't know the answer, say so.
  For billing questions, ask the customer to email billing@acme.com.""",
      temperature=0.7,
      context_window_messages=10,
      trigger_on_channels=["sms", "whatsapp"],
  )

  print(f"Agent created: {agent.id}")
  ```

  ```ruby Ruby theme={null}
  require "zavudev"

  client = Zavudev::Client.new(api_key: ENV["ZAVUDEV_API_KEY"])

  agent = client.senders.agent.create("sender_abc123",
    enabled: true,
    provider: "openai",
    model: "gpt-4o-mini",
    system_prompt: "You are a helpful customer support agent for Acme Corp.\nBe friendly and concise. If you don't know the answer, say so.\nFor billing questions, ask the customer to email billing@acme.com.",
    temperature: 0.7,
    context_window_messages: 10,
    trigger_on_channels: ["sms", "whatsapp"]
  )

  puts "Agent created: #{agent.id}"
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"os"

  	"github.com/zavudev/sdk-go"
  )

  func main() {
  	client := zavudev.NewClient(zavudev.WithAPIKey(os.Getenv("ZAVUDEV_API_KEY")))

  	agent, _ := client.Senders.Agent.Create(context.TODO(), "sender_abc123", zavudev.AgentCreateParams{
  		Enabled:               zavudev.Bool(true),
  		Provider:              zavudev.String("openai"),
  		Model:                 zavudev.String("gpt-4o-mini"),
  		SystemPrompt:          zavudev.String("You are a helpful customer support agent for Acme Corp.\nBe friendly and concise. If you don't know the answer, say so.\nFor billing questions, ask the customer to email billing@acme.com."),
  		Temperature:           zavudev.Float(0.7),
  		ContextWindowMessages: zavudev.Int(10),
  		TriggerOnChannels:     []string{"sms", "whatsapp"},
  	})

  	fmt.Printf("Agent created: %s\n", agent.ID)
  }
  ```

  ```php PHP theme={null}
  $client = new Zavudev\Client(apiKey: getenv('ZAVUDEV_API_KEY'));

  $agent = $client->senders->agent->create('sender_abc123', [
      'enabled' => true,
      'provider' => 'openai',
      'model' => 'gpt-4o-mini',
      'systemPrompt' => "You are a helpful customer support agent for Acme Corp.\nBe friendly and concise. If you don't know the answer, say so.\nFor billing questions, ask the customer to email billing@acme.com.",
      'temperature' => 0.7,
      'contextWindowMessages' => 10,
      'triggerOnChannels' => ['sms', 'whatsapp'],
  ]);

  echo "Agent created: {$agent->id}\n";
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.zavu.dev/v1/senders/sender_abc123/agent \
    -H "Authorization: Bearer $ZAVU_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "enabled": true,
      "provider": "openai",
      "model": "gpt-4o-mini",
      "systemPrompt": "You are a helpful customer support agent for Acme Corp.\nBe friendly and concise. If you dont know the answer, say so.\nFor billing questions, ask the customer to email billing@acme.com.",
      "temperature": 0.7,
      "contextWindowMessages": 10,
      "triggerOnChannels": ["sms", "whatsapp"]
    }'
  ```
</CodeGroup>

## Agent Architecture

When a message arrives, the agent processes it through this flow:

```
                    Inbound Message
                          |
                          v
                  +---------------+
                  | Agent Enabled?|
                  +---------------+
                    |           |
                   No          Yes
                    |           |
                    v           v
              +---------+  +-----------------+
              | Webhook |  | Check Flow State|
              |  Only   |  +-----------------+
              +---------+       |         |
                          Has Active   No Active
                             Flow        Flow
                               |           |
                               v           v
                         +---------+  +-----------+
                         | Execute |  | Match Flow|
                         |   Step  |  |  Triggers |
                         +---------+  +-----------+
                               |           |
                               |      No Match
                               |           |
                               v           v
                         +---------+  +-----------+
                         |  Send   |  | Query KB  |
                         |Response |  | + LLM Call|
                         +---------+  +-----------+
                                           |
                                           v
                                     +-----------+
                                     |   Send    |
                                     |  Response |
                                     +-----------+
```

### Key Components

<CardGroup cols={2}>
  <Card title="LLM Configuration" icon="brain">
    Choose your AI provider and model. Configure system prompts, temperature, and context window size.
  </Card>

  <Card title="Conversational Flows" icon="diagram-project">
    Create structured conversation paths for lead capture, booking, and multi-step processes.
  </Card>

  <Card title="Webhook Tools" icon="webhook">
    Let the AI execute actions by calling your webhooks (check orders, create tickets, etc.).
  </Card>

  <Card title="Knowledge Base" icon="book">
    Upload documents and FAQs. The agent uses RAG to find relevant context when answering.
  </Card>
</CardGroup>

## Pricing

AI Agent costs are **pass-through** with no Zavu markup. You pay exactly what the providers charge:

| Provider  | Model             | Input Cost        | Output Cost      | \~Cost per Message |
| --------- | ----------------- | ----------------- | ---------------- | ------------------ |
| OpenAI    | gpt-4o-mini       | \$0.15/1M tokens  | \$0.60/1M tokens | \~\$0.0002         |
| OpenAI    | gpt-4o            | \$2.50/1M tokens  | \$10/1M tokens   | \~\$0.003          |
| Anthropic | claude-3-5-haiku  | \$0.25/1M tokens  | \$1.25/1M tokens | \~\$0.0003         |
| Anthropic | claude-3-5-sonnet | \$3/1M tokens     | \$15/1M tokens   | \~\$0.005          |
| Google    | gemini-1.5-flash  | \$0.075/1M tokens | \$0.30/1M tokens | \~\$0.0001         |

<Tip>
  For most use cases, **gpt-4o-mini** or **gemini-1.5-flash** offer the best balance of quality and cost. Reserve larger models for complex reasoning tasks.
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Setup Guide" icon="rocket" href="/guides/ai-agents/setup">
    Configure your first AI Agent step-by-step
  </Card>

  <Card title="Conversational Flows" icon="diagram-project" href="/guides/ai-agents/flows">
    Build structured conversation paths
  </Card>

  <Card title="Webhook Tools" icon="wrench" href="/guides/ai-agents/tools">
    Add custom actions via webhooks
  </Card>

  <Card title="Knowledge Base" icon="book" href="/guides/ai-agents/knowledge-base">
    Set up RAG with your documents
  </Card>
</CardGroup>
