💬 Persistent Conversations
Ensure seamless and continuous user interactions with persistent conversations. This section covers how to maintain context across multiple sessions, enabling your chatbot to remember user inputs and preferences, creating a more personalized and engaging experience.
A persistent conversation allows the chatbot to save chat interactions across pages within the same domain. This means when a user navigates between different pages or exits the session and returns later, the chatbot will continue from where it left off, displaying the prior conversation.
How to Enable Persistent Conversations
To enable this feature, simply add the following line to your integration script:
widget.setAttribute("useLocalStorage", "true");
This instructs the widget to store the chat data in the browser’s localStorage, ensuring conversations are retained across sessions.
Full Integration Script Example
<script>
// Example: Set up a div with proper responsiveness, width, and height
var widget = document.createElement("destygo-webchat");
widget.setAttribute('id', "destygo_widget");
widget.setAttribute('class', "destygo_widget");
widget.setAttribute('token', "d8380225-f558-f1d8-d055-f022657c95c4"); // Your widget token
widget.setAttribute("useLocalStorage", "true"); // Enable conversation persistence
document.body.appendChild(widget);
</script>
<script type="text/javascript" src="<https://widget.mindsay.com/destygo-webchat.js>"></script>
Key Points:
- useLocalStorage: This attribute saves the chat data in the browser's localStorage, making it persistent across the same domain.
- Same Domain: Persistence only works when the user navigates across pages within the same domain. If the user moves to a different domain, the conversation won't carry over.
- Widget Token: Replace the token (
"d8380225-f558-f1d8-d055-f022657c95c4"
) with your own chatbot’s token.