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

# 长期记忆快速入门

为一个可正常工作的 Convai 角色设置长期记忆，然后确认该角色在稍后的 Play In Editor 会话中能记住同一位玩家。

### 先决条件

* Convai Unreal Engine 插件版本 <code class="expression">space.vars.unreal\_plugin\_version</code> 已安装且 API 密钥已配置。参见 [安装 Convai Unreal Engine 插件](/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

在开发用 Blueprint 中，添加 **Convai Set LTM Status** 来自 `Convai|LTM` 类别。

将 **角色 ID** 将其设置为 Convai 仪表板中的角色 ID。设置 **B 启用** 设为 `true`. 连接 **成功时** 到一个 **打印字符串** 节点，这样你就可以确认请求已完成。

如需持续验证，请使用 **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** 在 Details 面板中的组件，或通过 Blueprint。
* 将 `EndUserID` 在该 **Convai Player** 在 Details 面板中的组件，或通过 Blueprint。

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

{% hint style="success" %}
当以下条件满足时，设置就绪： **Convai 获取 LTM 状态** 返回 `true` 以及聊天机器人 `EndUserID` 在每次之前都设置为非空值 `StartSession`.
{% endhint %}

### 验证跨会话回忆

1. 按 **Play**.
2. 告诉角色一个持久事实，例如 `我叫 Alex，我检查安全阀。`
3. 让对话继续足够长的时间，以便角色作出回应。
4. 停止 Play In Editor。
5. 按 **Play** 再次。
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 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/long-term-memory-quick-start.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.
