An agent doesn't have to live in the Gleap messenger. You can open it from your own interface, embed its conversation as a component, or call it from code and do what you like with the answer.
Open the agent and choose Implementation to get the ready-made snippet for your agent, with its ID already filled in.
The simplest option. Call this from a button in your product and the agent's chat opens:
Gleap.startAgent("YOUR_AGENT_ID");You can also open it with the first question already asked, or with an opening message from the agent, which saves the user staring at an empty box:
Gleap.startAgent("YOUR_AGENT_ID", {
initialQuestion: "Where is my order?"
});If the agent should sit inside a page rather than open over it, use the conversation element:
<gleap-agent-conversation agentId="YOUR_AGENT_ID" />This suits a dedicated support page or a panel beside the thing the user is working on.
When you want the answer but not Gleap's interface, send a message and use the result in your own UI. The call resolves to an object with the answer text, a run ID, a status, and a conversation ID:
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 rather than starting a fresh one, so the agent still has what was said before:
const next = await Gleap.sendAgentMessage(
"YOUR_AGENT_ID",
"And when does it arrive?",
{ conversationId }
);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 is doing work behind your own interface — filling in a field, drafting something a user then edits — and a chat window would be in the way.