vowwchatt-widget
v1.2.8
Published
This TypeScript chat widget provides a customizable, real-time chat interface that can be easily integrated into web applications. It uses WebSocket for real-time communication and supports various configuration options.
Readme
TypeScript Chat Widget
This TypeScript chat widget provides a customizable, real-time chat interface that can be easily integrated into web applications. It uses WebSocket for real-time communication and supports various configuration options.
Features
- Real-time messaging using WebSocket
- Customizable appearance (position, theme)
- Automatic reconnection on connection loss
- TypeScript support with full type definitions
- JSDoc comments for better code documentation
Installation
- Clone this repository or copy the TypeScript files into your project.
- Install the required dependencies:
pnpm installUsage
- Include the compiled JavaScript file in your HTML:
<script src="path/to/chat-widget.js"></script>- Initialize the chat widget with your configuration:
const chat = chatWidget({
position: "bottom-right",
theme: "light",
orgID: "your-org-id",
fileID: "your-file-id"
});
// Open the chat window
chat.open();
// Close the chat window
chat.close();
// Check if the chat window is open
console.log(chat.isOpen());Configuration Options
position: Position of the chat widget ("bottom-right", "bottom-left", "top-right", "top-left")theme: Color theme of the widget ("light" or "dark")companyName: Name of your company or support teamorgID: Your organization's unique identifierfileID: (Optional) Unique identifier for aidentifierfileID: (Optional) Unique identifier for a specific file or conversation
API
The chat widget returns an API object with the following methods:
open(): Opens the chat windowclose(): Closes the chat windowisOpen(): Returns a boolean indicating whether the chat window is currently open
Customization
You can customize the appearance of the chat widget by modifying the CSS styles in the addStyles function within the chat-widget.ts file.
Development
To make changes to the chat widget:
- Modify the TypeScript files (
chat-widget.tsandtypes.ts) - Recompile the TypeScript files:
