Events
Complete reference for all events emitted by the Alhena Website SDK, organized by category with callback signatures and examples.
The Alhena Website SDK emits JavaScript events that allow you to respond to user interactions and widget state changes. Use these events to customize the user experience, track analytics, or integrate with other systems.
Subscribing to Events
Use the window.gleenWidget.on() method to subscribe to events:
window.gleenWidget.on("event_name", function (data) {
// Handle the event
console.log("Event fired:", data);
});Event subscriptions should be set up after the SDK script loads. For best results, place your event handlers after the SDK script tag or inside a widget:loaded handler.
Quick Reference
Widget Events
Events related to the widget's state and lifecycle.
widget:loaded
Fired when the widget has finished loading and is ready for interaction. Use this event to safely set up other event handlers or perform initial configuration.
Callback data: None
widget:opened
Fired when the chat widget is opened (expanded).
Callback data: None
widget:closed
Fired when the chat widget is closed (minimized).
Callback data: None
Ticket/Conversation Events
Events related to chat conversations and messages.
ticket:message_submitted
Fired when the user sends a message in the chat widget.
Callback data:
text
string
The message text sent by the user
submitAction
string
How the message was sent — see the table below
submitAction values:
button_click
Typed a message and clicked the send button
enter_key
Typed a message and pressed Enter
icebreaker_clicked
Tapped one of the starter questions shown before the conversation began
suggested_question_clicked
Tapped one of the follow-up questions suggested under a reply
quiz_option_clicked
Picked an answer in a guided quiz
unknown
Sent the message some other way (for example, by clicking a nudge)
ticket:bot_response_finished
Fired when the AI bot has finished generating and streaming its response.
Callback data:
text
string
The complete bot response text
ticket:agent_handoff
Fired when a ticket has been successfully created in the helpdesk system after the user submits their email during human handoff.
Callback data:
ticketId
string
The ID of the created ticket
email
string
The user's email address
ticket:agent_handoff_initiated
Fired when the AI determines that the conversation should be transferred to a human agent. At this stage, the AI is waiting for the user to submit their email address.
Callback data: None
ticket:link_clicked
Fired when the user clicks a link within a chat message.
Callback data:
url
string
The URL that was clicked
text
string
The link text
ticket:input_focused
Fired when the user focuses on the message input field.
Callback data: None
ticket:attachment_added
Fired when the user attaches a file to their message.
Callback data:
fileName
string
Name of the attached file
fileType
string
MIME type of the file
fileSize
number
Size in bytes
ticket:closed
Fired when a conversation is closed.
Callback data:
ticket_id
string
The ID of the closed ticket
ticket:email_submitted
Fired when the user submits their email address during the human handoff flow, before the ticket is created in the helpdesk.
Callback data:
email
string
The email address submitted by the user
ticket:quiz_options_rendered
Fired when quiz option buttons are displayed in the conversation.
Callback data:
options
array
Array of option strings shown to the user
messageId
string
The ID of the message containing the options
E-commerce Events
Events for e-commerce integrations. These events help you connect the chat widget with your shopping cart and product pages.
Important: By adding an event handler for the product:added_to_cart event, you will cause the "Add to Cart" button to appear in product cards. You must implement custom JavaScript specific to your e-commerce platform to handle this event.
product:added_to_cart
Fired when a customer clicks the "Add to Cart" button on a product card within the chat widget.
Callback data:
variantId
string
The product variant ID
productId
string
The product ID
quantity
number
Quantity to add (usually 1)
price
number
Product price
products:added_to_cart
Fired when multiple products are added to cart at once (e.g., from a product bundle or quiz results).
Callback data:
products
array
Array of product objects
Each product object contains:
variantId
string
The product variant ID
productId
string
The product ID
quantity
number
Quantity to add
product:page_opened
Fired when a customer clicks a product link rendered inside the chat widget.
Callback data:
variantId
string
The product variant ID
productId
string
The product ID
url
string
The product page URL
product:displayed
Fired when a product card is rendered inside the chat widget.
Callback data:
variantId
string
The product variant ID
productId
string
The product ID
FAQ Events
Events for the Product FAQ feature.
faqs:question_clicked
Fired when a user clicks on an AI-generated FAQ question.
Callback data:
text
string
The question text
faqs:message_submitted
Fired when a user submits a custom question in the product FAQ text box.
Callback data:
text
string
The user's question
submitAction
string
How the question was sent: button_click (clicked send) or enter_key (pressed Enter)
Taps on the FAQ questions themselves fire faqs:question_clicked rather than this event.
faqs:bot_response_finished
Fired when the AI completes its response in the FAQ widget. This applies to both clicked FAQ questions and custom user questions.
Callback data:
text
string
The AI's complete response
faqs:link_clicked
Fired when a user clicks a link within a FAQ response.
Callback data:
url
string
The URL that was clicked
Experiment Events
Events for A/B testing functionality.
experiment:loaded
Fired when an active A/B test experiment is running and the user has been assigned to a group. See A/B Testing for full documentation.
Callback data: string — either 'test' or 'control'
Icebreaker Events
Events related to conversation starters and quick replies.
icebreaker_question:postback
Fired when a user clicks an icebreaker question or quick reply button.
Callback data:
question_text
string
The icebreaker question text
type
string
The type of icebreaker
postback_payload
string
The postback payload value
Nudge Events
Events for AI Nudges. These let you build a custom nudge UI driven by the same standard nudge logic (page matching, timer/scroll triggers, dismissal rules) that powers the built-in nudge.
These events fire whether or not the default nudge UI is visible. To suppress Alhena's built-in launcher and nudge UI and render your own, set hideDefaultUI: true in your config, then use clickNudge() to run the standard click behavior from your own elements.
All three events deliver the same payload describing the nudge:
id
string
The nudge's unique ID
nudge_type
string
The nudge type — generic or product_faqs
nudge_texts
array
The nudge text(s) to display, trimmed and with empty entries removed
nudge_button_text
string
The configured call-to-action button label (e.g. "Ask us"). May be empty, in which case the built-in UI shows no button
nudge_header_title_text
string
The configured nudge header title
nudge:loaded
Fired as soon as a nudge has been matched for the current page and its text is available — before any trigger condition (timer/scroll) is met. Use it to prepare your custom nudge UI ahead of time.
Callback data: the nudge payload described above.
nudge:triggered
Fired when the standard nudge show logic activates — the trigger condition (timer elapsed or scroll threshold met) is satisfied, the nudge hasn't been dismissed, and the widget is closed. This is the moment a custom nudge UI should reveal itself.
Callback data: the nudge payload described above.
When the visitor clicks your custom nudge, call window.gleenWidget.clickNudge() to run the exact same behavior (analytics + opening the conversation) as the built-in nudge.
nudge:hidden
Fired when a nudge that was showing should now be taken down. This is the counterpart to nudge:triggered — hide your custom nudge UI here.
Callback data: the payload of the nudge that was showing (not of any nudge that matches next).
A single nudge:hidden covers every reason a nudge goes away, and the payload doesn't say which one it was. The common causes:
The visitor interacted with the Product FAQ widget — clicked a question or sent a message
The visitor dismissed the nudge with the built-in close button (suppressed for 30 minutes), or dismissed it in another browser tab
The chat widget opened, including by clicking the nudge itself
Your site called
hideNudge()On a single-page app, the visitor navigated to a page that matches no nudge
An A/B test placed the visitor in the control group
Nudge events are not replayed to handlers registered after they fire. Subscribe right after the SDK <script> tag — early registrations are preserved — rather than waiting for a later moment.
Complete Example
Here's a complete example showing how to set up multiple event handlers:
Related Resources
JavaScript API - Complete method reference
A/B Testing - Experiment setup and events
Cart & Checkout Events - Revenue tracking
Examples - Code examples for common use cases
Last updated