> 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.

# 系统工具

**系统工具** 可让助手更新对话的内部状态。与 [Webhook 工具](/docs/zh/eleven-agents/customization/tools/webhook-tools) 或 [客户端工具](/docs/zh/eleven-agents/customization/tools/client-tools) 不同，系统工具不会发起外部 API 调用或触发客户端函数，而是在不进行外部调用的情况下修改对话内部状态。

## 概述

某些应用需要智能体控制对话流程或状态。
系统工具让助手能够执行与通话状态相关的操作，无需与外部服务器或客户端通信。

### 可用系统工具

#### [结束通话](/docs/zh/eleven-agents/customization/tools/system-tools/end-call)

当满足适当条件时，让智能体自动结束对话。

#### [语言检测](/docs/zh/eleven-agents/customization/tools/system-tools/language-detection)

让智能体在对话中自动切换至用户使用的语言。

#### [智能体转接](/docs/zh/eleven-agents/customization/tools/system-tools/agent-transfer)

根据定义的条件，在 AI 智能体之间无缝转接对话。

#### [转接至号码](/docs/zh/eleven-agents/customization/tools/system-tools/transfer-to-number)

将通话转接至外部电话号码或 SIP URI。

#### [跳过轮次](/docs/zh/eleven-agents/customization/tools/system-tools/skip-turn)

如果 LLM 检测到智能体暂不应发言，可让智能体跳过其轮次。

#### [播放按键触摸音](/docs/zh/eleven-agents/customization/tools/system-tools/play-keypad-touch-tone)

让智能体播放 DTMF 音，与自动电话系统交互并浏览菜单。

#### [语音信箱检测](/docs/zh/eleven-agents/customization/tools/system-tools/voicemail-detection)

让智能体自动检测语音信箱系统，并可选择留下留言。

#### [更新状态](/docs/zh/eleven-agents/customization/tools/system-tools/update-state)

让智能体在对话中使用表达式更新动态变量。

## 实现

通过 API 创建智能体时，可以将系统工具添加到智能体配置中。以下介绍如何实现结束通话和语言检测工具：

## 自定义 LLM 集成

将自定义 LLM 与 ElevenLabs 智能体配合使用时，系统工具会作为可供 LLM 调用的函数定义公开。每个系统工具都有特定参数和触发条件：

### 可用系统工具

#### 结束通话

**用途**：在满足相应条件时自动结束对话。

**触发条件**：LLM 应在以下情况下调用此工具：

* 主要任务已完成，且用户满意
* 双方达成一致后，对话自然结束
* 用户明确表示想结束对话

**参数**：

* `reason`（字符串，必填）：结束通话的原因
* `message`（字符串，选填）：结束通话前发送给用户的告别消息

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "end_call",
    "arguments": "{\"reason\": \"Task completed successfully\", \"message\": \"Thank you for using our service. Have a great day!\"}"
  }
}
```

**实现**：在智能体设置中将其配置为系统工具。LLM 会收到有关何时调用此函数的详细说明。

了解更多：[结束通话工具](/docs/zh/eleven-agents/customization/tools/system-tools/end-call)

#### 语言检测

**用途：** 在对话期间自动切换至检测到的用户语言。

**触发条件：** LLM 应在以下情况调用此工具：

* 用户使用与当前对话语言不同的语言
* 用户明确要求切换语言
* 对话需要多语言支持

**参数：**

* `reason`（字符串，必填）：切换语言的原因
* `language`（字符串，必填）：要切换至的语言代码（必须在支持的语言列表中）

**函数调用格式：**

```json
{
  "type": "function",
  "function": {
    "name": "language_detection",
    "arguments": "{\"reason\": \"User requested Spanish\", \"language\": \"es\"}"
  }
}
```

**实现方式：** 在智能体设置中配置支持的语言，并添加语言检测系统工具。智能体会自动切换音色和回复，以匹配检测到的语言。

了解更多：[语言检测工具](/docs/zh/eleven-agents/customization/tools/system-tools/language-detection)

#### 智能体转接

**用途**：根据用户需求，在专业 AI 智能体之间转接对话。

**触发条件**：LLM 应在以下情况调用此工具：

* 用户请求需要专业知识或其他智能体能力
* 当前智能体无法妥善处理该查询
* 对话流程表明需要其他类型的智能体

**参数**：

* `reason`（字符串，可选）：转接智能体的原因
* `agent_number`（整数，必填）：要转接到的智能体的从零开始编号（基于已配置的转接规则）

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "transfer_to_agent",
    "arguments": "{\"reason\": \"User needs billing support\", \"agent_number\": 0}"
  }
}
```

**实现方式**：定义将条件映射到特定智能体 ID 的转接规则。配置当前智能体可转接到哪些智能体。在转接配置中，智能体以从零开始的编号表示。

了解更多：[智能体转接工具](/docs/zh/eleven-agents/customization/tools/system-tools/agent-transfer)

#### 转接至号码

**用途**：当 AI 协助不足时，将对话无缝转接给人工客服。

**触发条件**：LLM 应在以下情况下调用此工具：

* 遇到需要人工判断的复杂问题
* 用户明确请求人工协助
* 对特定请求，AI 已达到能力上限
* 触发升级处理流程

