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

# 说话者 ID 管理

从 Unreal Blueprints 中创建、列出和删除说话者 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 返回的 Speaker 名称。                         |
| `DeviceID`  | `FString` | Convai 返回的设备 ID。当未提供或未返回设备 ID 时为空。             |

### 创建 Speaker ID

使用 **Convai 创建 Speaker ID** 在首次创建玩家资料时。

{% stepper %}
{% step %}

#### 添加节点

在配置资料期间运行的 Blueprint 中，添加 **Convai 创建 Speaker ID** 来自 `Convai|LTM` 类别。
{% endstep %}

{% step %}

#### 设置输入

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

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

{% step %}

#### 持久化结果

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

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

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

### 列出 Speaker ID

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

1. 添加 **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 %}

#### 调用删除节点

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