---
title: "Control the messenger from your code"
description: "Open the messenger from your own buttons, launch a specific workflow, tour or survey, and react to what the user does."
url: https://help.gleap.ai/fr/articles/364-control-the-messenger-from-your-code
collection: "Developer guides"
updated: 2026-11-16
language: fr
alternates: [en]
---

# Control the messenger from your code

Open the messenger from your own buttons, launch a specific workflow, tour or survey, and react to what the user does.

The launcher is one way in. The SDK is the other, and it's how you connect Gleap to the help menu, empty states and error screens you already have. The examples are JavaScript. The mobile SDKs have most of the same calls; product tours, `startAgent` and `setUrlHandler` are web only.

### Open and close

```javascript
Gleap.open();
Gleap.close();
Gleap.isOpened(); // true / false
```

To run without the floating launcher entirely, with your own button and nothing of Gleap's:

```javascript
Gleap.showFeedbackButton(false);
```

### Open a specific place

Landing someone on the messenger home when you know what they want is a wasted click. Each of these opens straight to the point:

```javascript
Gleap.openHelpCenter();
Gleap.openHelpCenterArticle("42");
Gleap.openHelpCenterCollection("7");
Gleap.searchHelpCenter("invoice");
Gleap.openConversations();
Gleap.startConversation();
Gleap.openNews();
Gleap.openFeatureRequests();
Gleap.openChecklists();
```

Most take an optional `showBackButton`. Pass `false` when you're sending someone to one specific thing and a back button would only offer a place they never came from.

A help icon that runs `searchHelpCenter` with the current screen's name is a small change that answers a lot of questions before they're asked.

### Start a flow

```javascript
Gleap.startBot("WORKFLOW_ID");
Gleap.startClassicForm("bugreporting");
Gleap.startProductTour("TOUR_ID");
Gleap.startChecklist("CHECKLIST_ID");
Gleap.showSurvey("SURVEY_ID");
```

This is how a tour starts after your own onboarding step rather than on a page rule, or a bug form opens from your error boundary with the failure already in context.

For AI:

```javascript
Gleap.askAI("How do I export my data?");
Gleap.startAgent("AGENT_ID", {
  initialQuestion: "How do I export my data?",
});
```

### Find the IDs

You rarely need to look an ID up by hand: the dashboard shows the ready-made call with the ID filled in.

-   **Workflow**: in the workflow's trigger settings, under **Start by code**.
    
-   **Product tour**: in the tour's settings, under **Start the product tour by code**. Checklists show the same kind of snippet.
    
-   **Survey**: on the survey's **Share** tab.
    
-   **AI agent**: open the agent's actions menu and choose **Use in SDK**.
    
-   **Help center article**: **Share article** shows the `openHelpCenterArticle` call.
    
-   **Forms**: the built-in forms are `bugreporting` and `featurerequests`; a custom form uses its own form key.
    

### Give the ticket context

Set these before opening a form, and they land on whatever ticket gets created:

```javascript
Gleap.setTicketAttribute("screen", "billing-settings");
Gleap.preFillForm({ subject: "Payment failed" });
Gleap.startClassicForm("bugreporting");
```

Anything you can set here is something the customer doesn't have to type and an agent doesn't have to ask for.

### React to what happens

```javascript
Gleap.on("initialized", () => {
  // safe to call other Gleap methods
});

Gleap.on("open", () => {});
Gleap.on("close", () => {});
Gleap.on("checklist-completed", (data) => {});
```

Waiting for `initialized` matters when your code runs early. It's the fix for calls that appear to do nothing on first load.

### Handle links yourself

```javascript
Gleap.setUrlHandler((url, newTab) => {
  // route internally instead of a full page load
});
```

Worth doing in a single-page app, where the default behaviour would reload the page.

> **Info:** Every method here has its arguments documented per platform at [docs.gleap.ai](https://docs.gleap.ai/introduction). The list of what exists is in the [SDK method index](https://help.gleap.ai/en/articles/363-sdk-method-index.md).

### Related

-   [SDK method index](https://help.gleap.ai/en/articles/363-sdk-method-index.md)
    
-   [Give an agent context about the current user](https://help.gleap.ai/en/articles/255-give-an-agent-context-about-the-current-user.md)
    
-   [Build a workflow](https://help.gleap.ai/en/articles/311-build-a-workflow.md)
