You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive TypeScript SDK for real-time and synchronous communication with the XiansAi Server UserApi, enabling AI-powered workflows and conversations in your applications.
Features
🔄 Real-time Communication: WebSocket-based chat with automatic reconnection
🌐 HTTP REST API: Synchronous messaging and conversation management
📡 Server-Sent Events: Live notifications and status updates
🔐 Multiple Authentication: API Key, JWT Token, or JWT Callback support
📝 TypeScript Support: Full type definitions and IntelliSense
🛡️ Error Handling: Comprehensive error handling and logging
⚡ Async/Await: Modern promise-based API
Quick Start
Installation
npm install @99xio/xians-sdk-typescript
# or
yarn add @99xio/xians-sdk-typescript
Basic Usage
import{SocketSDK,RestSDK,MessageType}from'@99xio/xians-sdk-typescript';// Real-time chat with WebSocketconstsocketSDK=newSocketSDK({tenantId: 'your-tenant-id',apiKey: 'your-api-key',serverUrl: 'https://your-server.com',eventHandlers: {onReceiveChat: (message)=>console.log('Received:',message.text)}});awaitsocketSDK.connect();awaitsocketSDK.subscribeToAgent('workflow-id','user-123');awaitsocketSDK.sendInboundMessage({participantId: 'user-123',workflowType: 'customer-support',text: 'Hello!'},MessageType.Chat);// Synchronous conversation with RESTconstrestSDK=newRestSDK({tenantId: 'your-tenant-id',apiKey: 'your-api-key',serverUrl: 'https://your-server.com'});constresult=awaitrestSDK.converse({participantId: 'user-123',workflow: 'customer-support',type: 'Chat',text: 'What is my order status?',timeoutSeconds: 30});