Virtual Chat SDK - Floating chat widget with 20+ languages support for seamless website integration
Package Exports
@skywu/virtual-chat-sdk
Readme
@skywu/virtual-chat-sdk
A modern JavaScript/TypeScript SDK for embedding floating chat widgets into web applications. Features real-time messaging, virtual chat simulations, 20+ languages support, and seamless integration.
🌍 20+ Languages - Built-in i18n support (English, 简体中文, 繁體中文, Español, हिन्दी, العربية, Português, Deutsch, 日本語, 한국어, Français, Русский, Italiano, Türkçe, Polski, Tiếng Việt, ไทย, Bahasa Indonesia, Nederlands, and more)
🎨 Multiple UI Templates - WhatsApp and Telegram-style themes with dark mode support
⚡ Real-time Communication - WebSocket-based messaging with automatic reconnection
📱 Responsive Design - Optimized for desktop, tablet, and mobile devices
🔧 Highly Customizable - Configurable positioning, colors, and behavior
📦 TypeScript Support - Full type definitions and IntelliSense support
🚀 Zero Config - Works out of the box with minimal setup
🔒 Secure - Built-in XSS protection and Shadow DOM isolation
<!-- 1) Include SDK from your server --><scriptsrc="https://YOUR_SERVER_DOMAIN/sdk/chat-sdk.umd.js"></script><!-- 2) Create a container (optional for floating mode) --><divid="chat-container"></div><!-- 3) Initialize with floating button mode --><script>
const chat = ChatSDK.init({
container: '#chat-container',
projectId: 'YOUR_PROJECT_ID',
username: 'Visitor',
language: 'zh',
uiTemplate: 'whatsapp',
autoJoin: true,
// point SDK API to your server
apiBaseUrl: 'https://YOUR_SERVER_DOMAIN',
socketUrl: 'https://YOUR_SERVER_DOMAIN',
// Floating button mode (recommended for third-party sites)
mode: 'floating',
floatingButton: {
position: 'bottom-right',
offset: { bottom: 20, right: 20 },
icon: 'chat'
}
})
// No need to call chat.open() in floating mode - button handles it
</script>
Option B: ESM (module) - Floating Button Mode
<scripttype="module">
import { ChatSDK } from 'https://YOUR_SERVER_DOMAIN/sdk/chat-sdk.esm.js'
const chat = ChatSDK.init({
container: '#chat-container',
projectId: 'YOUR_PROJECT_ID',
username: 'Visitor',
language: 'en',
autoJoin: true,
apiBaseUrl: 'https://YOUR_SERVER_DOMAIN',
socketUrl: 'https://YOUR_SERVER_DOMAIN',
// Floating button mode (recommended for third-party sites)
mode: 'floating',
floatingButton: {
position: 'bottom-right',
offset: { bottom: 20, right: 20 }
}
})
// No need to call chat.open() in floating mode - button handles it
</script>
Display Modes
Floating Button Mode (Recommended for Third-Party Sites)
Default behavior: Shows a floating button, expands to full-screen chat when clicked
Configuration: mode: 'floating' with floatingButton options
Best for: Third-party website integration, non-intrusive user experience
Full-Screen Mode (Traditional)
Behavior: Directly shows the chat interface
Configuration: mode: 'fullscreen' or omit the mode property
Best for: Dedicated chat pages, internal applications
Notes:
No API key is required on the client.
Replace YOUR_SERVER_DOMAIN with your actual server domain where this app is hosted.
projectId can be found in the Admin panel (Projects list).
CORS: ensure your server allows the third‑party origin if needed.
const chat = ChatSDK.init({container: document.body,projectId:'YOUR_PROJECT_ID',mode:'floating',floatingButton:{position:'bottom-left',// 'bottom-right', 'bottom-left', 'top-right', 'top-left'offset:{bottom:24,left:24},// Distance from edges in pixelsicon:'chat',// Button icon typezIndex:2147483000// CSS z-index for layering},apiBaseUrl:'https://YOUR_SERVER_DOMAIN',socketUrl:'https://YOUR_SERVER_DOMAIN'})
Full-Screen Mode (Traditional)
const chat = ChatSDK.init({container:'#chat-container',projectId:'YOUR_PROJECT_ID',mode:'fullscreen',// or omit this line for default behaviorapiBaseUrl:'https://YOUR_SERVER_DOMAIN',socketUrl:'https://YOUR_SERVER_DOMAIN'})
chat.open()// Required for full-screen mode
<!-- Via CDN --><scriptsrc="https://cdn.example.com/chat-sdk.umd.js"></script><!-- Or download and host locally --><scriptsrc="path/to/chat-sdk.umd.js"></script>