Skip to content

@egain/ai-agent-sdkEnterprise AI Agent SDK

TypeScript-first SDK for eGain's AI Agent platform with WebSocket communication, automatic reconnection, and comprehensive message handling.

AI Agent SDK

Quick Start

The example below uses the pre-auth option — your server obtains an access token and passes it to the SDK. To generate one, follow the instructions for Generating An Access Token using PKCE.

Required scopes:

  • core.aiservices.read
  • knowledge.portalmgr.manage
  • core.customermgr.read (required for AI Agent for Customer Self Service only)
bash
npm install @egain/ai-agent-sdk
typescript
import { AiAgent } from "@egain/ai-agent-sdk";

const agent = new AiAgent({
  id: "your-agent-id",
  endpoint: "https://your-endpoint.com",
  auth: { type: "pre-auth", accessToken: "your-access-token" },
  autoConnect: true
});

await agent.initialize();

agent.on("agentMessage", (event) => {
  console.log("Agent:", event.payload.message?.content);
});

await agent.send("Hello, agent!");

Why This SDK?

🏢 Enterprise-Ready

Built for production use with comprehensive logging, error handling, and connection management.

⚡ Developer Experience

TypeScript-first design with excellent IDE support, autocomplete, and inline documentation.

🔧 Flexible Architecture

Extensible message handlers, pluggable cache adapters, and customizable authentication strategies.

📦 Lightweight

Tree-shakable with zero framework dependencies. Use only what you need.

Released under the MIT License.