Update Webchat configuration

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.

Update configuration

To update Webchat’s configuration, you can call the window.botpress.config method after Webchat has been initialized:

window.botpress.config({
  configuration: {},
})

Include any configuration object you’d like to apply the new configuration.

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',
}

window.botpress.on('webchat:initialized', () => {
  window.botpress.config({ configuration: webchatConfig })
})

The above snippet:

  1. Waits until Webchat is initialized
  2. Updates the themeMode configuration to dark