Auto-Close After Handoff
Automatically close the chat widget after a conversation is transferred to a human agent.
Last updated
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto-Close Example</title>
</head>
<body>
<h1>Support Page</h1>
<p>Click the chat widget for assistance.</p>
<!-- Alhena SDK -->
<script>
document.gleenConfig = {
company: 'your-company-key',
apiBaseUrl: 'https://app.alhena.ai'
};
</script>
<script src="https://app.alhena.ai/sdk/gleenWidget.js"></script>
<!-- Auto-close logic -->
<script>
window.gleenWidget.on('ticket:agent_handoff', function(data) {
console.log('Handoff complete. Ticket ID:', data.ticketId);
// Wait 60 seconds, then close
setTimeout(function() {
window.gleenWidget.closeTicket(); // End the conversation
window.gleenWidget.close(); // Hide the widget
}, 60000);
});
</script>
</body>
</html>setTimeout(function() {
window.gleenWidget.closeTicket();
window.gleenWidget.close();
}, 30000); // 30 seconds instead of 60window.gleenWidget.on('ticket:agent_handoff', function(data) {
// Show a custom notification
showNotification('Your ticket has been created. A support agent will contact you via email.');
setTimeout(function() {
window.gleenWidget.closeTicket();
window.gleenWidget.close();
}, 60000);
});window.gleenWidget.on('ticket:agent_handoff', function() {
setTimeout(function() {
window.gleenWidget.closeTicket(); // Only close the ticket
// Widget stays visible, ready for new conversation
}, 60000);
});