Javascript SDK

The Javascript SDK provides a simple javascript component that can be embedded within any existing website. This component provides two graphical components:

  1. a chat button displayed in the bottom right corner of the embedding website
  2. a chat window which pops up to reveal a user's chat when the chat button is clicked.

Basic Setup

The following script will ensure that the Javascript SDK is loaded asynchronously and displays the relevant chat button:

<script type="text/javascript">
  window.alcmeonInMessageConfig = {
    pageId: 'p_YOUR_PAGE_ID',
  };
  (function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "https://inmessage.alcmeon.com/prod/client/latest/mbr-v2.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'alcmeon-inmessage'));
</script>
  1. p_YOUR_PAGE_ID should be replaced by your account identifier available in the account details

  2. the DNS domain name where your website is hosted should be setup as an Allowed domain on the account connection page


Configuration options

The layout and behavior of the SDK can be configured with the window.alcmeonInMessageConfig variable which must be set before loading the SDK:

<script type="text/javascript">
  window.alcmeonInMessageConfig = {
    pageId: 'p_YOUR_PAGE_ID',
  };
  // ... 
</script>

alcmeonInMessageConfig

NameDescription
pageIdThis member is mandatory (all others are optional). You should set it to the page_id displayed within your account configuration page.
langCodeAn ISO-639 language code string to specify which language should be used to display static human-readable strings. The current implementation supports fr, en, de, es, and, it. If unspecified, the SDK will defaut to the browser's language. If the browser's language is not supported, the SDK will default to en.
refA string which contains the ref attribute of non-default entry points in the bot scenario configured for this page_id. If specified, XXX.
jwtA string which contains a JWT. If unspecified, the user session will be anonymous. If specified, the user will be associated with the unique user id and user metadata stored in this JWT. When used, this JWT should be generated server-side: it will be used as authentication for the Authenticate endpoint.
isMenuInitiallyOpenA boolean set to false by default. If true, if a persistent menu has been configured within the Alcmeon bot editor, it will be open when the user opens the chat window.
isChatInitiallyOpenA boolean variable set to false by default. If set to true, the chat window will be opened automatically once the page is loaded.

Translation

The labels and others placeholders are managed via the customization tool in the account details.