@airelogic/docs-chatbot

中文文档
1.1.0发布于 2025/07/22TypeScriptES Module零依赖近 30 天下载 7020

AireSuite 产品聊天台

中文使用文档
文档目录6 节
  1. 安装
  2. 使用量
  3. 基本使用(自动挂载)
  4. 手动控制
  5. 道具
  6. 方法

@airelogic/docs-chatbot (英语)

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

安装

npm install @airelogic/docs-chatbot

使用量

基本使用(自动挂载)

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>
);

手动控制

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

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 脚本的引用 .

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

道具

Prop类型默认说明
botIdstring需求独有的机器人标识符
optionsDocsBotOptions{}部件配置选项
identifyDocsBotIdentifyundefined用户识别数据
signaturestringundefined认证签名
supportCallbackSupportCallbackundefined支持退票
keyboardShortcutsKeyboardShortcut[][]自定义键盘快捷键
enableDefaultShortcutsbooleantrue启用 CtrlQQ( 切换) 和 Escape( 关闭)
injectbooleantrue控制自动脚本插入

方法

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

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

版本与发布记录

@airelogic/docs-chatbot 共发布 6 个版本,首次发布于 2025/06/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2025/07/221.3 年前
1.0.32025/07/211.3 年前
1.0.22025/07/211.3 年前
1.0.12025/07/151.3 年前
1.0.02025/06/251.4 年前
1.0.0-pre022025/06/241.4 年前

关于 @airelogic/docs-chatbot 的常见问题

@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 和提交记录判断。