> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/fa-bu/embedding.md).

# 嵌入到你的产品中

使用 Docs Embed 将你的文档嵌入到产品或网站中。

Docs Embed 是一个强大的窗口，可让你深入了解产品知识，并可添加到任何产品或网站中。用户可以向 [GitBook Assistant](/docs/documentation/zh/mian-xiang-du-zhe-de-ai/gitbook-ai-assistant.md)提问，搜索你的文档，或直接浏览页面，而无需离开你的产品。你可以通过按钮打开该嵌入，将它放入你想要的任何组件中，或者完全通过程序进行控制。

<div data-with-frame="true"><figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2F5krgZgNq1Mj79a3aVB7h%2Femebeddable_assistant.png?alt=media&amp;token=a89feaac-3656-400b-8dcd-e7969f79d92d" alt="Embed GitBook Assistant into your product or website"><figcaption><p>将你的文档嵌入到产品或网站中</p></figcaption></figure></div>

## 概览

Docs Embed 可以包含三个标签页：

* **Assistant**： [GitBook Assistant](/docs/documentation/zh/mian-xiang-du-zhe-de-ai/gitbook-ai-assistant.md) — 一个由 AI 驱动的聊天界面，帮助用户找到答案
* **搜索**：一个以搜索为重点的界面，可快速查找页面并提出限定范围的问题
* **文档**：用于浏览你的文档站点的浏览器

默认情况下会启用所有标签页。如果你设置了 `tabs`，嵌入内容将只显示你列出的标签页。

你可以使用自定义操作、工具、建议问题、 [已认证访问](/docs/documentation/zh/fa-bu/site-audience/authenticated-access.md)等内容来自定义并覆盖默认配置。

## 开始使用

{% stepper %}
{% step %}
**前提条件**

在嵌入你的文档之前，请确保：

1. **你的文档已发布** 并且可通过某个 URL 访问（例如， `https://docs.company.com`).
2. **你已从** 你的网站设置中检索到嵌入脚本 URL（设置 → AI & MCP → Embed）。

{% hint style="info" %}
如果你想使用 Assistant 标签页， [GitBook Assistant 必须已启用](/docs/documentation/zh/mian-xiang-du-zhe-de-ai/gitbook-ai-assistant.md) 用于你的文档站点（设置 → AI & MCP）。
{% endhint %}
{% endstep %}

{% step %}
**实现**

使用我们的技能，利用你现有的技术栈快速将 GitBook Assistant 实现到你的产品中。

{% file src="/files/660b98bf335fdae37957dad219a2cfe40afb63cb" %}

或者，继续阅读文档中适合你设置方式的实现方案：

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-code">:code:</i></td><td><strong>独立 script 标签</strong></td><td>直接插入一个 &#x3C;script> 标签即可获得最快的设置方式，然后再自定义其外观</td><td><a href="/docs/documentation/zh/fa-bu/embedding/implementation/script.md">脚本标签</a></td></tr><tr><td><i class="fa-box">:box:</i></td><td><strong>Node.js/NPM</strong></td><td>通过 NPM 安装，用于服务端渲染或构建时控制</td><td><a href="/docs/documentation/zh/fa-bu/embedding/implementation/nodejs.md">Node.js/NPM</a></td></tr><tr><td><i class="fa-react">:react:</i></td><td><strong>React 组件</strong></td><td>使用预构建的 React 组件实现无缝集成</td><td><a href="/docs/documentation/zh/fa-bu/embedding/implementation/react.md">React</a></td></tr></tbody></table>

{% hint style="info" %}
如果你的文档使用 [已认证访问](/docs/documentation/zh/fa-bu/site-audience/authenticated-access.md)，请按照 [如何使用已认证文档设置嵌入](/docs/documentation/zh/fa-bu/embedding/using-with-authenticated-docs.md).
{% endhint %}
{% endstep %}

{% step %}
**配置**

* [自定义嵌入](/docs/documentation/zh/fa-bu/embedding/configuration/customizing-docs-embed.md) — 添加欢迎消息、自定义操作和建议
* [创建自定义工具](/docs/documentation/zh/fa-bu/embedding/configuration/creating-custom-tools.md) — 将 Assistant 连接到你的产品 API
  {% endstep %}
  {% endstepper %}

## 延伸阅读

如需完整的 API 参考和源代码，请查看 GitHub 上的 [`@gitbook/embed` 包](https://github.com/GitbookIO/gitbook/tree/main/packages/embed).


---

# 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, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/fa-bu/embedding.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
