0 live

Installation

Install the VoiceAI SDK from npm. Requires Node.js 20+.

bash
npm install @voice-agent/sdk
# or
yarn add @voice-agent/sdk
# or
bun add @voice-agent/sdk

Quickstart

Create a client with your API key and trigger your first outbound call in seconds.

typescript
import VoiceAI from "@voice-agent/sdk";

const client = new VoiceAI({ apiKey: process.env.VOICEAI_API_KEY });

// Trigger an outbound call
const call = await client.calls.create({
  assistantId: "asst_01",
  to: "+14155552671",
  from: "+18445550100",
  metadata: { orderId: "ORD-12345", customerId: "cust_abc" },
});

console.log("Call started:", call.id);

Note: Your VOICEAI_API_KEY can be found on the API Keys page. Never expose it in client-side code.

REST API

The REST API is available at https://api.go-do.ai/v1. Use it directly or via the SDK.

bash
curl -X POST https://api.go-do.ai/v1/calls \
  -H "Authorization: Bearer vai_prod_k8x2••••••••" \
  -H "Content-Type: application/json" \
  -d '{
    "assistantId": "asst_01",
    "to": "+14155552671",
    "from": "+18445550100"
  }'

Webhooks

Configure a webhook URL in Settings → Integrations. VoiceAI will POST events to your endpoint.

typescript
// POST https://your-server.com/webhooks/voiceai
app.post("/webhooks/voiceai", (req, res) => {
  const event = req.body;

  switch (event.type) {
    case "call.completed":
      console.log("Call ended:", event.data.call.id);
      console.log("Duration:", event.data.call.durationSeconds, "s");
      console.log("Sentiment:", event.data.call.sentiment);
      break;

    case "call.tool_called":
      // event.data.toolName, event.data.args, event.data.callId
      break;

    case "campaign.completed":
      console.log("Campaign done:", event.data.campaign.name);
      break;
  }

  res.json({ received: true });
});

Event Reference

EventDescription
call.startedCall connected and agent session initialized
call.completedCall ended; includes duration, sentiment, outcome
call.failedCall failed to connect or agent session crashed
call.tool_calledAgent invoked a tool mid-call; includes args and result
call.transcript_readyFull transcript available at the given URL
campaign.startedCampaign dialing has begun
campaign.pausedCampaign was paused
campaign.completedAll targets have been processed
assistant.updatedAn assistant's configuration was changed