K
KOS COMPANY
Ciao, vuoi informazioni sul nostro servizio?
Oppure hai intenzione di sviluppare un prodotto?
`; messagesContainer.appendChild(holder); messagesContainer.scrollTop=messagesContainer.scrollHeight; } function hideTyping(){ const el=document.getElementById("typingIndicator"); if(el) el.remove(); } /* Send */ function sendMessage(){ const userText = input.value.trim(); if(!userText) return; ensureChatId(); appendUser(userText); input.value=""; showTyping(); fetch(webhookUrl,{ method:"POST", headers:{ "Content-Type":"application/json" }, body: JSON.stringify({ question: userText, chat_id: CHAT_ID }) }) .then(r=>r.json()) .then(data=>{ hideTyping(); const payload = Array.isArray(data) ? (data[0]||{}) : (data||{}); const reply = payload.reply || {}; // prendiamo SOLO details (fallback a text/data) let detailsRaw = reply.details || payload.data || reply.text || ""; const isRichList = /{ hideTyping(); appendBotDetails("

⚠️ Errore di connessione.

"); }); } // Enter per inviare document.getElementById("userInput").addEventListener("keypress", e=>{ if(e.key==="Enter") sendMessage(); });