RingValee
Developers

Voicemail detection API: one WebSocket per call

The RingValee voicemail detection API is deliberately small. For each answered call you open a WebSocket, stream the audio, and read back a single JSON verdict. If you run VICIdial, Asterisk or FreeSWITCH you can skip this page and use the ready-made scripts; it's here for dialers and platforms that connect on their own.

  1. Connectwss://amd.ringvalee.com/ with your key on the handshake
  2. Say helloOptional start message with your call ID
  3. StreamRaw 8 kHz, 16-bit mono audio from the moment of answer
  4. ReadOne JSON verdict, then the server closes

Using a stock dialer? Take the VICIdial setup, the Asterisk EAGI script or the FreeSWITCH Lua script instead.

Connecting

Everyone on RingValee uses one address. Customers of a reseller use their reseller's WebSocket host instead.

endpoint
wss://amd.ringvalee.com/

Put your key in the handshake headers. Either of these works:

headers
Authorization: Bearer amd_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X-API-Key: amd_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

If your client can't set headers, send "api_key" inside the start message; the server waits up to 1 second for it. Keys are created and revoked on the WS keys page of the dashboard. You don't register IP addresses: the key is all you need.

What you send

MessageTypeNotes
{"type": "start", "call_id": "…"}Text, optional, firstcall_id (up to 64 characters) shows in your call logs.
AudioBinaryStarts at answer. Format: mono, 8,000 Hz, signed 16-bit little-endian, the same as Asterisk's "slin". Frame size is up to you; 100 ms (1,600 bytes) works best.
{"type": "close"}Text, optionalSend it if the call hangs up early. The verdict follows immediately, from whatever audio you sent.

Don't stop sending audio until the verdict is in. Once it's sent, the server ignores further audio and hangs up the socket.

What you get back

Exactly one text message:

verdict
{"status": true, "amdstatus": "MACHINE", "amdcause": "SCREENING", "confidence": 0.93, "p_human": 0.03,
 "tone": "", "audio_ms": 2000, "window_ms": 2000, "extended": false, "elapsed_ms": 2021}
amdstatus
One of HUMAN, MACHINE, FALLBACK. You'll never see HUMAN here unless the cause is HUMAN too.
amdcause
The reason: HUMAN, MACHINE, SCREENING, SILENCE, TONE, BUSY, UNKNOWN, or a fallback reason (next section).
confidence
Between 0 and 1. The certainty of whichever check made the call.
p_human
Between 0 and 1. How likely the AI model thinks it is that a person picked up.
tone
Empty unless a tone or a recognised recording settled it. Then it's busy, reorder, sit, fax, ringback or repeat:….
audio_ms · window_ms
How much audio arrived, and the window the verdict used (2000 or 3200).
extended
true means 2 s of audio wasn't conclusive, so the verdict used 3.2 s.
elapsed_ms
Milliseconds between your connection opening and the verdict, by our clock.

Fallback answers

Some calls can't be judged. For those, the reply is immediate and ignores the audio, so your own detection can step in:

fallback
{"status": true, "amdstatus": "FALLBACK", "amdcause": "CPS"}

AUTH The key is missing, isn't one we know, or belongs to a different brand's address.

SUSPENDED That key, or the whole account, has been disabled.

QUOTA This month's free calls are gone, or an invoice is past due.

CONCURRENCY The plan's limit on calls being judged at once is already reached.

CPS Too many new calls started within one second for your plan.

NOSERVER Detection isn't available at the moment. Our scripts report this too when they can't connect at all.

Fallback answers are never billed. Once you've started streaming, treat anything that goes wrong (a timeout, a dropped connection) as MACHINE / UNKNOWN. Only a confirmed person should reach an agent. Plan limits for concurrency and calls per second are on the plans page.

Timing rules

  • The verdict comes once 2.0 s of audio has arrived, or 3.2 s for an unclear call.
  • If the audio pauses for 0.6 s after at least 1 s has arrived, the server decides with what it has.
  • Give your client a 4,500 ms timeout from connect. A shorter one turns slow verdicts into dropped people.

Sample client (Node.js)

Streams a headerless 8 kHz, 16-bit mono file in real time and prints the verdict. Uses the ws package.

detect.mjs
import fs from "node:fs";
import WebSocket from "ws";

const ws = new WebSocket("wss://amd.ringvalee.com/", {
  headers: { Authorization: `Bearer ${process.env.AMD_KEY}` },
});

ws.on("open", async () => {
  ws.send(JSON.stringify({ type: "start", call_id: "lead-1042" }));
  const pcm = fs.readFileSync("answer.raw");          // 8 kHz, mono, s16le, no header
  for (let i = 0; i < pcm.length; i += 1600) {         // 1,600 bytes = 100 ms
    if (ws.readyState !== WebSocket.OPEN) return;      // verdict already in
    ws.send(pcm.subarray(i, i + 1600));
    await new Promise((r) => setTimeout(r, 100));     // real time, like a live call
  }
  if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: "close" }));
});

ws.on("message", (data, isBinary) => {
  if (!isBinary) console.log(JSON.parse(data.toString()));
});

Want to check a key without writing code? Our EAGI client has a test mode: python3 /var/lib/asterisk/agi-bin/ringvalee.agi.py --test wss://amd.ringvalee.com/ amd_live_... streams silence and should print AMDSTATUS=MACHINE AMDCAUSE=SILENCE.

Health checks: send "call_id": "__healthcheck__" and 2 s of silence. It is never billed or recorded, and should come back as SILENCE.

Let your agents talk to people, not greetings

25,000 calls a month free, no card. If anything goes wrong, your dialer quietly falls back to Asterisk AMD() for that call.