githubEdit

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:loaded

Widget

Widget finished loading

widget:opened

Widget

Widget was opened

widget:closed

Widget

Widget was closed

ticket:message_submitted

Ticket

User sent a message

ticket:bot_response_finished

Ticket

Bot completed its response

ticket:agent_handoff

Ticket

Ticket transferred to human agent

ticket:agent_handoff_initiated

Ticket

Human handoff process started

ticket:link_clicked

Ticket

User clicked a link in chat

ticket:input_focused

Ticket

User focused the input field

ticket:attachment_added

Ticket

User attached a file

product:added_to_cart

E-commerce

User clicked "Add to Cart"

products:added_to_cart

E-commerce

Multiple products added to cart

product:page_opened

E-commerce

User clicked a product link

product:displayed

E-commerce

Product card was rendered

faqs:question_clicked

FAQ

User clicked a FAQ question

faqs:message_submitted

FAQ

User submitted a FAQ question

faqs:bot_response_finished

FAQ

Bot finished FAQ response

experiment:loaded

Experiment

A/B test group assigned

icebreaker_question:postback

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: None

widget:opened

Fired when the chat widget is opened (expanded).

Callback: None

widget:closed

Fired when the chat widget is closed (minimized).

Callback: 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 parameters:

Property
Type
Description

text

string

The message text sent by the user

submitAction

string

The action that triggered the submission

ticket:bot_response_finished

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

Callback parameters:

Property
Type
Description

response

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 parameters:

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: None

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

Callback parameters:

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: None

ticket:attachment_added

Fired when the user attaches a file to their message.

Callback parameters:

Property
Type
Description

fileName

string

Name of the attached file

fileType

string

MIME type of the file

fileSize

number

Size in bytes


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 parameters:

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 parameters:

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 parameters:

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 parameters:

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 parameters:

The callback receives the question text as a string directly.

faqs:message_submitted

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

Callback parameters:

The callback receives the user's question as a string directly.

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 parameters:

The callback receives the AI's complete response as a string directly.


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 parameters:

The callback receives a string directly (not an object): 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 parameters:

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