Configure automatic user authentication in LiveChat. Then, after authentication on a website or portal, the user will not have to fill out another authentication form in LiveChat to start correspondence with an operator.
The setting also allows you to save the correspondence history if the user sign in the website from another device or browser.
To do this:
- 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.
- 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;
- hash. The hash key for user authentication;
- name. The user’s name;
- email. The user’s email address;
- phone. The user’s phone number.
Code example:
elma365LiveChatProfile=’{"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "hash": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "name": "User name", "email": "email@email.ru", "phone": "+79999999999"}’
Here is an example of using the elma365LiveChatProfile
attribute to embed LiveChat on a portal page:
- Open the portal page that contains LiveChat in the interface designer. Click the Context tab and create a
user_data
variable to store user data. - 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 ?? ' '
});
- Go to the Template tab and open the settings for the Code widget that is added to embed LiveChat. In the code text, to the
elma365LiveChatFormId
attribute, add theelma365LiveChatProfile
attribute with theuser_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>
- Save and publish the changes of the portal page template.
Found a typo? Highlight the text, press ctrl + enter and notify us