> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 语音信箱检测

## 概述

**语音信箱检测**工具允许 ElevenLabs 智能体自动识别接听通话的是语音信箱系统而非真人。此系统工具让智能体能够妥善处理自动语音信箱场景：播放预先配置的消息，或立即结束通话。

## 功能

* **自动检测**：LLM 根据自动问候语和提示词分析对话模式，以识别语音信箱系统
* **可配置响应**：检测到语音信箱时，可选择播放自定义语音信箱消息，或立即结束通话
* **结束通话**：完成检测和可选的消息播放后，通话会自动结束
* **状态跟踪**：语音信箱检测事件会被记录，可在对话历史和批量通话结果中查看

**参数**：

* `reason`（字符串，必填）：检测到语音信箱的原因（例如，“检测到自动问候语”“无人响应”）

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "voicemail_detection",
    "arguments": "{\"reason\": \"Automated greeting detected with request to leave message\"}"
  }
}
```

## 配置选项

语音信箱检测工具可使用以下选项配置：

![语音信箱检测配置
界面](/docs/_fern-img/f2f9a87e27ce0d5f631d2d294163e8df39e6dee5b3a98aaba692589c66364550.webp)

* **语音信箱消息**：可配置检测到语音信箱时播放的可选自定义消息。此消息支持[动态变量](/docs/zh/eleven-agents/customization/personalization/dynamic-variables)，可使用 `{{user_name}}` 或 `{{appointment_time}}` 等运行时值个性化语音信箱消息

## API 实现

通过 API 创建智能体时，可以将语音信箱检测工具添加到智能体配置中。应将其定义为系统工具：

```python
from elevenlabs import AgentConfig, ConversationalConfig, ElevenLabs

elevenlabs = ElevenLabs(api_key="YOUR_API_KEY")

response = elevenlabs.conversational_ai.agents.create(
    conversation_config=ConversationalConfig(
        agent=AgentConfig(
            prompt={
                "built_in_tools": {
                    "voicemail_detection": {
                        "type": "system",
                        "name": "voicemail_detection",
                        # Optional: customize when the tool should be triggered
                        "description": "",
                        "params": {
                            "system_tool_type": "voicemail_detection",
                            # Optional: message left when voicemail is detected
                            "voicemail_message": "Sorry I missed you. I'll call back later.",
                        },
                    }
                }
            },
        ),
    ),
)
```

```javascript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient({
  apiKey: "YOUR_API_KEY",
});

await elevenlabs.conversationalAi.agents.create({
  conversationConfig: {
    agent: {
      prompt: {
        builtInTools: {
          voicemailDetection: {
            type: "system",
            name: "voicemail_detection",
            description: "", // Optional: Customize when the tool should be triggered
            params: {
              systemToolType: "voicemail_detection",
              // Optional: message left when voicemail is detected
              voicemailMessage: "Sorry I missed you. I'll call back later.",
            },
          },
        },
      },
    },
  },
});
```