---
title: "JavaScript SDK: Callbacks"
description: "Handle widget events and lifecycle callbacks with the Gleap JavaScript SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/396-javascript-sdk-callbacks
collection: "JavaScript"
updated: 2026-11-01
language: en
---

# JavaScript SDK: Callbacks

Handle widget events and lifecycle callbacks with the Gleap JavaScript SDK. Follow the integration code examples.

Use the following callbacks to get notified on certain state changes of the Gleap widget. This enables you to create an even deeper integration with Gleap.

## On initialized

This allows you to get notified once Gleap is initialized and ready.

```javascript
Gleap.on("initialized", () => {
  console.log("Gleap got initialized and is ready :)");
});
```

## On notification count updated

This allows you to get updates on the unread notification count.

```javascript
Gleap.on("unread-count-changed", (unreadCount) => {
  console.log("unread-count-changed", unreadCount);
});
```

## On open

This allows you to get notified once Gleap opens.

```javascript
Gleap.on("open", () => {
  console.log("Gleap did open.");
});
```

## On close

This allows you to get notified once Gleap closes.

```javascript
Gleap.on("close", () => {
  console.log("Gleap did close.");
});
```

## On product tour completed

This allows you to get notified once a product tour gets completed.

```javascript
Gleap.on("productTourCompleted", (data) => {
  console.log(data);
});
```

## On conversation started

This allows you to get notified when the user starts a new conversation (with or without a bot workflow).

```javascript
Gleap.on("conversation-started", (data) => {
  console.log("User started a new conversation with optional workflow.");
  console.log(data.workflowId);
});
```

## On feedback sent

This allows you to get notified once feedback is sent.

```javascript
Gleap.on("feedback-sent", (formData) => {
  console.log("Gleap did send a feedback item.");
  console.log(formData);
});
```

## On outbound response sent

This allows you to get notified once a survey got answered.

```javascript
Gleap.on("outbound-sent", (outboundData) => {
  console.log("Gleap did send survey results.");
  console.log(outboundData);
});
```

For a survey, `outboundData` is `{ outboundId, outbound, formData }` with the answers by question key in `formData`; Surveys 2.0 adds `surveyId`, `responseId`, `endingId` and `status: "completed"`. `feedback-sent` fires for a completed survey too.

## On conversation rating

This allows you to get notified when a user submits a conversation rating in the widget.

```javascript
Gleap.on("rating-sent", (outboundData) => {
  console.log("User submitted conversation rating.");
  console.log(outboundData);
});
```

## On flow started

This allows you to get notified once a Gleap flow is started.

```javascript
Gleap.on("flow-started", (flow) => {
  console.log("The user selected a flow");
  console.log(flow);
});
```

## On error while sending feedback

This allows you to get notified if an error occurs while Gleap is trying to send a feedback item.

```javascript
Gleap.on("error-while-sending", () => {
  console.log("Ouch, something went wrong.");
});
```

## On checklist loaded

This allows you to get notified when a checklist is loaded.

```javascript
Gleap.on("checklist-loaded", (data) => {
  console.log("Checklist loaded:", data);
});
```

## On checklist step completed

This allows you to get notified when a user completes a step in a checklist.

```javascript
Gleap.on("checklist-step-completed", (data) => {
  console.log("Step completed:", data.stepId);
});
```

## On checklist completed

This allows you to get notified when a user completes an entire checklist.

```javascript
Gleap.on("checklist-completed", (data) => {
  console.log("Checklist completed!");
});
```

## Related

- [JavaScript SDK setup](https://docs.gleap.ai/en/articles/393-javascript-sdk-setup.md)
- [JavaScript SDK: Code snippet](https://docs.gleap.ai/en/articles/394-javascript-sdk-code-snippet.md)
- [JavaScript SDK: User identity](https://docs.gleap.ai/en/articles/395-javascript-sdk-user-identity.md)
- [JavaScript SDK: AI chatbar](https://docs.gleap.ai/en/articles/397-javascript-sdk-ai-chatbar.md)
- [JavaScript SDK: Frontend tools](https://docs.gleap.ai/en/articles/398-javascript-sdk-frontend-tools.md)
