> 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/narrative-design/narrative-design-blueprint-reference.md).

# 叙事设计 Blueprint 参考

Narrative design API 中 UConvaiChatbotComponent 上 Blueprint 函数、事件、属性和叙事结构体的参考。

叙事设计 API 包含两个部分： `UConvaiChatbotComponent` （蓝图显示名称为 **Convai Chatbot**）上的实例函数和事件，以及位于 **Convai|REST API** 下的独立异步获取节点，用于从 Convai 查询叙事数据。以下结构体描述了这两部分使用的数据形状。

### 异步获取节点

这些节点是独立的潜伏式蓝图函数，不是 `UConvaiChatbotComponent`的方法。它们会向 Convai 发送 HTTPS POST 请求，并通过 **On Success** / **On Failure** 执行引脚返回数据。有关用法说明，请参阅 [获取叙事数据](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/fetching-narrative-data.md) 。

#### Convai Fetch Narrative Sections

C++ 类： `UFetchNarrativeSectionsProxy`\
蓝图显示名称： **Convai Fetch Narrative Sections**\
类别： `Convai|REST API`\
访问方式： `BlueprintCallable` （潜伏式异步代理）\
端点： `character/narrative/list-sections`

| 引脚                   | 方向     | 类型                          | 说明                                      |
| -------------------- | ------ | --------------------------- | --------------------------------------- |
| `CharacterId`        | 输入     | `FString`                   | 要查询的角色 ID。                              |
| `On Success`         | 输出（执行） | —                           | HTTP 请求成功且分区已解析到输出数组时触发。                |
| `On Failure`         | 输出（执行） | —                           | 激活验证失败、响应指针无效，或 HTTP 响应不在 `2xx` 范围内时触发。 |
| `Narrative Sections` | 输出     | `TArray<FNarrativeSection>` | 返回的分区。失败时为空。                            |

**日志类别：** `ConvaiNarrativeHTTP`

| 消息                                                                    | 当                   |
| --------------------------------------------------------------------- | ------------------- |
| `Could not get a pointer to world!`                                   | 激活时世界上下文无效。         |
| `Could not get a pointer to http module!`                             | HTTP 模块不可用。         |
| `UFetchNarrativeSectionsProxy::Activate Invalid Character or API key` | 身份验证密钥或角色 ID 未通过验证。 |
| `HTTP request failed with code %d`                                    | HTTP 响应状态码不是 2xx。   |

如果 HTTP 请求成功，但响应数组无法解析为 `FNarrativeSection` 个条目，代理可能会直接返回，而不会触发 **成功时** 或 **失败时**.

***

#### Convai 获取叙事触发器

C++ 类： `UFetchNarrativeTriggersProxy`\
蓝图显示名称： **Convai 获取叙事触发器**\
类别： `Convai|REST API`\
访问权限： `BlueprintCallable` （潜在异步代理）\
端点： `character/narrative/list-triggers`

| 引脚            | 方向     | 类型                          | 说明                                      |
| ------------- | ------ | --------------------------- | --------------------------------------- |
| `CharacterId` | 输入     | `FString`                   | 要查询的角色 ID。                              |
| `On Success`  | 输出（执行） | —                           | HTTP 请求成功且触发器已解析到输出数组时触发。               |
| `On Failure`  | 输出（执行） | —                           | 激活验证失败、响应指针无效，或 HTTP 响应不在 `2xx` 范围内时触发。 |
| `叙事触发器`       | 输出     | `TArray<FNarrativeTrigger>` | 返回的触发器。失败时为空。                           |

**日志类别：** `ConvaiNarrativeHTTP`

| 消息                                                                    | 当                   |
| --------------------------------------------------------------------- | ------------------- |
| `Could not get a pointer to world!`                                   | 激活时世界上下文无效。         |
| `Could not get a pointer to http module!`                             | HTTP 模块不可用。         |
| `UFetchNarrativeTriggersProxy::Activate Invalid Character or API key` | 身份验证密钥或角色 ID 未通过验证。 |
| `HTTP request failed with code %d`                                    | HTTP 响应状态码不是 2xx。   |

