// widget.js document.getElementById('userInput').addEventListener('keydown', function(event) { if (event.key === 'Enter') { sendMessage(); } }); function sendMessage() { const userInput = document.getElementById('userInput').value; if (userInput) { addMessageToChatbox('User', userInput); document.getElementById('userInput').value = ''; fetch('https://your-backend-server.com/api/message', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: userInput }) }) .then(response => response.json()) .then(data => { addMessageToChatbox('Chatbot', data.message); }) .catch(error => { console.error('Error:', error); }); } } function addMessageToChatbox(sender, message) { const chatbox = document.getElementById('chatbox'); const messageElement = document.createElement('div'); messageElement.textContent = `${sender}: ${message}`; chatbox.appendChild(messageElement); chatbox.scrollTop = chatbox.scrollHeight; }
Chatbot Interface

(819) 477 7417

Entrer en contact

Itinéraire