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);
});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
metadata
object
Structured details, such as picked quiz options or form values, when present
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
quiz_set_submitted
Finished a multi-question quiz, sending all answers at once
unknown
Sent the message some other way (for example, by clicking a nudge)
Chat origin
Message, quiz and form events carry an origin object saying which chat they came from. Pass it to getLatestCarouselProducts() to read the products shown in that chat (not supported for Product FAQs).
instance
string | null
For an embeddable agent, the slug of its placement. Otherwise null
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. Not fired for single quiz cards.
Callback data:
options
array
Array of option strings shown to the user
messageId
string
The ID of the message containing the options
question
string
The question being asked. Multi-question quizzes only
In a multi-question quiz, it fires once per question.
ticket:form_submitted
Fired when the user submits a form in the conversation, on its own or as a quiz step.
Callback data:
title
string
The form's title
messageId
string
The ID of the message containing the form
fields
object
The values the user entered, keyed by field name
E-commerce Events
Events for e-commerce integrations. These events help you connect the chat widget with your shopping cart and product pages.
Where the add came from
Alhena can recommend products from more than one place on your store, and both add-to-cart events carry a source telling you which one the shopper used. Use it to attribute revenue to the right surface, or to route each surface's adds to different cart behavior.
source value
The shopper added the product from…
CHAT_WIDGET
The chat widget — typed chat or a voice conversation
PRODUCT_FAQ
A Product FAQ block on a product page
AI_SEARCH
Conversational Search results
EMBEDDED_AGENT
An embeddable agent — panel or inline
product:added_to_cart
Fired when a customer adds a single product to their cart from an Alhena surface — the "Add to Cart" button on a product card, or an add the AI makes on the shopper's behalf.
Callback data:
variantId
string
The product variant ID
masterProductId
string
The product ID
productName
string
The product title
quantity
number
Quantity to add (usually 1)
price
number
Product price
currency
string
Currency code for the price, such as USD
category
string
The product's category
attributes
object
Variant options such as size or color, when your catalog has them
products:added_to_cart
Fired when several products are added to the cart at once — for example from a product bundle, an outfit or room set, or quiz results.
Callback data: an array of product objects. Each product object contains the same fields as product:added_to_cart:
variantId
string
The product variant ID
masterProductId
string
The product ID
productName
string
The product title
quantity
number
Quantity to add
price
number
Product price
currency
string
Currency code for the price, such as USD
category
string
The product's category
attributes
object
Variant options such as size or color, when your catalog has them
products:view_cart
Fired when a customer clicks View Cart on a product card, shown for products your setIsInCartHook() reports as in the cart. Open your cart from this handler.
Callback data: a single product object:
variantId
string
The product variant ID
masterProductId
string
The product ID
productName
string
The product title
price
number
Product price
currency
string
Currency code for the price, such as USD
category
string
The product's category
attributes
object
Variant options such as size or color, when your catalog has them
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
faqs:quiz_options_rendered
Fired for each question of a multi-question quiz in a Product FAQ answer.
Callback data: the same as ticket:quiz_options_rendered, including question and origin.
faqs:form_submitted
Fired when the user submits a form in a Product FAQ answer, on its own or as a quiz step.
Callback data: the same as ticket:form_submitted.
Embeddable Agent Events
Events for conversations in embeddable agents, such as the Product Quiz. Each mirrors the chat widget event of the same name; origin identifies the placement (see Chat origin).
embed:message_submitted
Fired when the user sends a message in an embeddable agent.
Callback data: the same as ticket:message_submitted.
embed:bot_response_finished
Fired when an embeddable agent has finished its response.
Callback data:
text
string
The complete response text
embed:quiz_options_rendered
Fired for each question of a multi-question quiz in an embeddable agent.
Callback data: the same as ticket:quiz_options_rendered, including question and origin.
embed:form_submitted
Fired when the user submits a form in an embeddable agent, on its own or as a quiz step.
Callback data: the same as ticket:form_submitted.
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.
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.
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
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