You can update your Webchat’s configuration dynamically using JavaScript. This is useful if you want to update Webchat’s style or settings after it’s already loaded on your website.
You will need:
  • A website with an embedded bot
  • Familiarity with JavaScript

Update configuration

To update Webchat’s configuration, you can call the window.botpress.config method after Webchat has been initialized:
window.botpress.config({ configuration: <configuration>, user: <user>});

Switch to dark theme

Here’s an example that updates Webchat’s theme to dark mode as soon as Webchat loads:
const webchatConfig = {
    "themeMode": "dark",
};

async function getBotpressUser() {
  return await window.botpress.getUser();
}

window.botpress.on('webchat:initialized', () => {
    window.botpress.config({ configuration: webchatConfig, user: getBotpressUser() });
});
The above snippet:
  1. Waits until Webchat is initialized
  2. Gets the current Botpress user using the getUser method
  3. Updates the themeMode configuration to dark for the current user`
You don’t need to provide the entire configuration object every time—just the values that you want to update.