@datus/web-chatbot
v1.0.9
Published
Datus Chatbot widget – embeddable via CDN script tag
Readme
@datus/web-chatbot
Embeddable Datus Chatbot widget. Ships as a UMD bundle that can be loaded via a <script> tag from CDN or self-hosted, with React as an external dependency.
Quick Start (CDN)
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<!-- React (external) -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- Datus Chatbot -->
<link rel="stylesheet" href="https://unpkg.com/@datus/web-chatbot/dist/datus-chatbot.css" />
<script src="https://unpkg.com/@datus/web-chatbot/dist/datus-chatbot.umd.js"></script>
</head>
<body>
<div id="chatbot-root" style="width: 100%; height: 100vh;"></div>
<script>
DatusChatbot.initChatbot({
el: '#chatbot-root',
requestOrigin: 'https://api.example.com',
});
</script>
</body>
</html>Options
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| el | string \| HTMLElement | Yes | — | CSS selector or DOM element to mount into |
| requestOrigin | string | Yes | — | API server origin (e.g. https://api.example.com) |
| projectId | string | No | 'chatbot' | Project ID for the chatbot session |
| subagentId | string | No | URL param subagent | Sub-agent ID. Falls back to ?subagent= URL parameter |
| userName | string | No | — | Display name shown on the welcome screen |
| headers | Record<string, string> | No | — | Default headers attached to every API request |
Theme
Set data-theme on the <html> element to switch between light and dark mode:
<html data-theme="light"> <!-- or "dark" -->The chatbot includes a built-in theme toggle in the sidebar.
Building from Source
# From the monorepo root
pnpm --filter @datus/web-chatbot buildOutput files:
dist/datus-chatbot.umd.js— UMD bundle (global:DatusChatbot)dist/datus-chatbot.es.js— ES module bundledist/datus-chatbot.css— Stylesheet (must be included)
Templates
The templates/ directory contains ready-to-use HTML files:
index.html— CDN integration exampleindex-dev.html— Local development example (loads fromdist/, connects tolocalhost:8501)
