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);
});
circle-info

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

Event
Category
Description

Widget

Widget finished loading

Widget

Widget was opened

Widget

Widget was closed

Ticket

User sent a message

Ticket

Bot completed its response

Ticket

Ticket transferred to human agent

Ticket

Human handoff process started

Ticket

User clicked a link in chat

Ticket

User focused the input field

Ticket

User attached a file

Ticket

Conversation was closed

Ticket

User submitted their email during handoff

Ticket

Quiz option buttons were displayed

E-commerce

User clicked "Add to Cart"

E-commerce

Multiple products added to cart

E-commerce

User clicked a product link

E-commerce

Product card was rendered

FAQ

User clicked a FAQ question

FAQ

User submitted a FAQ question

FAQ

Bot finished FAQ response

FAQ

User clicked a link in a FAQ response

Experiment

A/B test group assigned

Widget

User clicked an icebreaker


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:

Property
Type
Description

text

string

The message text sent by the user

submitAction

string

How the message was sent: button_click, enter_key, or quiz_option_clicked


ticket:bot_response_finished

Fired when the AI bot has finished generating and streaming its response.

Callback data:

Property
Type
Description

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:

Property
Type
Description

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


Fired when the user clicks a link within a chat message.

Callback data:

Property
Type
Description

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:

Property
Type
Description

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:

Property
Type
Description

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:

Property
Type
Description

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:

Property
Type
Description

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.

circle-info

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:

Property
Type
Description

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:

Property
Type
Description

products

array

Array of product objects

Each product object contains:

Property
Type
Description

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:

Property
Type
Description

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:

Property
Type
Description

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:

Property
Type
Description

text

string

The question text


faqs:message_submitted

Fired when a user submits a custom question in the product FAQ text box.

Callback data:

Property
Type
Description

text

string

The user's question

submitAction

string

How the message was sent: button_click, enter_key, or quiz_option_clicked


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:

Property
Type
Description

text

string

The AI's complete response


Fired when a user clicks a link within a FAQ response.

Callback data:

Property
Type
Description

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:

Property
Type
Description

question_text

string

The icebreaker question text

type

string

The type of icebreaker

postback_payload

string

The postback payload value


Complete Example

Here's a complete example showing how to set up multiple event handlers:


Last updated