๐ Web Chat Widget
The Web Chat Widget is an embeddable JavaScript chat bubble that can be added to any website. When visitors send a message through the widget, it appears in PulseHub's inbox just like any other channel.
Adding the Widget to Your Websiteโ
1. Add a Web Chat Channel in PulseHubโ
- Go to Channels โ Add Channel
- Select Web Chat Widget
- Enter a name and optional greeting/color
- Click Save Channel
- Note the Channel ID from the card
2. Embed the Scriptโ
<script
src="https://yourdomain.com/public/js/webchat-widget.js"
data-channel="YOUR_CHANNEL_ID"
data-greeting="Hi! How can we help you today?"
data-color="#10b981">
</script>
Widget Configuration Optionsโ
| Attribute | Default | Description |
|---|---|---|
data-channel | required | The channel UUID from PulseHub |
data-greeting | Hi! How can we help you? | Message shown when chat first opens |
data-color | #10b981 | Hex color for the button and sent messages |
How Sessions Workโ
The widget stores two values in localStorage:
ph_contact_{channel_id}โ the contact's UUIDph_conv_{channel_id}โ the conversation's UUID
This means visitors who close the tab and return continue the same conversation.
Cross-Origin Requestsโ
If PulseHub is on a different domain from your website, add CORS headers:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://yourwebsite.com"
Header set Access-Control-Allow-Methods "GET, POST, PATCH, DELETE, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, X-Webchat-Channel"
</IfModule>
Security Noteโ
The Web Chat API endpoints accept requests from unauthenticated users when the X-Webchat-Channel header is present. Ensure rate-limiting at the web server or firewall level.