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

# Answering Machine Detection (AMD)

> How to screen out calls answered by voicemail using Wavix AMD.

Answering Machine Detection (AMD) is a Wavix intelligence feature that analyzes the initial audio of an outbound call to determine if it was answered by a human or a machine. When an answering machine or voicemail greeting is detected, the Wavix platform automatically disconnects the call, saving your agents time and improving scale and efficiency.

## How AMD works

Wavix AMD analyzes the initial audio of a call to distinguish between a human response and a pre-recorded voicemail message. By identifying frequency patterns and audio characteristics, the platform can detect a machine even during **Early Media** playback (before the final answer signal).

Wavix AMD also screens for automated network announcements played during **Early Media**—the period before a call is technically answered. By identifying these pre-answer signals and terminating the call immediately, the Wavix platform ensures that your resources are only dedicated to successful human connections.

```mermaid actions={false} theme={null}
sequenceDiagram
    participant App as Your Application
    participant Wavix as Wavix Platform
    participant Rec as Recipient
    
    App->>Wavix: Initiate call (voicemail_detection: true)
    Wavix->>Rec: Ringing...
    Rec->>Wavix: Call Answered
    Wavix->>Wavix: Analyze Audio (AMD)
    
    alt Human Detected
        Wavix->>App: Callback: machine_detected: false
        Wavix-->>Rec: Bridged to Agent/Application
    else Machine Detected
        Wavix->>App: Callback: machine_detected: true
        Wavix->>Rec: Disconnect Call
    end
```

## Activation levels

You can enable AMD at two different levels depending on your integration needs:

### 1. Trunk level (Wavix portal & Wavix Embeddable)

Recommended for calls manually placed from your PBX or third-party systems connected via SIP, as well as features built using **Wavix Embeddable**.

For these methods, AMD is controlled globally for the specific SIP trunk:

1. **Sign in** to your [Wavix account](https://app.wavix.com).
2. In the top menu, click on **Numbers & Trunks → Trunks**.
3. Select an existing SIP trunk to edit (or create a new one).
   <Info>Wavix Embeddable uses the SIP trunk configured during your application setup.</Info>
4. Scroll down to the **Trunk features** section.
5. Toggle **Voicemail detection** to **ON**.
6. Click **Save and close**.

Once enabled, any outbound call made through this trunk—whether via a hardware phone or a Wavix Embeddable instance—that is answered by a machine will be automatically dropped.

### 2. Call level (API only)

Recommended for programmable voice applications where you want granular control over which specific calls use AMD. This is currently supported exclusively by the **Calls API**.

#### Via Calls API

To enable AMD for a specific call, set the `voicemail_detection` property to `true` in your `POST /v1/calls` request.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.wavix.com/v1/calls" \
    -H "Authorization: Bearer <your_api_key_here>" \
    -H "Content-Type: application/json" \
    -d '{
      "from": "13614157006",
      "to": "1234567890",
      "voicemail_detection": true
    }'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  axios.post('https://api.wavix.com/v1/calls', {
    from: '13614157006',
    to: '1234567890',
    voicemail_detection: true
  }, {
    headers: {
      'Authorization': 'Bearer <your_api_key_here>',
      'Content-Type': 'application/json'
    }
  })
  .then(response => console.log(response.data))
  .catch(error => console.error(error));
  ```

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

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"net/http"
  )

  func main() {
  	url := "https://api.wavix.com/v1/calls"
  	payload := map[string]interface{}{
  		"from":                "13614157006",
  		"to":                  "1234567890",
  		"voicemail_detection": true,
  	}
  	jsonPayload, _ := json.Marshal(payload)

  	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
  	req.Header.Set("Authorization", "Bearer <your_api_key_here>")
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	resp, err := client.Do(req)
  	if err != nil {
  		fmt.Printf("Error: %v\n", err)
  		return
  	}
  	defer resp.Body.Close()

  	fmt.Printf("Status: %s\n", resp.Status)
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'
  require 'json'

  uri = URI.parse("https://api.wavix.com/v1/calls")
  header = {
    'Content-Type' => 'application/json',
    'Authorization' => 'Bearer <your_api_key_here>'
  }
  body = {
    from: '13614157006',
    to: '1234567890',
    voicemail_detection: true
  }

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, header)
  request.body = body.to_json

  response = http.request(request)
  puts response.body
  ```
</CodeGroup>

## AMD events and webhooks

To receive real-time notifications about AMD results, you can configure an **on-call** webhook. Wavix sends a POST callback to your designated URL whenever a call event occurs, such as when a call is answered and the AMD analysis is complete.

### Subscribe to call events

You can create a webhook using the [Create a webhook](/api-reference/call-webhooks/create-a-call-webhook) endpoint:

```bash theme={null}
curl -X POST "https://api.wavix.com/v1/calls/webhooks" \
  -H "Authorization: Bearer <your_api_key_here>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/calls",
    "event_type": "on-call"
  }'
```

### The machine\_detected event

When a call is answered and subsequently ends, Wavix triggers a `completed` event callback. The JSON payload includes a `machine_detected` boolean field that indicates whether the call was screened by the AMD system.

**Sample completed event payload:**

```json theme={null}
{
  "uuid": "5dccb6b0-f35c-488c-867b-86fb012c4415",
  "direction" : "outbound",
  "event_type": "completed",
  "event_time": "2025-09-22T12:56:45.000Z",
  "event_payload": null,
  "call_started": "2025-09-22T12:56:38.000Z",
  "call_answered": "2025-09-22T12:56:40.000Z",
  "call_completed": "2025-09-22T12:56:45.000Z",
  "from": "+18045961058",
  "to": "17653889567",
  "machine_detected": true,
  "tag": "marketing-campaign"
}
```

* `machine_detected: true`: An answering machine or voicemail was detected.
* `machine_detected: false`: A human was detected.

By listening for the `completed` event, your application can accurately log the outcome of the call, including whether it was dismissed by AMD or successfully answered by a human.
