---
title: "Embed an agent in your product"
description: "Open a custom agent's chat from your own UI, embed it as a component, or call it headlessly and use the answer yourself."
url: https://help.gleap.ai/fr/articles/254-embed-an-agent-in-your-product
collection: "Custom AI agents and skills"
updated: 2026-11-01
language: fr
alternates: [en]
---

# Embed an agent in your product

Open a custom agent's chat from your own UI, embed it as a component, or call it headlessly and use the answer yourself.

A customer-facing custom agent can open from your own interface, appear as an embedded conversation or answer through code. The calls below are part of the Gleap JavaScript SDK. Team agents are intended for internal work; use a customer agent with the **Reply to customer** tool for these customer-facing experiences.

### Get the snippet for your agent

1.  Open the agent under **AI agents**.
    
2.  Open the **⋯** menu in the header and choose **Use in SDK**.
    
3.  Pick **Managed UI**, **Headless** or **Component** and copy the code. Your agent's ID is already filled in.
    

![Agent sdk screen in the Pied Piper demo project.](https://staticfiles.gleap.io/p613b5dd730aed737108f87ab/OnNkH9h0LaxArFdO19ah72Ag88KQsvienlUv8r6JnrtJOXrAHxyYsA6efpEm3MvVys2gmgOmFeY.png)

> **Warning:** The code only appears once the agent has the **Reply to customer** tool. Without it, the agent has no way to say anything to the user, so there's nothing to embed.

### Open the agent's chat

The simplest option. Call this from a button in your product and the agent's chat opens:

```javascript
Gleap.startAgent("YOUR_AGENT_ID");
```

You can open it with a first question already asked (`initialQuestion`), or with a greeting from the agent (`initialMessage`), so the user doesn't face an empty box:

```javascript
Gleap.startAgent("YOUR_AGENT_ID", {
  initialQuestion: "Where is my order?"
});
```

### Embed the conversation as a component

If the agent should sit inside a page instead of opening over it, use the conversation element:

```html
<gleap-agent-conversation agentId="YOUR_AGENT_ID" />
```

This suits a dedicated support page or a panel next to what the user is working on.

### Call it headlessly

When you want the answer but not Gleap's interface, send a message and use the result in your own UI. The call returns the answer text, a run ID, a status and a conversation ID:

```javascript
const { response, conversationId } = await Gleap.sendAgentMessage(
  "YOUR_AGENT_ID",
  "Where is my order?"
);
```

Pass that conversation ID on the next call to continue the same thread, so the agent still knows what was said:

```javascript
const next = await Gleap.sendAgentMessage(
  "YOUR_AGENT_ID",
  "And when does it arrive?",
  { conversationId }
);
```

### Which one to use

Use the chat when the agent is something the user talks to. Use the component when it belongs inside a page you already own. Use the headless call when the agent works behind your own interface, such as filling in a field or drafting text the user then edits, and a chat window would be in the way.

### Related

-   [Give an agent context about the current user](https://help.gleap.ai/en/articles/255-give-an-agent-context-about-the-current-user.md)
    
-   [Let an agent run actions inside your app](https://help.gleap.ai/en/articles/251-let-an-agent-run-actions-inside-your-app.md)
    
-   [Control the messenger from your code](https://help.gleap.ai/en/articles/364-control-the-messenger-from-your-code.md)
