paltext-embed
v1.1.9
Published
Embeddable script to use PalTextSDK React in non-React websites
Maintainers
Readme
PalText Embed
An embeddable script to integrate PalText AI Customer Support Chat into any website without requiring React.
Installation
You can include this script directly from the CDN:
<script src="https://unpkg.com/paltext-embed@latest/dist/paltext-embed.js"></script>Or you can install it via npm:
npm install paltext-embedUsage
Basic usage
<!-- Add the script to your page -->
<script src="https://unpkg.com/paltext-embed@latest/dist/paltext-embed.js"></script>
<script>
// Initialize the chat widget
window.PalTextEmbed.default.init({
apiKey: 'YOUR_API_KEY',
apiUrl: 'https://api.paltext.com',
webSocketUrl: 'wss://api.paltext.com',
businessId: 'YOUR_BUSINESS_ID',
chatWindow: {
title: 'Customer Support',
theme: 'light',
position: 'bottom-right',
initialOpen: false,
primaryColor: '#0084ff'
}
});
// You can control the chat programmatically
document.getElementById('open-chat').addEventListener('click', () => {
window.PalTextEmbed.default.open();
});
document.getElementById('close-chat').addEventListener('click', () => {
window.PalTextEmbed.default.close();
});
document.getElementById('toggle-chat').addEventListener('click', () => {
window.PalTextEmbed.default.toggle();
});
</script>Configuration Options
| Property | Type | Description | |----------|------|-------------| | apiKey | string | Your PalText API key | | apiUrl | string | The URL of the PalText API | | webSocketUrl | string | The WebSocket URL for real-time communication | | businessId | string | Your business ID | | debug | boolean | Enable debug mode | | chatWindow | object | Configuration for the chat window |
Chat Window Options
| Property | Type | Description | |----------|------|-------------| | title | string | The title of the chat window | | theme | 'light' | 'dark' | 'auto' | The theme of the chat window | | position | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | The position of the chat window | | initialOpen | boolean | Whether the chat window should be open by default | | primaryColor | string | The primary color of the chat window | | secondaryColor | string | The secondary color of the chat window |
API
window.PalTextEmbed.default.init(config): Initialize the chat widgetwindow.PalTextEmbed.default.open(): Open the chat widgetwindow.PalTextEmbed.default.close(): Close the chat widgetwindow.PalTextEmbed.default.toggle(): Toggle the chat widgetwindow.PalTextEmbed.default.isOpen(): Check if the chat widget is open
Example
See the included example.html file for a complete example.
License
MIT
