# Website SDK events

Alhena AI chat sdk emits the following js events, that can be used to customize the user experiences.

You can use the `window.gleenWidget.on(eventName, callback` function to subscribe to these events.

See [](<> "mention") for more details

**widget:opened -** This is called when widget successfully get opened

**widget:closed** - This is called when the widget successfully get closed

**widget:loaded** - This is called when the widget successfully loaded and reading to do the integration

**ticket:agent\_handoff:**  This is called when AI successfully created the ticket in help desk after human user has submitted the email in human hand off.

**ticket:agent\_handoff\_initiated:** This is called when AI detects that it needs to send the prompt for email ask. At this stage AI is awaiting email from user to submit in the form. Once user submits the form a ticket is created and **ticket:agent\_handoff** is calle&#x64;**.**

**ticket:message\_submitted:** This is called when user sends a message in the widget.&#x20;

**ticket:bot\_response\_finished:** This is called when AI response is delivered in the widget

For e-commerce companies there are additional chat events sent in the sdk

**product:added\_to\_cart** : This is called when customer clicks add to cart inside the chat widget. It is useful to trigger code on your site to actually add the item to the cart, and show the user a cart popup or page.&#x20;

{% hint style="info" %}
IMPORTANT: By add an event handler for the added to cart event, you will cause the "Add to Cart" button to start showing in product cards. You must add custom JavaScript specific to your website implementation to handle this event.
{% endhint %}

**product:page\_opened** : This is called when custome opens a product link rendered inside the chat widget

**product:displayed**: This is called when a product is rendered as a card inside the Gleen chat widget.

**faqs:question\_clicked :** This is called when AI generated FAQ is clicked

```javascript
 window.gleenWidget.on('faqs:question_clicked', function(question_text) {
   console.log('question text clicked. Question Text ' + question_text);
 });
```

**faqs:message\_submitted** : This is called when end user submits message in text box in product FAQ.

```javascript
 window.gleenWidget.on('faqs:message_submitted', function(user_message) {
   console.log('User asked question in product FAQ. User message is' + user_message);
 });
```

**faqs:bot\_response\_finished**: This is called when AI completes the streaming of response. It is applicable for both Product FAQ question clicked and message submitted in the text box.

```javascript
 window.gleenWidget.on('faqs:bot_response_finished', function(response_text) {
   console.log('AI Finished the response. Response is ' + response_text);
 });
```
