> 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 是一个 embodiment 模块，用来决定角色的对话状态——空闲、倾听、思考或说话——而其他所有 embodiment 模块都会读取这个状态，而不是追踪自己的一份版本。你很少需要手动添加它：当另一个模块需要读取对话状态时，Convai 会自动添加一个控制器。本页解释该模块负责什么，以及依赖它的模块为何会表现得如此。

***

### Conversation Flow 负责什么

`ConvaiConversationFlowController` (`SDK/Modules/ConversationFlow/Components/ConvaiConversationFlowController.cs`) 是角色关于其对话状态的唯一权威来源。它提供一个 `Current` 读取项和一个 `已变更` 事件；没有其他 embodiment 模块会重新定义或推断它自己的这个状态版本。请参见 [对话状态](/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>”，因为该角色上的某个 embodiment 模块需要对话状态。如果你想自行配置它，请手动添加该组件。
```

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

{% hint style="info" %}
其背后的契约 `Current`, `IConversationFlowSource`，是包内部实现。请直接读取控制器的 `Current` 属性并订阅 `已变更` ——不要自己实现这个接口。
{% 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>添加控制器，或依赖自动创建，然后分配一个 profile 来调整其时序。</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、它返回的对话状态读取结果，以及每个 profile 字段。</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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
