> 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-unity-sdk/embodiment/emotion/scripting-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.convai.com/api-docs/~gitbook/mcp).

# Emotion 脚本 API

介绍如何通过脚本读取角色的情绪状态、控制情绪、锁定或覆盖表情，以及订阅情绪事件。

Emotion 系统提供两种路径，用于在运行时响应和控制情绪状态。 **Inspector 路径** 使用 `ConvaiCharacterEventRelay` ——一个将原始情绪回调作为 Unity Events 暴露出来的组件，无需编写代码。另一种是 **脚本路径** 使用 `ConvaiEmotionController` ，它直接暴露完整的 C# API，用于读取组合状态、控制心情、注入覆盖值以及锁定表情。两种路径可以同时使用。有关短暂情绪与静息心情之间的概念区别，请参阅 [心情](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/moods.md).

### Inspector 路径 — ConvaiCharacterEventRelay

`ConvaiCharacterEventRelay` 是一个 MonoBehaviour，可将角色回调桥接到 Unity Events，让设计人员无需编写任何代码，即可完全在 Inspector 中配置情绪响应。

**添加组件：** **Convai → Events → Convai Character Event Relay**

将其放置在场景中的任意 GameObject 上。它会自动查找同一 GameObject 上的 `ConvaiCharacter` ，也可以通过 **Character** 字段指定其他 GameObject 上的角色。

#### Inspector 字段

| 字段                       | 默认值    | 说明                                               |
| ------------------------ | ------ | ------------------------------------------------ |
| `Character`              | *（无）*  | 对 `ConvaiCharacter`的可选显式引用。留空则使用自动解析。            |
| `Auto Resolve Character` | `true` | 启用后，中继器会自动查找同一 GameObject 上的 `ConvaiCharacter` 。 |

#### OnEmotionChanged 事件

中继器会公开一个 **On Emotion Changed** Unity Event，每当 Convai 发送原始情绪信号时就会触发。该事件会传递一个 `CharacterEmotionRelayData` 负载：

| 属性              | 类型       | 说明                             |
| --------------- | -------- | ------------------------------ |
| `CharacterId`   | `string` | 角色的唯一标识符。                      |
| `CharacterName` | `string` | 角色的显示名称（若无，则使用 GameObject 名称）。 |
| `Emotion`       | `string` | 服务器发送的原始标签（例如 `"happy"`).      |
| `Intensity`     | `int`    | Convai 发送的 1–3 整数刻度值。          |

**配置示例：** 添加一个 `ConvaiCharacterEventRelay` 到 NPC 的 GameObject 上。在 **On Emotion Changed** 列表中，点击 **+**，将 UI Text 组件拖入对象字段，然后选择 `Text.text` — 每次情绪变化时，标签都会自动更新。

`ConvaiCharacterEventRelay` 会在分类体系解析或平滑处理之前，针对原始服务器标签触发。可将其用于 UI 显示、音频提示或简单的分支逻辑。若要获取经过平滑处理和解析后的状态（包含分数和保持时间），请改用 `ConvaiEmotionController.Current` ，并在脚本中读取。

### 从脚本访问控制器

通过具体类型获取 `ConvaiEmotionController` ——它实现的跨模块契约（`IEmotionStateSource` 及相关接口）是 SDK 内部接口，不属于公共 API。

```csharp
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class EmotionDrivenBehavior : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    private void Awake()
    {
        if (emotionController == null)
            emotionController = GetComponentInChildren<ConvaiEmotionController>();
    }
}
```

### 读取当前情绪状态

`ConvaiEmotionController.Current` 返回一个 `EmotionReading` ——仅在合成状态发生变化时才会重建的不可变快照。可在 `Update` 中轮询，也可以在任意事件发生时对其作出响应。

```csharp
using Convai.Domain.Embodiment.Readings;
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class EmotionLogger : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    private void Update()
    {
        EmotionReading reading = emotionController.Current;

        if (!reading.IsNeutral)
            Debug.Log($"Dominant emotion: {reading.DominantLabel} ({reading.DominantScore:F2})");
    }
}
```

#### EmotionReading 属性和方法

