> 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` 。有关指定步骤，请参阅 [终端用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### FConvaiSpeakerInfo

`FConvaiSpeakerInfo` 是以下节点返回的结构体： **Convai Create Speaker ID** 和 **Convai List Speaker IDs**.

| 字段          | 类型        | 说明                                         |
| ----------- | --------- | ------------------------------------------ |
| `SpeakerID` | `FString` | 由 Convai 分配的标识符。请保存此值，并将其重复用作 `EndUserID`. |
| `Name`      | `FString` | Convai 返回的说话人名称。                           |
| `DeviceID`  | `FString` | Convai 返回的设备 ID。如果未提供或未返回设备 ID，则为空。        |

### 创建 Speaker ID

在首次创建玩家档案时使用 **Convai Create Speaker ID** 节点。

{% stepper %}
{% step %}

#### 添加节点

在档案设置期间运行的蓝图中，添加 **Convai Create Speaker ID** 节点，该节点位于 `Convai|LTM` 类别中。
{% endstep %}

{% step %}

#### 设置输入

将 **Speaker Name** 设为非空的玩家显示名称。如果有稳定的设备或账户标识符，请将 **Device Id** 设为该标识符。

如果 **Speaker Name** 为空，插件会记录日志 `Speaker name is empty` ，并在发送请求前触发 **On Failure** 。
{% endstep %}

{% step %}

#### 保存结果

在 **On Success**时，拆分返回的 `FConvaiSpeakerInfo` ，并将 `SpeakerID` 保存到你的 `SaveGame` 或账户个人资料。

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

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

### 列出 Speaker ID

使用 **Convai List Speaker IDs** 检查配置的 API 密钥可访问的记录。

1. 从 **Convai List Speaker IDs** 类别中添加 `Convai|LTM` 。
2. 绑定 **成功时**.
3. 遍历返回的 `FConvaiSpeakerInfo` 数组。
4. 打印或显示 `SpeakerID`, `Name`和 `DeviceID`.

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

### 删除 Speaker ID

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

{% stepper %}
{% step %}

#### 选择记录

查找目标 `SpeakerID` ，可以从已保存的个人资料数据中查找，也可以通过 **Convai List Speaker IDs**.
{% endstep %}

{% step %}

#### 调用删除节点

添加 **Convai Delete Speaker ID** 并将 **Speaker ID** 设为目标值。

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

{% step %}

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

如果玩家需要继续使用 LTM，请创建新的 Speaker ID，并将其设为下一个 `EndUserID`。请参阅 [最终用户身份](https://docs.convai.com/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 创建说话者 ID**              |
| 复用回归玩家的记忆     | 加载已保存的 `SpeakerID`；不要再次调用 create |
| 审计身份记录        | **Convai 列出说话者 ID**              |
| 移除测试身份或用户身份   | **Convai 删除说话者 ID**              |
| 开始全新对话，但不删除身份 | `ResetConversation()`            |

### 后续步骤

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[终端用户身份](https://docs.convai.com/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 参考](https://docs.convai.com/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" %}
[长期记忆使用示例](https://docs.convai.com/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.
