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

<div data-with-frame="true"><figure><img src="/files/97538cae968c488b6e43986c80dc14d7d0efecd2" 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** ，该 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="/pages/81272e1e8dae8b9000873ffae62b3b5a7fd53166">/pages/81272e1e8dae8b9000873ffae62b3b5a7fd53166</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="/pages/8453f74f049615248171dd3528fd9d96ad8271b5">/pages/8453f74f049615248171dd3528fd9d96ad8271b5</a></td></tr><tr><td><i class="fa-react">:react:</i></td><td><strong>React 组件</strong></td><td>使用预构建的 React 组件，实现无缝集成</td><td><a href="/pages/fc94bec83478ce08eac8e9fae8a7b03fd3067f0a">/pages/fc94bec83478ce08eac8e9fae8a7b03fd3067f0a</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.