| 成员                                                     | 类型                                   | 说明                                                                         |
| ------------------------------------------------------ | ------------------------------------ | -------------------------------------------------------------------------- |
| `DominantLabel`                                        | `string`                             | 得分最高的瞬态情绪的规范标签（例如 `"joy"`, `"anger"`).                                     |
| `DominantScore`                                        | `float`                              | 经过平滑处理和突发增强后，主导瞬态情绪的归一化分数 \[0–1]。                                          |
| `AllScores`                                            | `IReadOnlyDictionary<string, float>` | 按规范标签索引的完整分数表。分类体系中的每种情绪都有对应条目；本帧未产生贡献的情绪，其分数为 `0`.                        |
| `MouthInfluence`                                       | `float`                              | \[0–1] 范围的提示值，供 LipSync 合成器在非说话帧中用于混合口型。                                   |
| `DominantHoldSeconds`                                  | `float`                              | 当前主导标签持续保持的实际时间（秒）。                                                        |
| `MoodLabel`                                            | `string`                             | 角色已解析的静息情绪的规范标签——与 `DominantLabel`不同。请参阅 [运行时情绪控制](#runtime-mood-control). |
| `MoodScore`                                            | `float`                              | 归一化强度 \[0–1]，表示 `MoodLabel`.                                               |
| `IsNeutral`                                            | `bool`                               | `true` 当主导标签为 `"neutral"` 或当 `DominantScore ≤ 0`.                          |
| `NeutralLabel`                                         | `const string`                       | 字符串常量 `"neutral"`.                                                         |
| `GetScore(string canonicalLabel)`                      | `float`                              | 返回给定规范标签的平滑分数；如果不存在，则返回 `0` 。                                              |
| `CopyScoresTo(IDictionary<string, float> destination)` | `void`                               | 将完整分数表复制到由调用方拥有的字典中。复制前会清空目标字典。                                            |

#### CurrentFrame — 零分配帧视图

`ConvaiEmotionController.CurrentFrame` 返回一个 `EmotionStateFrame` ——它是同一组合状态的借用式零分配视图，在控制器的下一次 tick 前有效。在每帧的热点路径中，如果无需分配由调用方持有的副本，请优先使用它，而不是 `Current` 。

| 成员                                                        | 类型                                              | 说明                                                                                |
| --------------------------------------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------- |
| `Version`                                                 | `int`                                           | 每当帧内容发生变化时递增。                                                                     |
| `DominantLabel`, `DominantScore`                          | `string`, `float`                               | 含义与 `EmotionReading`.                                                             |
| `中的相同。`, `Scores`                                         | `IReadOnlyList<string>`, `IReadOnlyList<float>` | 涵盖分类体系中所有情绪的标签/分数列表，按索引对齐，由控制器持有。                                                 |
| `MoodLabel`, `MoodScore`                                  | `string`, `float`                               | 含义与 `EmotionReading`.                                                             |
| `Dimensions`                                              | `EmotionDimensions`                             | 主导情绪的 `Valence`/`Arousal`/`Agency`/`Approach` 信号。请参阅 [情绪维度](#emotion-dimensions). |
| `MouthInfluence`, `DominantHoldSeconds`                   | `float`                                         | 含义与 `EmotionReading`.                                                             |
| `IsNeutral`                                               | `bool`                                          | 含义与 `EmotionReading`.                                                             |
| `GetScore(int index)` / `GetScore(string canonicalLabel)` | `float`                                         | 通过索引查找分数，索引对应于 `Labels`/`Scores`；也可以通过规范标签查找。                                     |

### 已解析的状态和情绪

| 成员                                                                | 类型                      | 说明                                                                                                                                                                   |
| ----------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CurrentResolvedEmotion`                                          | `string`                | 经过分类体系解析、平滑处理和配置组合后的规范标签 — 等同于 `Current.DominantLabel`.                                                                                                              |
| `CurrentNormalizedIntensity`                                      | `float`                 | CurrentResolvedEmotion 的组合归一化强度 \[0, 1] `CurrentResolvedEmotion`.                                                                                                    |
| `CurrentMoodLabel`                                                | `string`                | 角色人格/气质的基础情绪所对应的规范标签。明确 **不是** 短暂的主导情绪。                                                                                                                              |
| `CurrentMoodScore`                                                | `float`                 | CurrentMoodLabel 的归一化强度 \[0, 1] `CurrentMoodLabel`.                                                                                                                  |
| `KnownEmotionLabels`                                              | `IReadOnlyList<string>` | 此角色的活动分类体系所识别的非中性规范标签，顺序与分类体系的编写顺序一致。管线构建完成前为空。                                                                                                                      |
| `TryResolveEmotionLabel(string label, out string canonicalLabel)` | `bool`                  | 根据活动分类体系（规范标签及其别名）解析 `label` ，并返回规范的非中性标签。以下情况会返回 `false` ：标签为空、无法解析、解析结果为分类体系的中性条目，或管线尚未构建。在调用 `SetMood`/`SetEmotionOverride`之前，请先使用此方法验证标签；否则，未知标签会被静默降级为中性，而不会报错。 |

```csharp
if (emotionController.TryResolveEmotionLabel(userSuppliedLabel, out string canonicalLabel))
    emotionController.SetMood(canonicalLabel, 0.6f);
else
    Debug.LogWarning($"'{userSuppliedLabel}' is not in this character's emotion vocabulary.");
```

### 创作时锁定

控制器有三个序列化字段，可直接在 Inspector 中将表情固定为特定情绪 — 适用于创作和调试，或无需进入 Play Mode 即可在 Scene 视图中预览表情效果。

| 字段                   | 类型       | 默认值         | 说明                                       |
| -------------------- | -------- | ----------- | ---------------------------------------- |
| `lockEmotion`        | `bool`   | `false`     | 启用后，将忽略所有传入的服务器情绪事件，角色会保持锁定的情绪。          |
| `lockedEmotionLabel` | `string` | `"neutral"` | lockEmotion `处于启用状态时要保持的规范分类标签。` 处于启用状态。 |
| `lockedIntensity`    | `float`  | `1.0`       | 锁定情绪的强度 \[0–1]。                          |

`ConvaiEmotionController` 继承自基类的 `[ExecuteAlways]` ，因此设置 `lockEmotion = true` 在 Inspector 中会立即更新 Scene 视图中的表情，无需进入 Play Mode。

{% hint style="danger" %}
`lockEmotion` 是一个 **序列化字段** ——其值会随场景或预制件一起保存。如果启用后忘记重置，角色在生产构建中就会静默忽略所有实时表情信号，且不会产生运行时错误或警告。构建前务必将其禁用。
{% endhint %}

### SetEmotionOverride 和 ClearEmotionOverride

`SetEmotionOverride` 会向累加器中注入额外的瞬时分数，叠加在 Convai 发送的内容之上。此覆盖值仍会经过平滑处理——它会以 `lerpSpeed`进行混合，而非立即生效。当应用逻辑需要根据场景内事件增强或引导瞬时表情时，可使用此方法。

```csharp
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class HazardZoneTrigger : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Trainee"))
            emotionController.SetEmotionOverride("fear", 0.9f);
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Trainee"))
            emotionController.ClearEmotionOverride();
    }
}
```

`ClearEmotionOverride` 会移除覆盖值，并使累加器恢复为由服务器驱动的状态。恢复过程会经过平滑处理。

### LockEmotion 和 UnlockEmotion

`LockEmotion` 会完全绕过累加器，将角色的表情直接切换为指定表情并保持不变，无论 Convai 发送什么内容。当脚本控制的序列需要确保表情稳定时，可使用此方法。

```csharp
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class WelcomeSequenceController : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    public void BeginWelcome()
    {
        emotionController.LockEmotion("joy", 0.75f);
    }

    public void EndWelcome()
    {
        emotionController.UnlockEmotion();
    }
}
```

`UnlockEmotion` 会解除锁定，并恢复锁定前处于活动状态的目标——如果当时有活动的 `SetEmotionOverride` ，则恢复该覆盖值；否则恢复为中性状态。累加器会继续响应服务器事件。

**API 签名：**

```csharp
void LockEmotion(string label, float intensity = 1f);
void UnlockEmotion();
void SetEmotionOverride(string label, float score);
void ClearEmotionOverride();
```

### 运行时心境控制

`SetMood` 和 `ClearMood` 可在运行时更改角色的 **静息心境** ——即角色在瞬时情绪之间回归的面部状态，不同于 `SetEmotionOverride`的瞬时通道。两者都会平滑交叉淡化，而非突然切换。有关心境的概念模型及其相对于角色档案中人格基线的优先级，请参阅 [心境](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/moods.md).

```csharp
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class MoodDirector : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    public void OnGoodNewsDelivered()
    {
        // 在 2 秒内逐渐过渡到更愉快的静息心境。
        emotionController.SetMood("joy", 0.5f, transitionSeconds: 2f);
    }

    public void OnSceneReset()
    {
        // 在默认的 1.5 秒过渡时间内恢复到设定的基线。
        emotionController.ClearMood();
    }
}
```

**API 签名：**

```csharp
void SetMood(string label, float intensity, float transitionSeconds = 1.5f);
void ClearMood(float transitionSeconds = 1.5f);
```

* `SetMood` 根据 `label` 通过角色当前启用的分类体系进行解析。标签为空或为中性、无法识别（每个标签只记录一次警告，然后回退），或者 `intensity` 为非正数时，都会过渡到“无情绪”，而不会抛出异常。
* `ClearMood` 会过渡回作者设定的基线——如果设置了该角色自己的静息情绪覆盖值，则使用它；否则使用配置文件的人设基线——不一定是零。
* 在管线构建完成前（例如组件已禁用时），这两个方法都会安全地空操作，且绝不会抛出异常。
* 会话重置（断开连接或发生错误）总会丢弃运行时 `SetMood` 覆盖值，并恢复到作者设定的基线，无论 `LockEmotion`.

### 解析后的情绪和心境事件

两个支持迟滞的事件让游戏逻辑代码能够响应角色实际表达的内容，而无需重新实现平滑逻辑：

```csharp
public event Action<string, float> DominantEmotionChanged;
public event Action<string, float> MoodChanged;
```

```csharp
using Convai.Modules.Emotion.Components;
using UnityEngine;

