> 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/long-term-memory-quick-start.md).

# 长期记忆快速开始

为 Unreal 角色设置长期记忆，分配稳定的玩家身份，并确认在 Play In Editor 会话之间的回忆。

为一个正在运行的 Convai 角色设置长期记忆，然后确认该角色在稍后的一次编辑器中运行（Play In Editor）会话中回忆起同一个玩家。

### 前提条件

* Convai 虚幻引擎插件版本 <code class="expression">space.vars.unreal\_plugin\_version</code> 已安装且 API 密钥已配置。请参见 [安装 Convai 虚幻引擎插件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/install-the-convai-plugin.md).
* 一个关卡包含一个 `UConvaiChatbotComponent` 在 AI 角色上有一个 `UConvaiPlayerComponent` 在玩家 Actor 上。
* 聊天机器人组件具有一个有效的 `CharacterID` 来自 Convai 仪表板的

{% hint style="info" %}
本教程使用 Speaker ID 工作流。有关账户 ID 或设备回退策略，请参见 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md)。在 Convai 仪表板中，新角色默认禁用记忆——在测试回忆之前请先启用它。
{% endhint %}

### 启用记忆并连接身份

{% stepper %}
{% step %}

#### 为角色启用 LTM

在开发蓝图中，添加 **Convai 设置 LTM 状态** 来自 `Convai|LTM` 类别。

设置 **角色 ID** 到来自 Convai 仪表板的角色 ID。将 **B 启用** 到 `true`。连接 **成功时** 到一个 **Print String** 节点，以便你确认请求已完成。

为了持续验证，请使用 **Convai 获取 LTM 状态** 使用相同的 **角色 ID**.
{% endstep %}

{% step %}

#### 获取稳定的 EndUserID

调用 **Convai 创建 Speaker ID** 玩家第一次使用你的项目时。在 **成功时**，保存返回的 `SpeakerID` 来自 `FConvaiSpeakerInfo` 到一个 `SaveGame` 或账户配置文件中。

在后续启动时，加载已保存的 `SpeakerID` ，而不是创建新记录。有关完整的创建、列出和删除流程，请参见 [Speaker ID 管理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/speaker-id-management.md).
{% endstep %}

{% step %}

#### 分配身份并开始会话

在调用 `StartSession`之前，先将已保存的 `SpeakerID` 作为 `EndUserID` 分配到两个组件上：

* 设置 `EndUserID` 在 **Convai Chatbot** 详情面板中的组件或通过蓝图中的组件。
* 设置 `EndUserID` 在 **Convai 播放器** 详情面板中的组件或通过蓝图中的组件。

聊天机器人 `EndUserID` 是在连接时发送给 Convai 的值。调用 `StartSession` 在两个值都设置后，在聊天机器人组件上执行。
{% endstep %}
{% endstepper %}

{% hint style="success" %}
当 **Convai 获取 LTM 状态** 返回 `true` 并且聊天机器人 `EndUserID` 在每次 `StartSession`.
{% endhint %}

### 验证跨会话回忆

1. 按 **播放**.
2. 告诉角色一个持久事实，例如 `我的名字是 Alex，我检查安全阀。`
3. 让对话继续足够长，以便角色做出回应。
4. 停止在编辑器中播放。
5. 按 **播放** 再次。
6. 恢复相同的 `EndUserID` 在聊天机器人和玩家组件上，在 `StartSession`.
7. 询问 `你还记得我检查什么吗？`

角色应使用之前的事实进行回应。如果它是从头开始的，请参见 [排查长期记忆问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/troubleshoot-long-term-memory.md).

### 下一步

{% content-ref url="/pages/9df4cda7b4a29ebef0a84953231ee1b61e2d4c9f" %}
[长期记忆的工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/how-long-term-memory-works.md)
{% endcontent-ref %}

{% 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/02906b279025410eed0c91dd64f1012b0304b626" %}
[为角色配置记忆](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/configure-memory-for-a-character.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/long-term-memory-quick-start.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.
