> 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/api-can-kao/core-api-reference/character-crafting-apis/narrative-design-api.md).

# 叙事设计 API

## 切换叙事设计

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/toggle-is-narrative-driven`

为你的角色启用/禁用叙事图。

#### 请求头

<table><thead><tr><th width="211">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称                    | 类型  | 说明                            |
| --------------------- | --- | ----------------------------- |
| character\_id         | 字符串 | 你的角色 ID。                      |
| is\_narrative\_driven | 布尔  | 将其设置为 true 或 false，以启用或禁用叙事图。 |

{% tabs %}
{% tab title="200：OK " %}

```json
{"STATUS": "成功"}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/toggle-is-narrative-driven"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id": "<Your-Character-Id>",
    "is_narrative_driven": True
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/toggle-is-narrative-driven" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{"character_id": "<Your-Character-Id>", "is_narrative_driven": true}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 创建章节

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/create-section`

为你的角色创建新章节。

#### 请求头

<table><thead><tr><th width="211">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称                       | 类型   | 说明              |
| ------------------------ | ---- | --------------- |
| character\_id            | 字符串  | 你的角色 ID。        |
| objective                | 字符串  | 章节目标            |
| section\_name            | 字符串  | 章节名称。           |
| updated\_character\_data | JSON | \*忽略\* 此字段未被使用。 |
| behavior\_tree\_code     | 字符串  | \*忽略\* 此字段未被使用。 |
| bt\_constants            | 字符串  | \*忽略\* 此字段未被使用。 |

{% tabs %}
{% tab title="200：OK 章节已创建 " %}

```json
{
    "section_id": "<New-Section-Id>"
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/create-section"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
    "objective":"章节目标",
    "section_name":"章节名称",
    "updated_character_data":{},
    "behavior_tree_code":"",
    "bt_constants":""
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/create-section" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Your-Character-Id>",
         "objective": "章节目标",
         "section_name": "章节名称",
         "updated_character_data": {},
         "behavior_tree_code": "",
         "bt_constants": ""
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 编辑章节

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/edit-section`

编辑你角色的章节。你应将想要更新的该章节所有字段通过 updated\_character\_data JSON 发送。以下为有效键。

* "section\_name"
* "objective"
* "decisions": 这是一个 JSON 列表。列表中的每个条目应具有以下格式。

  ```
  {
      "criteria":"决策条件",
      "next_section_id":"要跳转到的章节 ID"
  }
  ```

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称                       | 类型   | 说明         |
| ------------------------ | ---- | ---------- |
| character\_id            | 字符串  | 你的角色 ID。   |
| updated\_character\_data | JSON | 包含已更新的字段。  |
| section\_id              | 字符串  | 要更新的章节 ID。 |

{% tabs %}
{% tab title="200：OK 章节已更新 " %}

```json
{
    "status": "success",
    "section_id": "<Section-Id>",
    "updated_data": {
        "objective": "新的目标。"
    }
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/edit-section"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
    "section_id":"<Section-Id->",
    "updated_data":{
        "decisions":[
            {"criteria":"用户同意参加导览。", "next_section_id":"b9d7f568-7d06-11ef-be6a-42010a7be011"}
        ],  
        "objective":"向用户提供博物馆导览。",
        "section_name":"欢迎章节"
    }   
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/edit-section" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Your-Character-Id>",
         "section_id": "<Section-Id->",
         "updated_data": {
             "decisions": [
                 {
                     "criteria": "用户同意参加导览。",
                     "next_section_id": "b9d7f568-7d06-11ef-be6a-42010a7be011"
                 }
             ],
             "objective": "向用户提供博物馆导览。",
             "section_name": "欢迎章节"
         }
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 获取章节

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/get-section`

获取你角色中某个特定叙事章节的详细信息。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明         |
| ------------- | --- | ---------- |
| character\_id | 字符串 | 你的角色 ID。   |
| section\_id   | 字符串 | 要获取的章节 ID。 |

{% tabs %}
{% tab title="200：OK 章节详情 " %}

```json
{
   "character_id": "<Your-CharacterId>",
   "section_id": "<Your-SectionId>",
   "objective": "向用户提供历史博物馆导览。",
   "decisions": [{"criteria": "用户同意参加导览。", "next_section_id": "12345568-7890-1123-4456-424242424242"}],
   "parents": null,
   "updated_character_data": {},
   "bt_constants": "",
   "behavior_tree_code": "",
   "section_name": "欢迎章节",
   "triggers": null,
   "node_position": []
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/get-section"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
    "section_id":"<Section-Id->", 
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/get-section" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
           "character_id": "<Your-Character-Id>",
           "section_id": "<Section-Id->"
         }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 列出章节

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/list-sections`

列出给定角色的所有叙事章节详情。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明       |
| ------------- | --- | -------- |
| character\_id | 字符串 | 你的角色 ID。 |

{% tabs %}
{% tab title="200：OK 章节详情列表 " %}

```json
[
  {
    "character_id": "<Your-Character-Id>",
    "section_id": "123456789-7ddd-dddd-bbbb-424242424242",
    "objective": "",
    "decisions": null,
    "parents": null,
    "updated_character_data": {},
    "bt_constants": "",
    "behavior_tree_code": "",
    "section_name": "章节 1",
    "triggers": null,
    "node_position": []
  },
  {
    "character_id": "<Your-Character-Id>",
    "section_id": "100000789-7ddd-dddd-bbbb-42424242424",
    "objective": "向用户提供历史博物馆导览。",
    "decisions": [
      {
        "criteria": "用户同意参加导览。",
        "next_section_id": "123456789-7ddd-dddd-bbbb-424242424242"
      }
    ],
    "parents": null,
    "updated_character_data": {},
    "bt_constants": "",
    "behavior_tree_code": "",
    "section_name": "欢迎章节",
    "triggers": null,
    "node_position": []
  }
]
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/list-sections"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/list-sections" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
           "character_id": "<Your-Character-Id>"
         }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 删除章节

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/delete-section`

删除你角色的一个叙事章节。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明         |
| ------------- | --- | ---------- |
| character\_id | 字符串 | 你的角色 ID。   |
| section\_id   | 字符串 | 要删除的章节 ID。 |

{% tabs %}
{% tab title="200：OK 章节已删除 " %}

```json
{"STATUS": "成功"}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/delete-section"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
    "section_id":"<Section-Id->", 
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/delete-section" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Your-Character-Id>",
         "section_id": "<Section-Id->"
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 创建触发器

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/create-trigger`

为你的角色创建一个新的触发器。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称                   | 类型  | 说明                                      |
| -------------------- | --- | --------------------------------------- |
| character\_id        | 字符串 | 你的角色 ID。                                |
| trigger\_name        | 字符串 | 触发器名称。对一个角色必须唯一。                        |
| trigger\_message     | 字符串 | 触发器消息。通常描述触发器被调用的事件。例如：用户进入了场景。         |
| desgination\_section | 字符串 | 此触发器的目标章节 ID。如果你不想将触发器连接到任何章节，请不要传递此字段。 |

{% tabs %}
{% tab title="200：OK 触发器已创建 " %}

```json
{
    "character_id": "<Your-Character-Id>,
    "trigger_id": "<ID-Of-The-Newly-Created-Trigger>",
    "trigger_name": "StartTrigger",
    "trigger_message": "用户已进入博物馆。",
    "destination_section": "<Destination-Section-ID>",
    "node_position": []
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/create-trigger"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Your-Character-Id>",
    "trigger_message":"用户已进入博物馆。",
    "trigger_name":"StartTrigger",
    "destination_section": "<Destination-Section-ID-to-connect-to>"
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/create-trigger" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Your-Character-Id>",
         "trigger_message": "用户已进入博物馆。",
         "trigger_name": "StartTrigger",
         "destination_section": "<Destination-Section-ID-to-connect-to>"
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 更新触发器

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/update-trigger`

编辑触发器。你应通过 updated\_data JSON 发送所有想要更新的字段。以下为有效键。

* "trigger\_name": 新的触发器名称。必须唯一。
* "trigger\_message": 新的触发器消息。
* "destination\_section": 触发器的新目标章节 ID。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型   | 说明          |
| ------------- | ---- | ----------- |
| character\_id | 字符串  | 你的角色 ID。    |
| updated\_data | JSON | 包含已更新的字段。   |
| trigger\_id   | 字符串  | 要更新的触发器 ID。 |

{% tabs %}
{% tab title="200：OK 触发器已更新 " %}

```json
{
    "STATUS": "Successful",
    "message": "触发器已成功更新"
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/update-trigger"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Character-Id>",
    "trigger_id": "<Trigger-Id>",
    "updated_data": {
        "destination_section":"<New-Destination-Section-Id>",
        "trigger_message":"用户已进入计算机历史博物馆"
    }   
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)                  
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/update-trigger" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Character-Id>",
         "trigger_id": "<Section-Id>",
         "updated_data": {
             "destination_section": "<New-Destination-Section-Id>",
             "trigger_message": "用户已进入计算机历史博物馆"
         }
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 删除触发器

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/delete-trigger`

删除现有触发器。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明          |
| ------------- | --- | ----------- |
| character\_id | 字符串 | 你的角色 ID。    |
| trigger\_id   | 字符串 | 要删除的触发器 ID。 |

{% tabs %}
{% tab title="200：OK 触发器已删除 " %}

```json
{
    "STATUS": "Successful",
    "message": "触发器已成功删除"
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/delete-trigger"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Character-Id>",
    "trigger_id": "<Trigger-Id>",  
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)                 
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/delete-trigger" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
         "character_id": "<Character-Id>",
         "trigger_id": "<Trigger-Id>"
     }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 获取触发器

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/get-trigger`

获取现有触发器的详细信息。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明          |
| ------------- | --- | ----------- |
| character\_id | 字符串 | 你的角色 ID。    |
| trigger\_id   | 字符串 | 要获取的触发器 ID。 |

{% tabs %}
{% tab title="200：OK 触发器详情 " %}

```json
{
    "character_id": "<Character-Id>",
    "trigger_id": "<Trigger-Id>",
    "trigger_name": "UserEntry",
    "trigger_message": "用户已进入博物馆。",
    "destination_section": null,
    "node_position": []
}
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/get-trigger"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Character-Id>",
    "trigger_id": "<Trigger-Id>",  
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)              
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/get-trigger" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{
           "character_id": "<Character-Id>",
           "trigger_id": "<Trigger-Id>"
         }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 列出触发器