如果 HTTP 请求成功，但响应数组无法解析为 `FNarrativeTrigger` 个条目，代理可能会直接返回，而不会触发 **成功时** 或 **失败时**.

***

### UConvaiChatbotComponent 上的函数 `UConvaiChatbotComponent`

#### Invoke Narrative Design Trigger

C++ 名称： `InvokeNarrativeDesignTrigger`\
类别： `Convai`\
访问权限： `BlueprintCallable`

通过 `SendTriggerMessage` 发送一个命名触发器，作为 `trigger-message` 数据包，其中包含 `trigger_name`。断开连接时，会将触发器排入 `PendingTriggers` 队列，并在会话连接后重新发送。

| 参数                     | 类型        | 说明                      |
| ---------------------- | --------- | ----------------------- |
| `TriggerName`          | `FString` | 触发器名称。必须与控制面板配置完全一致。    |
| `InGenerateActions`    | `bool`    | 存在于蓝图签名中。当前插件源代码未应用此参数。 |
| `InReplicateOnNetwork` | `bool`    | 存在于蓝图签名中。当前插件源代码未应用此参数。 |

返回：无。

**日志类别：** `ConvaiChatbotComponentLog`

| 消息                                                                                  | 当                 |
| ----------------------------------------------------------------------------------- | ----------------- |
| `Invoke Narrative Design Trigger: TriggerName is missing`                           | `TriggerName` 为空。 |
| `Invoke Narrative Design Trigger: Executed \| Character ID : %s \| Session ID : %s` | 触发器已接受，等待发送或排队。   |

***

#### Invoke Speech

C++ 名称： `ExecuteNarrativeTrigger`\
类别： `Convai`\
访问权限： `BlueprintCallable`

通过 `AddContextEvent` 并使用 `EC_RunLLMOption::Always`暂存动态上下文事件。不会发送 `trigger-message` 数据包，也不会使用 `PendingTriggers`.

| 参数                     | 类型        | 说明                      |
| ---------------------- | --------- | ----------------------- |
| `TriggerMessage`       | `FString` | 作为上下文事件暂存的消息字符串。        |
| `InGenerateActions`    | `bool`    | 存在于蓝图签名中。当前插件源代码未应用此参数。 |
| `InReplicateOnNetwork` | `bool`    | 存在于蓝图签名中。当前插件源代码未应用此参数。 |

返回：无。

**日志类别：** `ConvaiChatbotComponentLog`

| 消息                                                                | 当                    |
| ----------------------------------------------------------------- | -------------------- |
| `Invoke Speech: TriggerMessage is missing`                        | `TriggerMessage` 为空。 |
| `Invoke Speech: Executed \| Character ID : %s \| Session ID : %s` | 消息已接受并暂存。            |

***

### 上的事件 `UConvaiChatbotComponent`

#### 收到叙事章节时

C++ 名称： `OnNarrativeSectionReceivedEvent`\
类别： `Convai`\
访问权限： `BlueprintAssignable`

Convai 返回 `BTResponse` 数据包时触发，并传递该数据包中的 `narrative_section_id`。插件会广播此事件，不会检查 ID 是否为新值或非空。

| 参数                   | 类型                         | 说明                                               |
| -------------------- | -------------------------- | ------------------------------------------------ |
| `ChatbotComponent`   | `UConvaiChatbotComponent*` | 接收到章节更新的组件。                                      |
| `NarrativeSectionID` | `FString`                  | 来自 `narrative_section_id` 值，取自 `BTResponse` 数据包。 |

***

### UConvaiChatbotComponent 上的属性 `UConvaiChatbotComponent`

#### 叙事模板键

C++ 名称： `NarrativeTemplateKeys`\
类型： `TMap<FString, FString>`\
类别： `Convai|NarrativeDesign`\
访问权限： `BlueprintReadWrite, EditAnywhere`\
蓝图 setter： `UpdateNarrativeTemplateKeys` (`BlueprintInternalUseOnly`)

