Skip to main content

Widget Integration

Add the ChatterMate chat widget to your website using either direct script integration or iframe embedding.
Widget Integration Options

Integration Methods

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

Widget Position

By default the launcher sits 20px from the bottom-right corner. To move it — for example, to clear a fixed bottom navigation bar — initialize the widget with ChatterMate.init() and pass a position. Both values are in pixels, measured from the bottom and right edges of the screen. The chat window stays anchored above the launcher, and the offset applies on mobile too.
You can also reposition the widget at any time after it has loaded — useful when your layout changes, such as a bottom bar appearing:
position and setPosition() accept bottom and right in pixels. On mobile the chat window opens full-screen, so the offset controls where the closed launcher button sits — handy for keeping it clear of a bottom navigation bar.

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:
  1. Clone and setup:
  1. Start test server:
  1. Open http://localhost:3000 and enter your widget ID
The test project demonstrates:
  • Basic widget initialization
  • Token management
  • Style customization
  • Mobile responsiveness

Best Practices

  1. Implementation
    • Add script just before closing body tag
    • Enable secure token storage
    • Test on multiple browsers
    • Verify mobile responsiveness
  2. Security
    • Store tokens securely
    • Use HTTPS only
    • Implement proper CSP headers
    • Enable domain restrictions
  3. User Experience
    • Test email collection flow
    • Verify history loading
    • Check offline behavior
    • Test connection handling

Troubleshooting

  • Verify localStorage access
  • Check token storage events
  • Clear stored tokens and retry
  • Verify domain permissions
  • Check CSS variables
  • Verify mobile breakpoints
  • Test iframe dimensions
  • Validate color codes
  • Verify widget ID
  • Check network connectivity
  • Test WebSocket connection
  • Validate API endpoints

What’s Next?

After integrating the widget:
  1. Test customer identification flow
  2. Verify conversation persistence
  3. Monitor connection stability
  4. Test mobile responsiveness

Human Agents

Next: Learn how to manage human agents