<mark style="color:绿色;">`POST`</mark> `https://api.convai.com/character/narrative/list-triggers`

列出角色的所有触发器。

#### 请求头

<table><thead><tr><th width="226">名称</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>CONVAI-API-KEY<mark style="color:红色;">*</mark></td><td>字符串</td><td>每个用户提供的唯一 api-key。在登录 Convai 账户后，可在 Key 图标下找到。</td></tr></tbody></table>

#### 请求体

| 名称            | 类型  | 说明       |
| ------------- | --- | -------- |
| character\_id | 字符串 | 你的角色 ID。 |

{% tabs %}
{% tab title="200：OK 触发器详情列表 " %}

```json
[
  {
    "character_id": "<Character-Id>",
    "trigger_id": "<Trigger-ID1>",
    "trigger_name": "触发器 1",
    "trigger_message": "",
    "destination_section": null,
    "node_position": []
  },
  {
    "character_id": "<Character-Id>",
    "trigger_id": "<Trigger-ID2>",
    "trigger_name": "UserEntry",
    "trigger_message": "用户已进入博物馆。",
    "destination_section": null,
    "node_position": [ ]
  }
]
```

{% endtab %}

{% tab title="401 API 密钥验证失败" %}

```json
{
    "ERROR": "提供的 API 密钥无效。"
}
```

{% endtab %}
{% endtabs %}

以下是一些示例代码，用于演示该端点的请求格式 -->

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = "https://api.convai.com/character/narrative/list-triggers"
headers = { 
    'CONVAI-API-KEY': '<Your-API-Key>',
    'Content-Type': 'application/json'
}

# 为 JSON 负载创建一个字典
payload = { 
    "character_id":"<Character-Id>", 
}

# 将负载转换为 JSON
json_payload = json.dumps(payload)

response = requests.post(url, headers=headers, data=json_payload)

print(response.text)              
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```shell
curl -X POST "https://api.convai.com/character/narrative/list-triggers" \
     -H "CONVAI-API-KEY: <Your-API-Key>" \\
     -H "Content-Type: application/json" \
     -d '{"character_id":"<Character-Id>"}'
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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/api-can-kao/core-api-reference/character-crafting-apis/narrative-design-api.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.
