Dynamic Chatbot Configuration
How to dynamically configure different chatbots based on page URL
Why Use Dynamic Configuration?
Implementation Script
<script defer>
// Create the Wonderchat script element
var wcs = document.createElement("script");
wcs.setAttribute("data-name", "wonderchat");
wcs.setAttribute("data-address", "app.wonderchat.io");
// Get the current page path
var path = window.location.pathname;
// Configure different chatbots based on URL patterns
if (/^\/members\/[^/]+/.test(path)) {
// Members area - use specialized chatbot
wcs.setAttribute("data-id", "YOUR_MEMBERS_CHATBOT_ID");
} else if (path.startsWith("/support/")) {
// Support section
wcs.setAttribute("data-id", "YOUR_SUPPORT_CHATBOT_ID");
} else if (path.startsWith("/products/")) {
// Products section
wcs.setAttribute("data-id", "YOUR_SALES_CHATBOT_ID");
} else {
// Default - general chatbot
wcs.setAttribute("data-id", "YOUR_GENERAL_CHATBOT_ID");
}
// Set script source and widget configuration
wcs.setAttribute("src", "https://app.wonderchat.io/scripts/wonderchat.js");
wcs.setAttribute("data-widget-size", "normal");
wcs.setAttribute("data-widget-button-size", "normal");
// Append the script to the page
document.body.appendChild(wcs);
</script>Setup Steps
1. Get Your Chatbot IDs
2. Plan Your URL Structure
3. Implement the Script
4. Test Your Implementation
Common URL Patterns
Members Area
Language-Based
Subdomain-Based
Multiple Conditions
Advanced Configuration
Dynamic Widget Sizing
Page-Specific Positioning
Troubleshooting
Last updated
Was this helpful?