---
title: "JavaScript SDK: Custom actions"
description: "Handle custom actions triggered by the widget with the Gleap JavaScript SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/407-javascript-sdk-custom-actions
collection: "JavaScript"
updated: 2026-11-01
language: en
---

# JavaScript SDK: Custom actions

Handle custom actions triggered by the widget with the Gleap JavaScript SDK. Follow the integration code examples.

_Tags_: JavaScript, React, Vue, Angular, Website, Web App

We know that the built in actions (Bug Reporting, Feature Requests, Ratings & Contact Us) might not be enough for certain use cases. For these situations we offer custom actions, which allow you to start any custom action by code.

## Configure a custom action

Open Settings → Widget → Content → Quick actions. Add or open a quick action, choose Custom action, and enter its Custom action name. Use that exact name in the handler below.

Now you need to **set a name for your custom action**. Choose any name you like (it's however important that this name matches the name you check in the next step).

![Current messenger quick-action settings in the Pied Piper demo project.](https://staticfiles.gleap.io/p613b5dd730aed737108f87ab/gmAdnE7X2jnNhNn1dRmzvgLczFyPAIF7Qsn2PicWuQHx4eAMN1Er2Il0dBP2VBl1brGt4Zn56QT.png)

## Custom action callback

Once you set a custom action in the Gleap dashboard, it will be called automatically on selection through the user. In order to perform custom code, simply listen for custom actions by using the `registerCustomAction` method.

If you use multiple custom actions, we suggest you check the triggered custom action's name in order to find out which custom action got triggered.

```javascript
Gleap.registerCustomAction((customAction) => {
  // For custom actions triggered within tickets, customAction.shareToken will be set to identify the ticket.
  if (customAction.name === "MAGIC_ACTION") {
    alert("It's magic!");
  }
});
```

> **Info:** The **custom action name** is defined by you in the visual widget configurator.

## 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: Callbacks](https://docs.gleap.ai/en/articles/396-javascript-sdk-callbacks.md)
- [JavaScript SDK: AI chatbar](https://docs.gleap.ai/en/articles/397-javascript-sdk-ai-chatbar.md)
