agrasya-voice-sdk
v1.0.36
Published
A simple, secure SDK for integrated voice AI.
Readme
Agrasya Voice SDK
A simple, secure SDK for integrated voice AI.
Installation
npm install agrasya-voice-sdkUsage
import { AgrasyaVoiceSDK } from "agrasya-voice-sdk";
// Initialize the SDK
const sdk = new AgrasyaVoiceSDK({
apiKey: "your-api-key",
baseUrl: "https://api.agrasya.com",
language: "en",
debug: false,
});
// Start a voice session
await sdk.start();
// Handle events
const events = {
onStatusChange: (status) => console.log("Status:", status),
onMessageReceived: (message) => console.log("Message:", message),
};
const sdkWithEvents = new AgrasyaVoiceSDK({ apiKey: "your-api-key" }, events);Methods
Constructor
constructor(config: AgrasyaSDKConfig, events: AgrasyaEvents = {});Initializes the SDK with the provided configuration and optional event handlers.
start()
async start(): Promise<void>Starts a voice session by establishing a connection with the backend and initializing WebRTC components.
stop()
async stop(): Promise<void>Stops the voice session, closes the WebRTC connection, and cleans up resources.
sendMessage()
sendMessage(message: string): voidSends a message through the data channel.
onStatusChange
onStatusChange(status: "idle" | "initializing" | "connecting" | "connected" | "error"): voidEvent handler for status changes.
onMessageReceived
onMessageReceived(message: string): voidEvent handler for incoming messages.
Development
# Install dependencies
npm install
# Build the SDK
npm run build
# Watch mode for development
npm run dev
# Run tests
npm testPublishing
See PUBLISHING.md for instructions on publishing to npm.
License
MIT
