Files
demo-mayagen/dashboard-page/scripts/main.js
emmanuel.rizky 84c7cbd8ce feat(chat): Integrate chatbot API for dynamic responses
This commit replaces the static, simulated chat functionality with a live integration to a chatbot backend API.

The chat page now sends user messages to a webhook endpoint using the `fetch` API. It implements session management by generating and storing a `sessionId` in `localStorage` to maintain conversation context between requests.

Key changes:
- Implement `async` `sendMessage` function to post to the chatbot API.
- Add session ID generation and persistence.
- Dynamically render text and image responses from the API.
- Remove hardcoded example messages from the HTML.
- Update the virtual assistant's name to "Maya".
- Fix navigation links from the dashboard to the chat page.
2025-07-21 14:44:06 +07:00

17 lines
542 B
JavaScript

// Toggle dropdown menu visibility
const menuButton = document.querySelector('.mobile-header-menu-button');
const dropdownMenu = document.querySelector('.dropdown-menu');
if (menuButton && dropdownMenu) {
menuButton.addEventListener('click', function() {
dropdownMenu.classList.toggle('hidden');
});
}
// Close dropdown when clicking outside
document.addEventListener('click', function(event) {
if (!event.target.closest('.mobile-header-right') && dropdownMenu) {
dropdownMenu.classList.add('hidden');
}
});