Widget SDK

The Maison chat widget is loaded via a single script tag and initialised with window.initMcbs(). This page documents every configuration option, control method, and callback available on the returned object. For platform-specific setup instructions, see the Integration Guides.

Basic usage

html
<script src="https://agent.maison-labs.com/agent-inject.bundle.js"></script>
<script>
  var mcAgent = window.initMcbs({
    clientId: 'YOUR_CLIENT_UUID'
  });
  mcAgent.showIcon();
</script>

Configuration options

Pass these properties in the object argument to initMcbs():

PropertyTypeRequiredDescription
clientIdstringYesYour Client UUID from the Business Console.
sessionIdstringNoAn existing session ID to restore a previous conversation. If omitted, a new session is created.
localestringNoBCP-47 locale code (e.g. en_US, fr_FR). Defaults to the browser locale.
iconPositionobjectNoInitial icon placement. Properties: top, bottom, left, right — each a number of pixels. Values must be plain numbers (e.g. 20), not strings with units (e.g. '20px').
onSessionUpdatefunctionNoCallback fired when a session is created or restored. Receives the session ID as its argument.
onLocaleUpdatefunctionNoCallback fired when the chat language changes. Receives the new locale string.
iconPosition values are plain numbers, not strings. Use { bottom: 20, right: 20 }, not { bottom: '20px', right: '20px' }. The widget interprets each value as pixels automatically.

Control methods

The object returned by initMcbs() exposes these methods:

MethodDescription
showChat()Open the chat interface
hideChat()Close the chat interface
showIcon()Display the chat icon
hideIcon()Hide the chat icon
hideSuggestion()Hide the suggestion prompt
updateLocale(locale)Change the chat language at runtime
updateIconPosition(position)Move the icon to a new position

Full example

All configuration options together:

html
<script src="https://agent.maison-labs.com/agent-inject.bundle.js"></script>
<script>
  function getQueryParam(param) {
    var queryString = window.location.search;
    var urlParams = new URLSearchParams(queryString);
    return urlParams.get(param);
  }
  var sessionId = getQueryParam('mcbsid');
  var mcAgent = window.initMcbs({
    clientId: 'YOUR_CLIENT_UUID',
    sessionId: sessionId,
    locale: 'en_US',
    iconPosition: { top: 0, bottom: 20, left: 0, right: 20 },
    onSessionUpdate: function(id) { console.log('Session:', id); },
    onLocaleUpdate: function(locale) { console.log('Locale:', locale); }
  });
  mcAgent.showIcon();
</script>