# @airelogic/docs-chatbot 中文文档

规范地址：https://npmcn.com/package/%40airelogic/docs-chatbot/

版本：1\.1\.0
npm 元数据更新时间：2025-07-22T11:44:32.493Z
中文译文更新时间：2026-11-06T01:48:39.643Z
软件包许可：未声明

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40airelogic/docs-chatbot
原文对照：https://npmcn.com/package/%40airelogic/docs-chatbot/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：23.1 kB，8 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2025-06-24T10:14:02.541Z
- 最新版本发布：2025-07-22T11:44:32.324Z
- 近 30 天下载量：7020（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

AireSuite 产品聊天台

## 安装

```sh
npm install @airelogic/docs-chatbot
```

也可以使用：`pnpm add @airelogic/docs-chatbot`、`yarn add @airelogic/docs-chatbot`、`bun add @airelogic/docs-chatbot`

## README

# @airelogic/docs-chatbot (英语)

Airelogic 文档的聊天器,用于Airesite产品.

## 安装

```bash
npm install @airelogic/docs-chatbot
```

## 使用量

### 基本使用(自动挂载)

```javascript
import React, { useRef } from "react";
import {
  useDocsBotChat,
  DocsBotChatRef,
  DocsBotOptions,
} from "@airelogic/docs-chatbot";

const widgetOptions: DocsBotOptions = {
  botName: "AireGlu Docs",
  description: "Ask me anything about AireGlu!",
  color: "#291b3e",
  alignment: "left",
  labels: {
    firstMessage:
      "Hi! I can help you with our documentation. What would you like to know?",
    floatingButton: "Help",
    inputPlaceholder: "Ask about our docs...",
    poweredBy: "Aireinnovate",
  },
  questions: [
    "How do I get started with AireGlu endpoints?",
    "What are the main features of AireGlu?",
    "How do I send an email from an AireGlu enpoint?",
  ],
  verticalMargin: 10, // use 70 if there is a footer
  horizontalMargin: 10,
  customCSS: `
    .docsbot-wrapper {
      height: calc(100% - 230px);
    }
    `, // Adjust height to fit the page when there is a footer
};

{
  /* Refer to AireGlu (magicman) on how the Bot Id is housed in an environment variable */
}
useDocsBotChat({
  botId: "a1QS54aX5vqaWUgXH9c1/QYNQLIJlzqpRsJX90lLE",
  options: widgetOptions,
});

// include component, the bot Id is unique for Airelogic
return (
  <div>
    <h1>Welcome to the Docs Chatbot Playground</h1>
  </div>
);
```

### 手动控制

对于聊天器加载和挂载时的更多控制,您可以禁用自动注射:

```javascript
import React, { useRef, useState } from "react";
import {
  DocsBotChat,
  DocsBotChatRef,
  DocsBotOptions,
} from "@airelogic/docs-chatbot";

const { mount, unmount, toggle } = useDocsBotChat({
  botId: "your-bot-id",
  options: widgetOptions,
  inject: false,
});
const [isMounted, setIsMounted] = useState(false);

const handleMount = async () => {
  const success = await mount();
  setIsMounted(success || false);
};

const handleUnmount = async () => {
  const success = await unmount();
  setIsMounted(!success);
};

const handleToggle = () => {
  toggle();
};

return (
  <div>
    <div>
      <button onClick={handleMount} disabled={isMounted}>
        Mount Chatbot
      </button>
      <button onClick={handleUnmount} disabled={!isMounted}>
        Unmount Chatbot
      </button>
      <button onClick={handleToggle} disabled={!isMounted}>
        Toggle Chatbot
      </button>
    </div>
  </div>
);
```

重要: 当使用手动控制时, 请确保您在 HTML 中添加了 Docbot 脚本的引用 .

```html
<script src="https://widget.docsbot.ai/chat.js" async></script>
```

## 道具

| Prop | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `botId` | `string` | 需求 | 独有的机器人标识符 |
| `options` | `DocsBotOptions` | `{}` | 部件配置选项 |
| `identify` | `DocsBotIdentify` | `undefined` | 用户识别数据 |
| `signature` | `string` | `undefined` | 认证签名 |
| `supportCallback` | `SupportCallback` | `undefined` | 支持退票 |
| `keyboardShortcuts` | `KeyboardShortcut[]` | `[]` | 自定义键盘快捷键 |
| `enableDefaultShortcuts` | `boolean` | `true` | 启用 CtrlQQ( 切换) 和 Escape( 关闭) |
| `inject` | `boolean` | `true` | 控制自动脚本插入 |

## 方法

钩子(或组件 ref)提供了控制聊天器部件的几种方法:

-   `mount()` - 手动挂载聊天器部件
-   `unmount()` - 卸载并清理聊天器部件
-   `open()` - 打开聊天机接口
-   `close()` - 关闭聊天机接口
-   `toggle()` - 切换打开/关闭的聊天机接口
-   `addUserMessage(message, send?)` - 在聊天时添加用户信息
-   `addBotMessage(message)` - 在聊天时添加一个机器人信息
-   `clearChatHistory()` - 清谈历史

## 常见问题

### @airelogic/docs-chatbot 是什么？

AireSuite 产品聊天台

### 如何安装 @airelogic/docs-chatbot？

在项目目录运行 npm install @airelogic/docs-chatbot，或使用 pnpm add / yarn add / bun add。

### @airelogic/docs-chatbot 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @airelogic/docs-chatbot 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @airelogic/docs-chatbot 可以商用吗？

@airelogic/docs-chatbot 使用 未声明 许可。package\.json 没有声明许可证。没有许可证的代码默认保留全部权利，商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括，不构成法律意见，请以许可原文为准。

### @airelogic/docs-chatbot 的下载量有多少？

根据 npm 官方下载统计，@airelogic/docs-chatbot 在 2026/10/05 – 2026/11/03 这 30 天内被下载 7,020 次，日均约 234 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @airelogic/docs-chatbot 还在维护吗？

最新版本 1\.1\.0 发布于 2025/07/22（1\.3 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2025/06/24。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

