WebSocket Communication
Real-time bidirectional communication with automatic reconnection and exponential backoff for reliability.
TypeScript-first SDK for eGain's AI Agent platform with WebSocket communication, automatic reconnection, and comprehensive message handling.
npm install @egain/ai-agent-sdkimport { 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!");Built for production use with comprehensive logging, error handling, and connection management.
TypeScript-first design with excellent IDE support, autocomplete, and inline documentation.
Extensible message handlers, pluggable cache adapters, and customizable authentication strategies.
Tree-shakable with zero framework dependencies. Use only what you need.