Widget Authentication
Secure your embedded chat widget with flexible token-based authentication. ChatterMate supports both public and authenticated access modes to fit your application’s needs.Authentication Modes
ChatterMate offers two authentication modes for your widget:- Optional (Default)
- Required
Public Access Mode
The default mode allows anonymous visitors to start conversations without authentication.How it works:- Token is automatically generated when the widget initializes
- Visitors can chat immediately without signing in
- Email collection is optional (based on chat style settings)
- Conversation history is linked to the generated token
- Public support websites
- Documentation assistants
- General Q&A interfaces
- Lead generation chatbots
How Token Authentication Works
Token Structure
ChatterMate uses JWT (JSON Web Token) for secure widget authentication. Each token contains:| Field | Description |
|---|---|
widget_id | Unique identifier for the widget |
org_id | Organization identifier |
customer_id | Customer/user identifier |
source | Optional tracking source |
exp | Token expiration timestamp |
Token Flow
Token Validation
ChatterMate validates the token on each request, verifying the signature and organization context.
Implementation
Server-Side Token Generation
Generate tokens on your backend to securely identify users:Client-Side Token Usage
Pass the token when initializing the widget:API Authentication
For direct API calls, include the token in headers:Security Features
Organization Isolation
Tokens are scoped to your organization. Cross-organization access is prevented.
Signature Verification
All tokens are cryptographically signed and verified on each request.
Widget Binding
Tokens are bound to specific widgets, preventing cross-widget token reuse.
Encrypted Storage
Tokens are stored securely with encryption at rest.
Best Practices
-
Token Expiration
- Set appropriate expiration times (recommended: 24 hours)
- Implement token refresh for long sessions
- Handle expired token errors gracefully
-
Secure Generation
- Generate tokens server-side only
- Use environment variables for secret keys
- Rotate secrets periodically
-
User Context
- Include user identifiers for conversation continuity
- Add email for customer identification
- Use source tracking for analytics
Troubleshooting
Token validation failed
Token validation failed
- Verify your
CONVERSATION_SECRET_KEYmatches between token generation and ChatterMate config - Check token hasn’t expired
- Ensure
widget_idin token matches the widget being used
Widget not loading with token
Widget not loading with token
- Confirm token is set before the widget script loads
- Check browser console for JavaScript errors
- Verify token format is valid JWT
Conversation history not loading
Conversation history not loading
- Ensure
customer_idis consistent for the same user - Check organization ID matches
- Verify token hasn’t been regenerated with different customer ID
What’s Next?
After configuring authentication:- Set up your widget integration
- Configure chat customization options
- Test with authenticated and anonymous users
Widget Integration
Learn how to integrate the widget into your website