通过以下接口发送给 Convai 的键值对： `update-template-keys` 会话连接后。赋值给此属性会触发 `UpdateNarrativeTemplateKeys`，该函数会存储此映射，并在会话代理处于活动状态时发送它。

#### bAutoInitializeSession

C++ 名称： `bAutoInitializeSession`\
类型： `bool`\
类别： `Convai|Session`\
访问权限： `BlueprintReadWrite, EditAnywhere`\
默认值： `true`

当值为 `true`时，会在 `StartSession` 的 **Begin Play**.

***

### 叙事结构体

这些结构体属于 `BlueprintType`。标记为 `BlueprintReadOnly` 的字段可在蓝图中查看。它们描述了 Convai 控制面板中定义的章节、触发器和决策的数据模型。

#### FNarrativeSection

表示叙事图中的一个章节（故事节拍）。

| 字段                       | 类型                           | 蓝图访问权限 | 说明                                       |
| ------------------------ | ---------------------------- | ------ | ---------------------------------------- |
| `section_id`             | `FString`                    | 只读     | 此章节的唯一标识符。                               |
| `section_name`           | `FString`                    | 只读     | 在控制面板中显示的易读名称。                           |
| `objective`              | `FString`                    | 只读     | 此部分的行为目标。                                |
| `character_id`           | `FString`                    | 只读     | 此部分所属的角色。                                |
| `behavior_tree_code`     | `FString`                    | 只读     | 用于高级自动化的行为树代码（可以为空）。                     |
| `bt_constants`           | `FString`                    | 只读     | 被以下内容引用的常量： `behavior_tree_code` （可以为空）。 |
| `decisions`              | `TArray<FNarrativeDecision>` | 只读     | 此部分的出站决策规则。                              |
| `parents`                | `TArray<FString>`            | 只读     | 图中父级部分的部分 ID。                            |
| `updated_character_data` | `TMap<FString, FString>`     | 只读     | 此部分激活时应用的角色数据覆盖项。                        |

***

#### FNarrativeTrigger

表示部分之间具有名称的触发边。

| 字段                    | 类型        | 蓝图访问权限 | 说明                           |
| --------------------- | --------- | ------ | ---------------------------- |
| `trigger_id`          | `FString` | 只读     | 此触发器的唯一标识符。                  |
| `trigger_name`        | `FString` | 只读     | 与以下内容匹配的名称： **调用叙事设计触发器**.   |
| `trigger_message`     | `FString` | 只读     | 与触发器关联的消息内容。                 |
| `destination_section` | `FString` | 只读     | 触发器触发时，图将前进到的 `section_id` 。 |

***

#### FNarrativeDecision

表示部分中的一条出站决策规则。

| 字段                | 类型        | 蓝图访问权限 | 说明                        |
| ----------------- | --------- | ------ | ------------------------- |
| `criteria`        | `FString` | 只读     | 此决策适用的条件。                 |
| `next_section_id` | `FString` | 只读     | 满足条件时要前进到的 `section_id` 。 |
| `priority`        | `int32`   | 只读     | 此决策规则的数值优先级。默认值： `0`.     |

***

### 相关页面

{% content-ref url="/pages/ff19704aac20f7d6e4bf5c3214636ccbe4248151" %}
[叙事触发器](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/narrative-triggers.md)
{% endcontent-ref %}

{% content-ref url="/pages/453cd3ea71434b9c4a8a7da307779eeb39996f99" %}
[模板键](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/template-keys.md)
{% endcontent-ref %}

{% content-ref url="/pages/01a30a9c684189ac16deee8b6b420f60eb8252f8" %}
[获取叙事数据](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/fetching-narrative-data.md)
{% endcontent-ref %}

{% content-ref url="/pages/78fce7020677f54bda05ede0262a6996390ed909" %}
[叙事设计使用示例](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/narrative-design-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/narrative-design/narrative-design-blueprint-reference.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.
