Automatic authentication in LiveChat

Configure automatic user authentication in LiveChat when logging into the website or portal. Then:

  • The user will not have to fill out another authentication form in LiveChat to start correspondence with an operator.
  • The correspondence history will be saved, even if the user logs in from another device or clears the browser cache.

To do this:

  1. Set the prohibition to manually fill in the data for authentication in the chat. For this, go to LiveChat settings and uncheck all the checkboxes in the option User authentication fields.
  2. Go to the website or portal page settings, open the code text for the LiveChat embedding, and add the elma365LiveChatProfile attribute to it using the following parameters with the String data type:
    • id. The user ID filled in the GUID format.
    • hash. The hash key for user authentication filled in the GUID format.
    • name. The user’s name.
    • email. The user’s email address.
    • phone. The user’s phone number.

Example of filling in the attribute:

elma365LiveChatProfile=’{"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "hash": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "name": "User name", "email": "email@email.com", "phone": "+1000000000"}’

Configure automatic authentication on an external portal

Here is an example of using the elma365LiveChatProfile attribute to embed LiveChat on an external portal page:

  1. Open the portal page that contains a LiveChat in the interface designer. Click the Context tab and create a user_data variable to store user data.
  2. Go to the Scripts tab and add code to the onInit() function that will store user data in the user_data variable in string format:

const user = await System.users.getCurrentUser();
const HASH_KEY = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
Context.data.user_data = JSON.stringify({
      id: user.data.__id,
      hash: HASH_KEY,
      name: user.data.__name,
      email: user.data.email ?? ' ',
      phone: user.data.phone ?? ' '
});

  1. Go to the Template tab and open the settings for the Code widget that is added to embed the LiveChat. In the code text,  to the elma365LiveChatFormId attribute, add the elma365LiveChatProfile attribute with the user_data variable:

<script>
 let loader = document.querySelectorAll('[src="https://domain.elma365.ru/assets/livechat/assets/elma365.livechat.loader.js"]')[0];
 loader.setAttribute('elma365LiveChatFormId', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
 loader.setAttribute('elma365LiveChatProfile', '<%= Context.data.user_data %>');
</script>

  1. Save and publish the changes of the portal page template.