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

# Agent Functions

> Extend your AI agent capabilities with built-in and custom functions

## What are Functions?

Functions give your AI agent the ability to perform actions during calls. They enable real-time capabilities like transferring calls, ending conversations, booking appointments, and executing custom logic.

**Two Categories:**

* **Built-in Functions** - Pre-configured actions (transfer, end call, scheduling)
* **Custom Functions** - Your own logic (API calls, custom code)

## Built-in Functions

Ready-to-use functions for common call management and scheduling tasks.

### Call Management

Control call flow and routing.

<CardGroup cols={2}>
  <Card title="Transfer Call" icon="phone-arrow-up-right" href="/agents/functions/transfer-call">
    Transfer calls to phone numbers with warm transfer support
  </Card>

  <Card title="End Call" icon="phone-hangup" href="/agents/functions/end-call">
    Gracefully end conversations when appropriate
  </Card>
</CardGroup>

### Scheduling (Cal.com)

Book appointments and check availability using Cal.com integration.

<CardGroup cols={2}>
  <Card title="Check Availability" icon="calendar-clock" href="/agents/functions/check-availability">
    Query available time slots from Cal.com
  </Card>

  <Card title="Book a Meeting" icon="calendar-check" href="/agents/functions/book-a-meeting">
    Schedule appointments directly in Cal.com
  </Card>
</CardGroup>

## Custom Functions

Create your own functions with API integrations or custom code.

### Three Types

<CardGroup cols={3}>
  <Card title="Pre-Call" icon="play" href="/agents/functions/custom-functions/pre-call">
    Modify system prompt and metadata before calls start
  </Card>

  <Card title="In-Call" icon="phone" href="/agents/functions/custom-functions/in-call">
    Execute actions during active calls with AI triggers
  </Card>

  <Card title="Post-Call" icon="stop" href="/agents/functions/custom-functions/post-call">
    Process call data and execute logic after calls end
  </Card>
</CardGroup>

### Modes

**Basic Mode** - API integration without code

* Configure API endpoints
* Map variables to parameters
* Perfect for existing APIs

**Advanced Mode** - Write custom code

* Python (pre-call, in-call)
* JavaScript (post-call)
* AI-powered code generation

<Card title="Custom Functions Guide" icon="code" href="/agents/functions/custom-functions/introduction">
  Complete guide to creating custom functions
</Card>

## How Functions Work

### Built-in Functions

1. **Add Function** - Configure in agent settings
2. **Set Parameters** - Phone numbers, descriptions, Cal.com details
3. **AI Triggers** - AI decides when to call based on description
4. **Action Executes** - Function runs automatically

### Custom Functions

**Pre-Call:**

```
[Pre-Call Function] → [System Prompt Updated] → [Call Starts]
```

**In-Call:**

```
[AI Detects Trigger] → [Function Executes] → [AI Uses Result]
```

**Post-Call:**

```
[Call Ends] → [Conditions Check] → [Function Executes]
```

## Common Use Cases

### Built-in Functions

* **Transfer**: Route to human agents, specialists, departments
* **End Call**: Complete resolved conversations gracefully
* **Scheduling**: Book appointments, check calendars

### Custom Functions

**Pre-Call:**

* Fetch user preferences from database
* Customize greeting based on region
* Load context from CRM

**In-Call:**

* Check product availability
* Validate customer data
* Query databases
* Call external APIs

**Post-Call:**

* Calculate next date of action (NDOA)
* Update CRM with call results
* Send follow-up emails
* Generate reports

## Quick Start

<Steps>
  <Step title="Choose Function Type">
    Built-in for common tasks, custom for specific needs
  </Step>

  <Step title="Configure Function">
    Set parameters (built-in) or create logic (custom)
  </Step>

  <Step title="Add Description">
    Tell AI when to trigger the function
  </Step>

  <Step title="Test">
    Make test calls to verify function behavior
  </Step>
</Steps>

## Best Practices

* **Clear descriptions** - Be specific about when AI should call functions
* **Test thoroughly** - Verify functions work in different scenarios
* **Error handling** - Handle failures gracefully in custom functions
* **Keep focused** - One function, one purpose
* **Monitor usage** - Review function calls in analytics

<Tip>
  Start with built-in functions for standard tasks, then add custom functions as your needs grow.
</Tip>

## Next Steps

Choose a function category to get started:

<CardGroup cols={2}>
  <Card title="Built-in Functions" icon="bolt" href="/agents/functions/transfer-call">
    Explore pre-built call management and scheduling
  </Card>

  <Card title="Custom Functions" icon="code" href="/agents/functions/custom-functions/introduction">
    Create your own functions with code or APIs
  </Card>
</CardGroup>
