2.3.4 • Published 9 months ago
@callybaseai/vox v2.3.4
Vox
Web SDK for Callybase AI voice agents
Installation
To install Vox, you can use either npm or yarn.
Using npm:
npm install @callybaseai/vox
Using yarn:
yarn add @callybaseai/vox
Usage
Import the package
Begin by importing the CallybaseClient class from the SDK into your JavaScript application:
import { CallybaseClient } from "@callybaseai/vox";
Initialize the client
Create an instance of the CallybaseClient class. This client will be used to manage your AI voice agent interactions.
const client = new CallybaseClient();
Start the call
To initiate a call with a specific AI agent, use the start method. Replace "agentId" with the ID of your agent from your Callybase dashboard
await client.start(<agentId>);
End the call
To end an ongoing call, invoke the stop method:
await client.stop();
Event Listeners
We provide event listeners that you can use to enhance the functionality of your application. Here are some of the key events:
client.on("CALL_INITIATED", () => {
// Triggered when the call is initiated. This event is fired after the start method is called.
});
client.on("CALL_STARTED", () => {
// Triggered when the AI agent is connected to the user.
});
client.on("CALL_ENDED", () => {
// Triggered when the call ends, which may happen due to user action or session timeouts.
});
client.on("LATENCY", (d) => {
// Sent periodically to report the latency of the last user speech processing.
console.log(`Latency is ${d.total}ms`);
});
client.on("ERROR", (d) => {
// Triggered when the server throws a fatal error.
console.log(`Got an error`, e.message);
});