public sealed class ExpressionListener : MonoBehaviour
{
    [SerializeField] private ConvaiEmotionController emotionController;

    private void OnEnable()
    {
        emotionController.DominantEmotionChanged += HandleDominantEmotionChanged;
        emotionController.MoodChanged += HandleMoodChanged;
    }

    private void OnDisable()
    {
        emotionController.DominantEmotionChanged -= HandleDominantEmotionChanged;
        emotionController.MoodChanged -= HandleMoodChanged;
    }

    private void HandleDominantEmotionChanged(string label, float score) =>
        Debug.Log($"表达的情绪已变为 {label} @ {score:F2}");

    private void HandleMoodChanged(string label, float score) =>
        Debug.Log($"静息心境已变为 {label} @ {score:F2}");
}
```

* `DominantEmotionChanged` 在平滑后的主导（瞬时）情绪标签—— `CurrentResolvedEmotion` ——发生变化时触发，并提供新标签及其 `CurrentNormalizedIntensity`.
* `MoodChanged` 在 `CurrentMoodLabel` 发生变化时触发，并提供新标签及其 `CurrentMoodScore`。它涵盖所有可能影响心境的来源：作者设定的基线开始生效、 `SetMood`/`ClearMood`，以及心境漂移开始生效或停止生效。
* 这两个事件都只会在标签发生变化时触发——标签持续不变时不会每个刻度都触发，标签不变而分数单独变化时也不会触发。
* 这两个事件都会在 `Current`/`CurrentMoodLabel` 更新后触发，因此处理程序始终能观察到一致的状态。管线尚未构建或正在拆除时，二者都不会触发；如果订阅者抛出异常，会捕获并记录该异常，而不会中断当前刻度。
* 这与 `ConvaiManager.Events.OnCharacterEmotionChanged` 如下所示，它会转发收到的原始后端数据包，且尚未应用平滑处理、迟滞或角色基线。

### 订阅原始情绪事件

若要对 Convai 发送的每个原始情绪信号做出反应（用于日志记录、分析或自适应场景逻辑），请订阅 `OnCharacterEmotionChanged` （位于 `ConvaiManager.Events`上）。这是一个标准的 C# 事件；请在 `OnEnable` 中订阅，并在 `OnDisable`.

```csharp
using Convai.Domain.DomainEvents.Runtime;
using Convai.Runtime.Components;
using UnityEngine;

