Step 1: Add to Your Website
Add this code to your website before the closing</body> tag:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | Your Support Unicorn instance URL |
widgetToken | string | required | Widget authentication token |
position | string | 'right' | Widget position (‘left’ or ‘right’) |
locale | string | 'en' | Language code |
primaryColor | string | '#1f77b4' | Theme color (hex) |
welcomeMessage | string | 'Hi! How can we help you?' | Welcome message |
hideMessageBubble | boolean | false | Hide chat bubble |
Example: Full HTML Page
Security
Widget Token Authentication
- Widget tokens are generated using nanoid (format:
wgt_XXXXXXXXXXXXXXXX) - Tokens are validated on both HTTP and WebSocket connections
- Invalid or disabled tokens are rejected
- Tokens map to specific Organization + Configuration
Iframe Isolation
- Widget runs in sandboxed iframe
- Parent-iframe communication via
postMessage - Origin validation on all messages
Troubleshooting
Widget not loading
- Check
widgetTokenis correct - Verify ChatWidget is enabled
- Check browser console for errors
- Verify CORS is working
WebSocket connection failed
- Ensure configuration is set
- Check ActionCable is mounted at
/cable - Verify
widgetTokenauthentication
Messages not sending
- Check Slack integration is configured (if using Slack)
- Verify configuration has valid sink_main (Slack channel)
- Check Rails logs for errors
Next Steps
Configuration
Customize widget appearance and behavior
JavaScript API
Programmatically control the widget