> 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`）是角色对其对话状态唯一由作者指定的事实来源。它暴露一个 `当前` 读取属性和一个 `Changed` 事件；没有其他实体模块会重新定义或推断这个状态的自己的版本。参见 [对话状态](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/dialogue-state.md) 了解这八种状态各自的含义，以及角色何时进入它。

***

### 一次发言轮次如何结束

发言轮次在角色自己的声音停止的那一刻就结束，而不是在 Convai 确认轮次结束时结束。Convai 的轮次完成确认是在声音已经结束之后才发送的，因此等待该确认的角色会一直保持表演状态，直到该消息到达为止。控制器则在本地监测，并在 `说话中` 一旦它有本地证据表明回复已结束，就会立刻，而每个读取 `说话中` ——其中包括 Body Animation 的说话层——也会从同一时刻开始收尾。

有两种本地证据来源会驱动这一过程，控制器会优先响应最先报告结束的那一个：

* **角色的声音。** 两句话之间的间隔听起来和结束一样，因此控制器会等待 `0.4` 秒后，才将沉默视为该轮次的结束。
* **Lip Sync（如果角色具备）。** 语音动画会先于其对应的音频到达，因此 Lip Sync 在声音到来之前就知道回复在哪里结束，无需等待。

这是固定行为——对每个角色都一样，而且不能在 `ConvaiConversationFlowProfile`。控制器在本地证据表明你已经开始说话的那一刻也会察觉到你，比 Convai 确认已听到你更早——这是轮次的另一端，同样是固定的。参见 [Conversation flow 参考](/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 在状态存在时会读取它，但会优雅降级为 `空闲` 而不是由它们自己来预配控制器。当 Convai 添加一个时，Console 会记录一条日志，并标明角色名称：

```
[ConvaiConversationFlowController] 已添加到“<character name>”，因为该角色上的某个实体模块需要对话状态。如果你想配置它，请自行添加该组件。
```

自动添加的控制器行为与您手动添加的完全相同——参见 [配置 conversation flow](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/configure.md) 以调整或替换它。

{% hint style="info" %}
背后的契约 `当前`, `IConversationFlowSource`，属于包内部实现。读取控制器的 `当前` 属性，并订阅 `Changed` 即可——不要自行实现该接口。
{% endhint %}

***

### 探索 conversation flow

<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>配置 conversation flow</strong><br>添加控制器，或依赖自动创建，然后分配一个配置文件以调整其时序。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/configure.md">配置对话流程</a></td></tr><tr><td><strong>Conversation flow 参考</strong><br>控制器的公共 API、它返回的对话状态读取值，以及每个配置文件字段。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/conversation-flow/reference.md">对话流程参考</a></td></tr><tr><td><strong>排查 conversation flow 问题</strong><br>诊断停留在 Idle 的状态、感觉不对的时序，以及多角色冲突。</td><td><a href="/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" %}
[对话状态](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/dialogue-state.md)
{% endcontent-ref %}

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

{% content-ref url="/pages/528b8780a5fa83913d2d3f95cdbf6b1a0c52b073" %}
[具身化如何运作](/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.
