# GitBook Assistant

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FlzOUuOwM4Vffctmf3VHC%2F25_03_31_gitbook_assistant%402x.png?alt=media&#x26;token=914e435f-6305-41d8-b05c-23884ceba4e7" alt="GitBook Assistant"><figcaption><p>GitBook 助手</p></figcaption></figure>

GitBook Assistant 使用自然语言为你的用户提供关于你文档的快速、准确答案。它会根据你的用户进行个性化定制，可以嵌入到你的网站或产品中，并可在已发布文档的侧边栏中使用。

可以把它看作一位产品专家，在用户最需要它的时间和地点，随时为所有用户提供服务。

该助手使用 agentic retrieval 来理解查询上下文，基于用户当前页面、之前阅读过的页面以及之前的对话。

试着在下面的框中向助手提一个问题：

<p align="center"><button type="button" class="button primary" data-action="ask" data-icon="gitbook-assistant">提出一个问题...</button></p>

## 启用 GitBook Assistant <a href="#how-do-i-use-gitbook-ai" id="how-do-i-use-gitbook-ai"></a>

要启用 GitBook Assistant，请打开你站点的仪表板，前往 **设置** 页面并从左侧菜单中选择 **AI 与 MCP** 。你可以在这里从可用选项中启用 GitBook Assistant。

### 添加建议问题

建议问题是在助手打开且没有活动对话时显示的预设提示。它们可以帮助用户了解可以问什么，也可以帮助你引导用户找到有用的答案或工作流程。

你可以在站点的 **设置**中添加建议问题，位于 **AI 与 MCP** 部分。

#### **建议问题的最佳实践：**

* 从真实的用户目标开始（设置、故障排查、集成）。
* 使用用户使用的词语（避免内部代号）。
* 保持具体。“我该如何……？”比“告诉我关于……”。
* 涵盖不同意图：快速开始、操作指南、故障排查和参考。

{% hint style="info" %}
如果你将助手嵌入到产品中，还可以在嵌入配置中动态设置建议内容。参见 [自定义嵌入](https://app.gitbook.com/s/NkEGS7hzeqa35sMXQZ4X/docs-site/embedding/configuration/customizing-docs-embed#adding-suggestions).
{% endhint %}

## 在已发布文档中使用 GitBook Assistant <a href="#how-do-i-use-gitbook-ai" id="how-do-i-use-gitbook-ai"></a>

用户可以通过三种方式访问 GitBook Assistant：

* 按下 <kbd>⌘</kbd> + <kbd>I</kbd> 在 Mac 上，或 <kbd>Ctrl</kbd> + <kbd>I</kbd> 在 PC 上
* 点击 **GitBook Assistant** <picture><source srcset="broken-reference" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FRPCVZqnhQlwvRJbvEgM9%2Fgitbook-assistant.svg?alt=media&#x26;token=0506ce84-b363-481b-aefb-e0fa47357226" alt=""></picture> 按钮，位于 **提问或搜索…** 栏
* 在 **提问或搜索…** 栏中输入问题，并在菜单顶部选择“Ask…”选项

## 将 GitBook Assistant 嵌入到你的产品中

你可以将 GitBook Assistant 直接嵌入到你的产品或网站中，让用户无需离开你的应用即可立即获得 AI 驱动的帮助。助手可以作为 [Docs Embed](https://gitbook.com/docs/documentation/zh/docs-site/embedding)的一部分进行嵌入，其中包括用于 AI 聊天的 Assistant 选项卡，以及用于浏览文档的 Docs 选项卡。

选择适合你技术栈的嵌入方式：

* [**独立脚本标签**](https://gitbook.com/docs/documentation/zh/docs-site/embedding/implementation/script) – 使用一个 `<script>` 标签快速设置
* [**Node.js/NPM**](https://gitbook.com/docs/documentation/zh/docs-site/embedding/implementation/nodejs) – 服务端或构建时集成
* [**React 组件**](https://gitbook.com/docs/documentation/zh/docs-site/embedding/implementation/react) – 预构建的 React 组件

### 其他助手嵌入指南：

* [在已认证文档中使用嵌入式 Assistant](https://gitbook.com/docs/documentation/zh/docs-site/embedding/using-with-authenticated-docs) – 如果你的文档需要登录，则必需
* [自定义 Assistant 嵌入](https://gitbook.com/docs/documentation/zh/docs-site/embedding/configuration/customizing-docs-embed) – 欢迎消息、操作和建议
* [创建自定义嵌入工具](https://gitbook.com/docs/documentation/zh/docs-site/embedding/configuration/creating-custom-tools) – 将 Assistant 连接到你的 API
* [API 参考](https://gitbook.com/docs/documentation/zh/docs-site/embedding/configuration/reference) – 所有可用方法和事件

## 扩展 GitBook Assistant 的知识

GitBook Assistant 可以通过 [连接](https://app.gitbook.com/s/NkEGS7hzeqa35sMXQZ4X/ai-and-search/connections) 并在 [MCP 服务器](https://gitbook.com/docs/documentation/zh/ai-yu-sou-suo/mcp-servers-for-published-docs).

当你希望 GitBook 将记录同步到你的网站时，可以使用连接；当你想将 GitBook Assistant 连接到自定义工具时，可以使用 MCP 服务器。

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th>最适合</th></tr></thead><tbody><tr><td><strong>连接</strong></td><td><p>连接最适合内容量大的来源：</p><ul><li>GitHub 问题和讨论</li><li>Slack 或 Discord 对话</li><li>支持内容</li><li>外部文档、帮助中心和网站</li></ul></td></tr><tr><td><strong>MCP 服务器</strong></td><td><p>MCP 服务器最适合实时工具和数据：</p><ul><li>当前账号或产品状态</li><li>经常变化的内部系统</li><li>创建工单或提交 bug 等操作</li><li>你不想同步到 GitBook 的来源</li></ul></td></tr></tbody></table>

{% tabs %}
{% tab title="添加连接" %}
{% stepper %}
{% step %}
**打开你站点的设置**

打开你的网站仪表板。然后选择 **设置** → **连接**.
{% endstep %}

{% step %}
**连接来源**

选择一种来源类型。然后授权它，或输入要导入的 URL。
{% endstep %}

{% step %}
**向 GitBook Assistant 公开记录**

开启 **在搜索 / 助手中公开显示** 连接的。

随后 GitBook 就可以在搜索和 GitBook Assistant 中使用这些记录。
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="添加 MCP 服务器" %}
{% stepper %}
{% step %}
**打开你站点的设置**

打开你的网站仪表板。然后选择 **设置** → **AI 与 MCP**.
{% endstep %}

{% step %}
**添加新服务器**

在 MCP 服务器表中，点击 **添加 MCP 服务器**.
{% endstep %}

{% step %}
**输入服务器详情**

给服务器命名。添加它的 URL。

然后配置 GitBook 必须随每个请求发送的任何 HTTP 标头。
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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://gitbook.com/docs/documentation/zh/ai-yu-sou-suo/gitbook-ai-assistant.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.
