@faysal1000/universal-chatbot

中文文档
0.3.0发布于 2026/11/01MITTypeScriptES Module零依赖

Embeddable website chat for the Universal Chatbot RAG platform: the Web Component.

原始使用文档
文档目录6 节
  1. Key components
  2. Tech stack
  3. Install
  4. Configuration
  5. API
  6. Running locally

chat-widget

<universal-chat-bot>: an embeddable Web Component that adds the platform's chat assistant to any website.

flowchart LR
  site[Host website] --> el["&lt;universal-chat-bot&gt; launcher"]
  el -- first open --> panel[Chat panel, shadow DOM]
  panel -. built from .-> core[chat-core]
  panel -- "/v1/public + X-Widget-Key" --> rag[rag]
  panel -- challenge --> turnstile[Cloudflare Turnstile]

Key components

  • src/element — custom element, liquid-glass launcher (SVG edge refraction in Chromium), settings, mobile page lock
  • src/element/orb — animated canvas orb
  • src/panel — lazy-loaded React chat panel
  • src/embed.ts — script-tag loader
  • build/chatCore.ts — resolves shared chat-core imports
  • demo/ — plain HTML, React and Vue hosts

Tech stack

  • TypeScript, Web Components, Shadow DOM
  • React 19 (panel only), chat-core
  • Vite (library build), Vitest, Playwright

Install

npm install @faysal1000/universal-chatbot
import '@faysal1000/universal-chatbot';

Without a bundler, load it from the CDN instead (see API).

Configuration

Set as attributes on the element. Create the publishable key in the admin console under RAG → Website widgets.

AttributeDescriptionDefault
api-keyPublishable key (pk_…)required
api-urlrag's public URLrequired
positiontop/middle/bottom + -left/-center/-rightbottom-right
themelight, dark or autoauto
primary-colorAny CSS colour#6d5dfc
offset-xGap to the left/right edge (24, 2rem)20px
offset-yGap to the top/bottom edge (96, 6rem)20px
greetingLauncher labelChat
languageen or bnpage language
openPresent when the panel is openabsent

API

  • Methods: open(), close(), toggle(), isOpen
  • Events: chat-open, chat-close
<script src="https://cdn.jsdelivr.net/npm/@faysal1000/universal-chatbot@0/dist/embed.js" async></script>
<universal-chat-bot api-key="pk_your_key" api-url="https://chat-api.example.com"></universal-chat-bot>

Running locally

npm ci
npm run dev    # rebuild dist/ on change
npm run demo   # demo hosts on http://localhost:5391

Checks: npm run check; end-to-end: npm run test:e2e against the running stack.

版本与发布记录

@faysal1000/universal-chatbot 共发布 5 个版本,首次发布于 2026/11/01;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.3.0latest2026/11/012 天前
0.2.12026/11/012 天前
0.2.02026/11/012 天前
0.1.02026/11/012 天前
0.0.0-stage2026/11/012 天前

关于 @faysal1000/universal-chatbot 的常见问题

@faysal1000/universal-chatbot 是什么?

面向通用聊天机器人RAG平台的可嵌入网站聊天:Web组件。

如何安装 @faysal1000/universal-chatbot?

在项目目录运行 npm install @faysal1000/universal-chatbot,或使用 pnpm add / yarn add / bun add。

@faysal1000/universal-chatbot 支持 TypeScript 吗?

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

@faysal1000/universal-chatbot 支持 ESM 还是 CommonJS?

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

@faysal1000/universal-chatbot 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@faysal1000/universal-chatbot 可以商用吗?

@faysal1000/universal-chatbot 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@faysal1000/universal-chatbot 还在维护吗?

最新版本 0.3.0 发布于 2026/11/01(2 天前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。