**参数**：

* `reason`（字符串，选填）：转接原因
* `transfer_number`（字符串，必填）：要转接至的电话号码（必须与已配置号码一致）
* `client_message`（字符串，必填）：等待转接时向客户播报的消息
* `agent_message`（字符串，必填）：发送给接听通话的人工客服的消息

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "transfer_to_number",
    "arguments": "{\"reason\": \"Complex billing issue\", \"transfer_number\": \"+15551234567\", \"client_message\": \"I'm transferring you to a billing specialist who can help with your account.\", \"agent_message\": \"Customer has a complex billing dispute about order #12345 from last month.\"}"
  }
}
```

**实现**：配置转接电话号码和条件，并分别定义给客户和接听通话的人工客服的消息。支持 Twilio 和 SIP 中继。

了解更多：[转接至号码工具](/docs/zh/eleven-agents/customization/tools/system-tools/transfer-to-number)

#### 跳过轮次

**用途**：让智能体暂停并等待用户输入，不发出语音。

**触发条件**：LLM 应在以下情况调用此工具：

* 用户表示需要一点时间（“给我一点时间”“让我想想”）
* 用户要求暂停对话流程
* 智能体检测到用户需要时间处理信息

**参数**：

* `reason`（字符串，可选）：说明为何需要暂停的自由格式原因

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "skip_turn",
    "arguments": "{\"reason\": \"User requested time to think\"}"
  }
}
```

**实现方式**：无需额外配置。该工具仅向智能体发出信号，使其保持静默，直到用户再次说话。

了解更多：[跳过轮次工具](/docs/zh/eleven-agents/customization/tools/system-tools/skip-turn)

#### 播放按键触摸音

**参数：**

* `reason`（字符串，可选）：播放 DTMF 音调的原因（例如“导航至分机”“输入 PIN”）
* `dtmf_tones`（字符串，必填）：要播放的 DTMF 序列。有效字符：0-9、\*、#、w（0.5 秒暂停）、W（1 秒暂停）

**函数调用格式：**

```json
{
  "type": "function",
  "function": {
    "name": "play_keypad_touch_tone",
    "arguments": "{"reason": "Navigating to customer service", "dtmf_tones": "2"}"
  }
}
```

了解更多：[播放按键触摸音工具](/docs/zh/eleven-agents/customization/tools/system-tools/play-keypad-touch-tone)

#### 语音信箱检测

**参数**：

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

**函数调用格式**：

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

了解更多：[语音信箱检测工具](/docs/zh/eleven-agents/customization/tools/system-tools/voicemail-detection)

#### 更新状态

**用途**：让智能体根据对话更新一个或多个动态变量，无需调用外部 API。

**触发条件**：LLM 应在以下情况调用此工具：

* 对话提供了应记录的信息（例如升级标记、选定选项、用户提供的值）
* 已配置的状态更新依赖于 LLM 必须从对话中判断或提取的值

**参数**：

函数参数取决于工具的配置。每项使用 LLM 提取值的已配置状态更新，都会在架构中添加一个属性；该属性以此更新的动态变量命名，类型为 `string`、`number` 或 `boolean`。仅由常量或其他动态变量构建的状态更新不会添加任何参数。

**函数调用格式**：

```json
{
  "type": "function",
  "function": {
    "name": "update_state",
    "arguments": "{\"should_escalate\": true}"
  }
}
```

**实现方式**：智能体会使用提取出的参数和当前对话动态变量评估每个已配置表达式，然后将结果赋值给对应的动态变量。不会发出外部请求。

了解更多：[更新状态工具](/docs/zh/eleven-agents/customization/tools/system-tools/update-state)

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

elevenlabs = ElevenLabs(api_key="YOUR_API_KEY")

# Each system tool is keyed by name under built_in_tools.
# Leave "description" blank to use the default, tool-specific prompt.
response = elevenlabs.conversational_ai.agents.create(
    conversation_config=ConversationalConfig(
        agent=AgentConfig(
            prompt={
                "built_in_tools": {
                    "end_call": {
                        "type": "system",
                        "name": "end_call",
                        "description": "",
                        "params": {"system_tool_type": "end_call"},
                    },
                    "language_detection": {
                        "type": "system",
                        "name": "language_detection",
                        "description": "",
                        "params": {"system_tool_type": "language_detection"},
                    },
                }
            },
        ),
    ),
)
```

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

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

// Each system tool is keyed by name under builtInTools.
// Leave "description" blank to use the default, tool-specific prompt.
await elevenlabs.conversationalAi.agents.create({
  conversationConfig: {
    agent: {
      prompt: {
        builtInTools: {
          endCall: {
            type: "system",
            name: "end_call",
            description: "",
            params: { systemToolType: "end_call" },
          },
          languageDetection: {
            type: "system",
            name: "language_detection",
            description: "",
            params: { systemToolType: "language_detection" },
          },
        },
      },
    },
  },
});
```

## 常见问题

#### 系统工具能否与其他工具类型结合使用？

可以，系统工具可与同一助手中的 Webhook 工具和客户端工具配合使用。
这样可将内部状态管理与
外部交互结合，提供全面的功能。

```
```