> 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-unreal-engine-plugin/features/long-term-memory/speaker-id-management.md).

# Speaker ID 管理

Speaker ID 是 Convai 身份记录，用于长期记忆工作流。每个玩家创建一条记录，保存其 `SpeakerID`，并将该值分配为 `EndUserID` ，在开始会话之前。有关分配步骤，请参阅 [最终用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### FConvaiSpeakerInfo

`FConvaiSpeakerInfo` 是由 **Convai 创建 Speaker ID** 和 **Convai 列出 Speaker ID**.

| 字段          | 类型        | 描述                                      |
| ----------- | --------- | --------------------------------------- |
| `SpeakerID` | `FString` | Convai 分配的标识符。请保存此值并将其再次用作 `EndUserID`. |
| `名称`        | `FString` | Convai 返回的发言人名称。                        |
| `DeviceID`  | `FString` | Convai 返回的设备 ID。未提供或未返回设备 ID 时为空。       |

### 创建一个 Speaker ID

使用 **Convai 创建 Speaker ID** 在首次创建玩家配置文件时。

{% stepper %}
{% step %}

#### 添加该节点

在配置文件设置期间运行的 Blueprint 中，添加 **Convai 创建 Speaker ID** 来自 `Convai|LTM` 类别下的字段中。
{% endstep %}

{% step %}

#### 设置输入

设置 **Speaker 名称** 为非空的玩家显示名称。将 **Device Id** 如果可用，则设置为稳定的设备或账户标识符。

如果 **Speaker 名称** 为空时，插件会记录 `发言人名称为空` 并触发 **On Failure** ，然后再发送请求。
{% endstep %}

{% step %}

#### 持久化结果

在 **成功时**，拆分返回的 `FConvaiSpeakerInfo` 并保存 `SpeakerID` 到你的 `SaveGame` 或账户配置文件中加载。

在后续启动时，加载已保存的值并跳过记录创建。
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
不要在游戏每次启动时都创建新的 Speaker ID。重复创建会为同一玩家生成多条记录，这会使身份调试更加困难。
{% endhint %}

### 列出 Speaker ID

使用 **Convai 列出 Speaker ID** 以检查为已配置 API 密钥可用的记录。

1. Add **Convai 列出 Speaker ID** 来自 `Convai|LTM` 类别下的字段中。
2. Bind **成功时**.
3. 遍历返回的 `FConvaiSpeakerInfo` 数组。
4. 打印或显示 `SpeakerID`, `名称`，以及 `DeviceID`.

这对于测试工具、管理面板以及调试共享设备身份问题很有用。

### 删除一个 Speaker ID

使用 **Convai 删除 Speaker ID** 当需要移除玩家身份时。

{% stepper %}
{% step %}

#### 选择该记录

找到目标 `SpeakerID` 从你保存的配置文件数据中，或从 **Convai 列出 Speaker ID**.
{% endstep %}

{% step %}

#### 调用删除节点

Add **Convai 删除 Speaker ID** 并设置 **Speaker ID** 为目标值。

在 **成功时**，清除已存储的 `SpeakerID` 从你的保存数据中，以免项目重新使用已删除的身份。
{% endstep %}

{% step %}

#### 如有需要，创建新身份

如果玩家应继续使用 LTM，则创建一个新的 Speaker ID，并将其分配为下一个 `EndUserID`。参见 [最终用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).
{% endstep %}
{% endstepper %}

{% hint style="danger" %}
删除终端用户身份会移除该用户记录以及该用户在所有角色中的相关长期记忆记录。在向玩家或管理员公开此操作之前，请添加确认步骤。
{% endhint %}

### 何时使用各项操作

| 目标               | 操作                          |
| ---------------- | --------------------------- |
| 注册首次玩家           | **Convai 创建 Speaker ID**    |
| 重用回归玩家的记忆        | 加载已保存的 `SpeakerID`；不要再次调用创建 |
| 审核身份记录           | **Convai 列出 Speaker ID**    |
| 移除测试或用户身份        | **Convai 删除 Speaker ID**    |
| 在不删除身份的情况下开始新的对话 | `ResetConversation()`       |

### 下一步

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[最终用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md)
{% endcontent-ref %}

{% content-ref url="/pages/d52ddbffaafeb3f6c5f97016d40633bc7ea09f16" %}
[LTM Blueprint 参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/ltm-blueprint-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/fe714c4b4449c797215a2b49fe82fef8879c959a" %}
[长期记忆使用示例](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-usage-examples.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:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/speaker-id-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
