Read-Only Mode
Applying the Read-Only Mode
The read-only mode is a versatile feature designed to restrict user interaction within the chat, allowing only message viewing while disabling all other interface controls. Below is a detailed guide on how to configure and use this mode effectively.
Possible Values
true
When set to true, the chat enters read-only mode. Users in this mode can:
Read messages: Messages are fully visible and accessible for reading.
Navigate to the latest messages: Using the arrow button provided in the interface.
Users cannot:- Send messages.
- React to messages.
- Interact with any other chat elements.
false
When set to false or omitted, the chat operates in its default interactive mode, allowing users all actions.
Additional Considerations for Non-Authorized Zones
In scenarios where users are accessing the chat in a non-authorized zone (e.g., as guests), it is important to ensure that a unique userId is still provided to facilitate proper tracking and interaction handling. Even in read-only mode, assigning a unique identifier helps maintain user session integrity and enables accurate engagement analytics.
Read-only Interaction Tracking
User Interaction Events in Read-Only Mode
In read-only mode, user interactions are limited, but it is still essential to track engagement through a mechanism that notifies the parent application of user actions. This allows for the implementation of necessary scenarios, such as triggering user authorization.
Key Points on User Actions:
- Excluded Actions:
- Accepting chat rules (pop-up)
- Interacting with a welcome message (pop-up)
These actions do not trigger a notification event.
- Tracked Actions:
Any other interaction attempts within the chat will dispatch an event to the parent window.
Event Notification Mechanism
When a user attempts to interact with the chat in read-only mode (excluding the excluded actions), an event is sent to the parent window via the postMessage
API.
Event Details:
Type: watchersAttemptClick
Purpose: To notify the parent application of user interaction attempts within the read-only chat.
Example Implementation of Event Handling
The parent application can handle these events using an event listener. Below is an example of how to implement this functionality:
window.addEventListener('message', (event) => { if (event.data.type === 'watchersAttemptClick') { // Handle the user interaction event console.log('User interaction detected in read-only chat.'); } });
Updated 2 months ago