Update chatbot

This commit is contained in:
2026-03-26 15:45:54 -04:00
parent 169820240a
commit 3687003935
5 changed files with 128 additions and 39 deletions
+6 -1
View File
@@ -628,13 +628,18 @@ async function sendChat(){
typing.remove();
const reply = d.reply || 'Sorry, I encountered an error.';
appendBubble(reply,'bot');
chatHistory.push({role:'assistant',content:reply});
if(d.ticket){
// Clear history after ticket creation — keeping the prior conversation
// (which contains the AI's JSON action block) causes the model to
// re-trigger ticket creation on every subsequent message.
chatHistory = [];
const notif=document.createElement('div');
notif.className='chat-bubble bot';
notif.style.cssText='background:rgba(45,212,191,.1);border:1px solid rgba(45,212,191,.3);';
notif.innerHTML=`🎫 <strong>${d.ticket.ticket_number}</strong> — <a href="${d.ticket.url}">View Ticket</a>`;
document.getElementById('chat-messages').appendChild(notif);
} else {
chatHistory.push({role:'assistant',content:reply});
}
}catch(e){typing.remove();appendBubble('Sorry, something went wrong.','bot');}
scrollChat();