Agent Chat SDK
Getting Started
Install and set up the Agent Chat SDK in your project.
Installation
Install the SDK via your preferred package manager:
npm install @zelto/agent-chat-sdkpnpm add @zelto/agent-chat-sdkyarn add @zelto/agent-chat-sdkBasic usage
Import and initialize the SDK, then mount the chat widget:
import { init, mountChat } from '@zelto/agent-chat-sdk';
init({
apiKey: 'your-api-key',
userId: 'user-123',
baseUrl: 'https://api.zelto.ai',
});
mountChat();Required options
| Option | Type | Description |
|---|---|---|
apiKey | string | Your Zelto API key (found in the dashboard). |
userId | string | A unique identifier for the current user. |
Optional options
| Option | Type | Description |
|---|---|---|
baseUrl | string | API base URL. Required for sending messages. |
agentId | string | Override the default agent. |
articlesUrl | string | If set, shows an Articles tab in the widget. |
theme | AgentChatThemeOptions | Customize colors and border radius. |
personalization | AgentChatPersonalizationOptions | Set greeting, title, logo, and avatar. |
Unmounting
To remove the chat widget from the page:
import { unmountChat } from '@zelto/agent-chat-sdk';
unmountChat();Debugging
Use getConfigForDebug() to inspect the current configuration:
import { getConfigForDebug } from '@zelto/agent-chat-sdk';
console.log(getConfigForDebug());
// { config: { ... }, context: { ... } }