@buni.ai/chatbot-core
v1.0.14
Published
Core functionality for BuniAI chat widget adapters
Maintainers
Readme
@buni.ai/chatbot-core
Core functionality for BuniAI Chat Widget adapters - provides framework-agnostic utilities and API for seamless chatbot integration.
Features
- 🚀 Framework Agnostic - Works with any JavaScript framework or vanilla JS
- 📦 TypeScript Ready - Full type definitions included
- 🎯 Event-Driven - Comprehensive event system for real-time updates
- 🔧 Configurable - Extensive customization options
- 📱 Mobile Friendly - Responsive design and touch support
- 🎨 Themeable - Multiple built-in themes and custom styling options
Installation
npm install @buni.ai/chatbot-coreQuick Start
import { BuniChatWidget } from '@buni.ai/chatbot-core';
// Initialize the widget
const widget = new BuniChatWidget();
await widget.initialize({
token: 'your-embed-token',
config: {
theme: 'default',
position: 'bottom-right',
welcomeMessage: 'Hello! How can we help you today?'
}
});
// Control the widget
widget.show();
widget.hide();
widget.toggle();
// Set customer data
widget.setCustomerData({
name: 'John Doe',
email: '[email protected]',
userId: 'user123'
});
// Listen for events
widget.on('new_message', (data) => {
console.log('New message:', data.message);
});
widget.on('visibility_changed', (data) => {
console.log('Widget visibility:', data.visibility);
});API Reference
Configuration Options
interface BuniChatConfig {
theme?: 'default' | 'dark' | 'light' | 'corporate' | 'friendly' | 'minimal';
primaryColor?: string;
secondaryColor?: string;
companyName?: string;
customAvatar?: string;
welcomeMessage?: string;
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
width?: number;
height?: number;
triggerText?: string;
autoOpen?: boolean;
showMinimize?: boolean;
showBranding?: boolean;
enableMobile?: boolean;
}Widget Methods
initialize(options)- Initialize the widget with configurationdestroy()- Clean up and remove the widgetshow()- Show the chat widgethide()- Hide the chat widgettoggle()- Toggle widget visibilityminimize()- Minimize the widgetmaximize()- Maximize the widgetsetCustomerData(data)- Set customer informationgetCustomerData()- Get current customer datasetSessionVariables(variables)- Set session variablessendMessage(message)- Send a message programmaticallyclearChat()- Clear chat history
Events
ready- Widget is loaded and readyvisibility_changed- Widget visibility changednew_message- New message receivedminimized- Widget was minimizedmaximized- Widget was maximizederror- An error occurred
TypeScript Support
This package includes comprehensive TypeScript definitions:
import {
BuniChatWidget,
BuniChatOptions,
BuniChatConfig,
CustomerData,
SessionVariables
} from '@buni.ai/chatbot-core';Framework Adapters
For framework-specific implementations, use these packages:
- React:
@buni.ai/chatbot-react - Vue:
@buni.ai/chatbot-vue - Angular:
@buni.ai/chatbot-angular
License
MIT © BuniAI Team
