> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow.md).

# 对话流程

了解 Conversation Flow 模块在对话中跟踪什么，以及为什么其他每个具身化模块都依赖它的时序。

Conversation Flow 是决定角色对话状态的具身模块，状态包括空闲、聆听、思考和说话。所有其他具身模块都读取这一状态，而不是各自维护一份。你很少需要手动添加它：只要其他模块需要读取对话状态，Convai 就会自动添加一个控制器。本页面介绍该模块负责的内容，以及依赖它的模块为何会有相应的行为。

***

### Conversation Flow 的职责

`ConvaiConversationFlowController` (`SDK/Modules/ConversationFlow/Components/ConvaiConversationFlowController.cs`）是角色对话状态的唯一权威来源。它公开了一个 `Current` 读数和一个 `Changed` 事件；其他具身模块都不会重新定义或推断自己的状态。有关八种状态各自的含义以及角色何时进入这些状态，请参阅 [对话状态](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/dialogue-state.md) 。

***

### 说话轮次如何结束

说话轮次在角色自身的语音停止时就结束，而不是在 Convai 确认轮次结束时。Convai 在声音已经结束后才会发送轮次完成确认，因此，等待该确认的角色会在消息到达之前一直继续表演。控制器改为在本地进行监测，一旦有本地证据表明回复已结束，就立即退出 `Speaking` 状态。所有读取 `Speaking` 的模块（包括 Body Animation 的说话层）也会从同一时刻开始收尾。

控制器依据以下两个本地证据源判断结束，并以最先报告结束的证据源为准：

* **角色的语音。** 两句话之间的间隔听起来与结束时的静默相同，因此控制器会等待 `0.4` 秒，然后才将静默视为轮次结束。
* **Lip Sync（如果角色启用了它）。** 语音动画会先于其对应的音频到达，因此 Lip Sync 在声音播放到结尾之前就知道回复在哪里结束，无需等待。

这是固定行为，对所有角色都相同，无法在 `ConvaiConversationFlowProfile`中配置。控制器也会在本地有证据表明你已开始说话时立即检测到，比 Convai 自身确认听到你说话更早——这是轮次的另一端，同样是固定行为。有关这两种行为，请参阅 [Conversation Flow 参考](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/reference.md#fixed-behavior) 。

`ConvaiCharacter.IsSpeaking`, `OnSpeechStopped`和 `OnTurnCompleted` 不受影响——它们仍然报告 Convai 自身的判断，而不是控制器的本地判断。

***

### 其他模块为何都读取该状态

如果没有可读取的对话状态，Gaze、Body Animation、Body Language 和 Emotion 就无法区分聆听和说话，只能回退到中性行为：眼神接触不再区分聆听时刻和思考停顿，手势及表情的强度也不再随说话的活跃程度变化。Conversation Flow 使这些原本中性的行为能够跟随对话的实际进程变化。

***

### Convai 会在需要时自动添加

即使没有预先添加 `ConvaiConversationFlowController` ，角色也能获得一个。Body Animation 的 **自动创建 Conversation Flow** 设置（默认启用）会在角色需要对话状态且尚无控制器时，让 Convai 自动添加控制器。Emotion 也会这样做，但仅限于实际启用了某项对话驱动的细节效果时——聆听时的提升效果、思考时的神态或反应强调效果——因为这些效果默认都未启用。Gaze 和 Body Language 在状态存在时会读取它，但不会自行添加控制器，而是平稳回退到 `Idle` 。当 Convai 添加控制器时，Console 会记录一条日志，并注明角色名称：

```
[ConvaiConversationFlowController] Added to '<character name>' because an embodiment module on this character needs the dialogue state. Add the component yourself if you want to configure it.
```

自动添加的控制器与手动添加的控制器行为完全相同。有关调整或替换控制器的方法，请参阅 [配置 Conversation Flow](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/configure.md) 。

{% hint style="info" %}
支撑 `Current`, `IConversationFlowSource`的契约是包内部的。请读取控制器的 `Current` 属性并订阅 `Changed` — 直接使用，不要自行实现该接口。
{% endhint %}

***

### 探索对话流程

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>配置对话流程</strong><br>添加控制器，或依赖自动创建，然后为其分配配置文件以调整时序。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/configure.md">配置对话流程</a></td></tr><tr><td><strong>对话流程参考</strong><br>控制器的公共 API、它返回的对话状态读取结果，以及每个配置文件字段。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/reference.md">对话流程参考</a></td></tr><tr><td><strong>排查对话流程问题</strong><br>诊断状态卡在 Idle、时序不符合预期以及多角色冲突等问题。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/troubleshooting.md">排查对话流程问题</a></td></tr></tbody></table>

***

### 后续步骤

{% content-ref url="/pages/9aa58b1250604b0f44e22f31b27c7ffe4a02efeb" %}
[对话状态](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/dialogue-state.md)
{% endcontent-ref %}

{% content-ref url="/pages/491cfe5f38fba67eb46308256f5d4fa1ba67cda0" %}
[角色具身化](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/character-embodiment.md)
{% endcontent-ref %}

{% content-ref url="/pages/528b8780a5fa83913d2d3f95cdbf6b1a0c52b073" %}
[具身化如何运作](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/how-embodiment-works.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
