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

# Originate to AI

> Make outbound phone calls that connect to AI voice bots — for automated outreach, reminders, and surveys.

The originate-to-AI endpoint lets you make a phone call to someone and connect them to an AI voice bot. This is useful for automated outreach, appointment reminders, surveys, and follow-up calls.

## Endpoint

```
POST /api/v1/calls/originate-to-ai
```

## Authentication

Requires an API key with `calls.originate_ai` permission.

## Request body

```json theme={null}
{
  "to": "9944421125",
  "caller_id": "+918065978015",
  "ai_agent_app": "ai_agent",
  "wss_url": "wss://gateway.astradial.com/ws/{orgId}/{botId}?key={apiKey}",
  "timeout": 30,
  "variables": {
    "guest_name": "John Doe",
    "room_number": "305",
    "purpose": "wake_up_call"
  }
}
```

| Field          | Type   | Required | Description                                     |
| -------------- | ------ | -------- | ----------------------------------------------- |
| `to`           | string | Yes      | Phone number to call                            |
| `caller_id`    | string | No       | Caller ID shown to the person being called      |
| `ai_agent_app` | string | No       | The ARI application name (default: "ai\_agent") |
| `wss_url`      | string | Yes      | WebSocket URL for the AI bot                    |
| `timeout`      | number | No       | Seconds to wait for answer (default: 30)        |
| `variables`    | object | No       | Custom variables passed to the bot              |

## Example: wake-up call

```bash theme={null}
curl -X POST https://your-server:8000/api/v1/calls/originate-to-ai \
  -H "X-API-Key: ak_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "9944421125",
    "caller_id": "+918065978015",
    "wss_url": "wss://gateway.astradial.com/ws/org123/bot456?key=ak_abc123",
    "variables": {
      "guest_name": "John Doe",
      "purpose": "wake_up_call"
    }
  }'
```

## Example: using an extension with a bot

If you have a user configured with AI routing, you can call through that extension:

```bash theme={null}
curl -X POST https://your-server:8000/api/v1/calls/originate-to-ai \
  -H "X-API-Key: ak_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "9944421125",
    "caller_id": "+918065978015",
    "wss_url": "wss://your-server:7860/ws/org123/bot456?key=ak_abc123"
  }'
```

## How it works

1. Astradial dials the phone number
2. When the person answers, the call connects to the AI bot via WebSocket
3. The bot follows its conversation flow
4. Variables you pass are available to the bot for personalized responses
5. The bot can transfer to a human, create tickets, or end the conversation

## Response

```json theme={null}
{
  "status": "success",
  "message": "Call originated",
  "channel_id": "PJSIP/trunk-00000005"
}
```

## Use with workflows

You can also originate AI calls from workflows. In the workflow editor, add a **Place Call** action node and select a bot. The workflow passes trigger data as variables to the bot.
