1.0.1 • Published 1 year ago
@agilist/chat-widget v1.0.1
Chat Widget
A highly customizable chat widget that can be easily embedded into any website.
Quick Start
Add the following code to your HTML page:
<!-- Chat Widget -->
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1",
"react-dom": "https://esm.sh/react-dom@18.3.1",
"react-dom/client": "https://esm.sh/react-dom@18.3.1/client"
}
}
</script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@agilist/chat-widget@1.0.0/dist/chat.css" />
<script type="module">
import { createChat } from 'https://cdn.jsdelivr.net/npm/@agilist/chat-widget@1.0.0/dist/chat.es.js';
createChat({
webhookUrl: "your-webhook-url",
configId: "your-config-id" // Optional: Configuration will be loaded from Supabase
});
</script>Installation Options
1. Using Hosted Configuration (Recommended)
The easiest way to use the chat widget is with a hosted configuration:
- Configure your chat widget in the dashboard
- Get your configuration ID
- Add the widget to your site with minimal code
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1",
"react-dom": "https://esm.sh/react-dom@18.3.1",
"react-dom/client": "https://esm.sh/react-dom@18.3.1/client"
}
}
</script>
<script type="module">
import { createChat } from 'https://cdn.jsdelivr.net/npm/@agilist/chat-widget@1.0.0/dist/chat.es.js';
createChat({
configId: 'your-config-id',
webhookUrl: 'your-webhook-url'
});
</script>2. Using Local Configuration
You can also configure the widget directly in your code:
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1",
"react-dom": "https://esm.sh/react-dom@18.3.1",
"react-dom/client": "https://esm.sh/react-dom@18.3.1/client"
}
}
</script>
<script type="module">
import { createChat } from 'https://cdn.jsdelivr.net/npm/@agilist/chat-widget@1.0.0/dist/chat.es.js';
createChat({
webhookUrl: 'your-webhook-url',
config: {
branding: {
name: 'Customer Support',
avatarUrl: 'https://api.dicebear.com/7.x/bottts/svg?seed=chat',
welcomeMessage: 'Hi there! How can we help you today?'
},
colors: {
primary: '#0EA5E9'
}
}
});
</script>Configuration Options
The chat widget supports extensive customization. Here are the main configuration options:
Branding
name: Widget titleavatarUrl: URL for the chat bot avataravatarShape: 'circle' | 'square' | 'rounded'welcomeMessage: Initial message shown to usersplaceholder: Input placeholder textshowAvatar: Show/hide avatarshowTimestamp: Show/hide message timestamps
Colors
primary: Primary brand colorsecondary: Secondary/accent coloruserBubble: User message backgroundbotBubble: Bot message backgrounduserText: User message text colorbotText: Bot message text color
Layout
width: Widget widthheight: Widget heightposition: 'left' | 'right'shape: 'rectangle' | 'pill' | 'custom'startMaximized: Open widget on loadautoPopup: Configure automatic popup behavior
Typography
fontFamily: Main font familyfontSize: Base, header, and timestamp sizesfontWeight: Normal and bold weights
Development
Install dependencies:
npm installStart development server:
npm run devBuild for production:
npm run build
Publishing
- Update version in package.json
Build the package:
npm run buildPublish to npm:
npm publish
License
MIT