Widget Integration
Add the ChatterMate chat widget to your website
Widget Integration
Add the ChatterMate chat widget to your website using either direct script integration or iframe embedding.
Integration Methods
1. Script Integration (Recommended)
Add the following code snippet to your website’s HTML, just before the closing </body>
tag:
Replace YOUR_WIDGET_ID
with your unique widget identifier from the ChatterMate dashboard.
2. IFrame Integration
Alternatively, embed the chat widget using an iframe:
The iframe method is useful for testing or when you need more control over the widget’s placement and dimensions.
Widget Configuration
Customization
Mobile Responsiveness
The widget automatically adapts to different screen sizes:
Event Handling
The widget supports the following events:
Token Management
Scroll Control
Security Features
- Tokens are encrypted and stored securely
- Communication uses postMessage for security
- Automatic token management
- Domain validation for widget loading
Widget Features
Customer Identification
- Email collection before chat starts
- Automatic returning customer detection
- Previous conversation history loading
- Context maintenance across sessions
Chat Interface
- Real-time message updates
- Typing indicators
- Message status tracking
- File attachment support
- Markdown formatting support
- Emoji support
Styling
The widget uses CSS variables for consistent theming:
Testing Your Integration
Test Project
We provide a sample test project at github.com/chattermate/chattermate.chat/tree/main/chattermate-test
:
- Clone and setup:
- Start test server:
- Open
http://localhost:3000
and enter your widget ID
The test project demonstrates:
- Basic widget initialization
- Token management
- Style customization
- Mobile responsiveness
Best Practices
-
Implementation
- Add script just before closing body tag
- Enable secure token storage
- Test on multiple browsers
- Verify mobile responsiveness
-
Security
- Store tokens securely
- Use HTTPS only
- Implement proper CSP headers
- Enable domain restrictions
-
User Experience
- Test email collection flow
- Verify history loading
- Check offline behavior
- Test connection handling
Troubleshooting
What’s Next?
After integrating the widget:
- Test customer identification flow
- Verify conversation persistence
- Monitor connection stability
- Test mobile responsiveness
Human Agents
Next: Learn how to manage human agents