Update chatbot
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user