public sealed class EmotionEventListener : MonoBehaviour
{
    [SerializeField] private ConvaiManager convaiManager;

    private void OnEnable()
    {
        convaiManager.Events.OnCharacterEmotionChanged += HandleEmotionChanged;
    }

    private void OnDisable()
    {
        convaiManager.Events.OnCharacterEmotionChanged -= HandleEmotionChanged;
    }

    private void HandleEmotionChanged(CharacterEmotionChanged e)
    {
        Debug.Log($"[{e.CharacterId}] {e.Emotion} — intensity {e.Intensity} ({e.NormalizedIntensity:F2})");
    }
}
```

#### CharacterEmotionChanged 属性

| 属性                     | 类型         | 说明                                                                        |
| ---------------------- | ---------- | ------------------------------------------------------------------------- |
| `CharacterId`          | `string`   | 情绪发生变化的角色的唯一标识符。                                                          |
| `Emotion`              | `string`   | 原始服务器标签（例如 `"happy"`，而不是规范标签 `"joy"`).                                    |
| `Intensity`            | `int`      | Convai 发送的 1–3 整数刻度值（已钳制）。                                                |
| `NormalizedIntensity`  | `float`    | `Intensity / 3f` — 将 1–3 刻度映射到 `(0, 1]`。较弱（刻度为 1）的信号仍会映射为 `0.33`，而不是 `0`. |
| `Timestamp`            | `DateTime` | 事件创建时间的 UTC 时间戳。                                                          |
| `Sequence`             | `long`     | 可选的服务器序列号，用于排序； `-1` 如果后端未提供该值，则可忽略延迟到达的数据包，避免角色表情倒退。                     |
| `UtteranceId`          | `string`   | 可选标识符，用于将情绪与特定回复关联起来。未提供时为空。                                              |
| `Confidence`           | `float`    | 可选的 \[0, 1] 检测置信度； `1` 未提供时为                                              |
| `DurationMilliseconds` | `int`      | 后端提供的可选持续时间提示； `0` 未提供时为                                                  |
| `IsNeutral`            | `bool`     | `true` 如果 `Emotion` 为 `"neutral"`.                                        |
| `IsHighIntensity`      | `bool`     | `true` 如果 `Intensity >= 3`.                                               |
| `IsLowIntensity`       | `bool`     | `true` 如果 `Intensity <= 1`.                                               |

{% hint style="warning" %}
`CharacterEmotionChanged.Emotion` 包含 **原始服务器标签** （例如 `"happy"`），而非规范分类标签（`"joy"`）。如果需要规范标签（例如用它在 `Current.AllScores` 中查找分数），请通过 `TryResolveEmotionLabel`.
{% endhint %}

### 情绪维度

`EmotionDimensions` 是一种连续的、跨模块的情感信号—— `Valence`, `Arousal`, `Agency`和 `Approach`——每个维度的取值范围均为 `[-1, 1]` ，由情绪、注视、肢体语言和移动模块共享。对于编写好的面部表情配方，类别标签仍是权威依据；维度则提供统一的调制信号，供其他模块混合使用。

| 属性         | 范围     | 说明                                            |
| ---------- | ------ | --------------------------------------------- |
| `Valence`  | -1 – 1 | 表示情绪的愉悦程度。 `+1` 代表欣喜， `-1` 代表痛苦。              |
| `Arousal`  | -1 – 1 | 表示情绪的激动程度。 `+1` 代表兴奋、急切， `-1` 代表平静、迟缓。        |
| `Agency`   | -1 – 1 | 表示角色觉得自己有多大掌控力。 `+1` 代表掌控局面， `-1` 代表任由事态摆布。   |
| `Approach` | -1 – 1 | 表示情绪会让角色靠近引发它的事物，还是远离它。 `+1` 代表靠近， `-1` 代表退缩。 |

通过 `CurrentFrame.Dimensions`读取主导情绪的维度。内置标签会解析为保守的默认值；自定义分类条目可以按标签覆盖这些值——请参阅 [情绪分类](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/emotion-taxonomy.md).

### 尝试获取嘴部权重

`bool TryGetMouthWeight(BlendshapeTargetKey key, out float weight)` 返回合成器为特定混合变形目标在当前帧解析出的、由情绪驱动的嘴部权重；如果 `false` 没有面部输出为该目标解析出嘴部权重，则返回此值。这是 LipSync 读取的交接点，用于在没有进行语音活动时，将其自身的嘴形与情绪姿势进行混合；除非要实现自定义面部输出使用方，否则大多数应用程序代码不会直接调用它。

### 后续步骤

有关将配置文件配置与这些 API 调用结合起来的完整示例，请参阅 [情绪示例](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/usage-examples.md)。如果运行时行为不符合预期，请参阅 [排查情绪问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/troubleshooting-and-diagnostics.md).

{% content-ref url="/pages/f5a3aaba473b4dfb20969b46c9a49bc4b176f223" %}
[心情](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/moods.md)
{% endcontent-ref %}

{% content-ref url="/pages/6c46f45b25431c91dffb50ae4e5dd2ea5cc7ef50" %}
[情绪示例](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/usage-examples.md)
{% endcontent-ref %}

{% content-ref url="/pages/65ec9decd2473b72bc06bf3c946f3008c8528dda" %}
[排查情绪问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/troubleshooting-and-diagnostics.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-unity-sdk/embodiment/emotion/scripting-api.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.
