Skip to content

Twilio and Telnyx, with no server in between.

Twilio and Telnyx can send a copy of the call’s audio straight to Voicemail Detector. When the verdict is in, we post it to your app in the same shape as the platform’s own answering machine detection, so an app that already handles it keeps its code. The call never waits: your agent or voice AI talks from the first second.

  1. 1Add a stream to the call, with your API key and your callback URL.
  2. 2We listen to the callee while the call goes on.
  3. 3Your callback gets human, machine or unknown, signed with your key.

Twilio

Start a Media Stream before the call’s own TwiML, which runs right away. Pass the key and the callback as parameters, since Twilio drops the query string of stream URLs.

TwiML
<Response>
  <Start>
    <Stream url="wss://api.voicemaildetector.com/v1/twilio">
      <Parameter name="key" value="vd_…" />
      <Parameter name="callback" value="https://your-app.com/amd" />
    </Stream>
  </Start>
  <Say>Hi! This is Ana, calling about your appointment.</Say>
</Response>

Make a key just for Twilio in the dashboard, so you can revoke it on its own. The stream carries the callee’s side by default. decision_timeout_ms and watch_ms go as parameters too.

Telnyx

Start streaming when you dial, or later with streaming_start, with the key and the URL-encoded callback in the query of the stream URL. Send the inbound track as PCMU or PCMA at 8 kHz.

terminal
curl https://api.telnyx.com/v2/calls \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "…",
    "to": "+51…",
    "from": "+1…",
    "stream_url": "wss://api.voicemaildetector.com/v1/telnyx?key=vd_…&callback=https%3A%2F%2Fyour-app.com%2Famd",
    "stream_track": "inbound_track",
    "stream_codec": "PCMU"
  }'

The webhook

One POST per verdict to your callback. For Twilio it is a form like its AsyncAmdStatusCallback; for Telnyx, a call.machine.detection.ended event. Both add verdict, stage and at_ms.

Twilio
POST /amd
Content-Type: application/x-www-form-urlencoded
X-VD-Signature: t=1764547200,v1=5f0c…

CallSid=CA1f…&AccountSid=AC9b…&AnsweredBy=machine_start&MachineDetectionDuration=4500&Verdict=machine&Stage=decision&AtMs=4500
Telnyx
{
  "data": {
    "record_type": "event",
    "event_type": "call.machine.detection.ended",
    "occurred_at": "2026-12-01T00:00:04.5Z",
    "payload": {
      "call_control_id": "v3:…",
      "call_session_id": "…",
      "result": "machine",
      "verdict": "machine",
      "stage": "decision",
      "at_ms": 4500
    }
  }
}
  • verdictTwilio AnsweredByTelnyx result
  • humanhumanhuman
  • machinemachine_startmachine
  • unknownunknownnot_sure

When a machine shows up after a human verdict, a second webhook arrives with stage after_human and a machine answer, while watch_ms lasts (30 s by default). Hang up then too.

Check the signature

Every webhook carries X-VD-Signature, an HMAC-SHA256 of its timestamp and raw body with your API key. Check it before acting on the webhook.

amd.js
import {verifyWebhook} from 'voicemaildetector'

// body: the raw request body, before any parsing
if (!verifyWebhook(body, req.headers['x-vd-signature'])) return res.writeHead(401).end()

The platform’s own signature check, X-Twilio-Signature or Telnyx’s, does not apply to these requests. Give the callback its own route that checks ours.

When there is no verdict

A call that cannot be analysed is answered at once with unknown and an Error field (error in the Telnyx payload), so your app carries on: payment_required, too_many_calls, busy, bad_audio, bad_request, or connection when the stream broke before a verdict. A stream with a wrong key gets no webhook at all.

Coming from Twilio AMD

  1. Remove MachineDetection and AsyncAmd from the calls you create.
  2. Add the <Start><Stream> above to the call’s TwiML.
  3. Point callback at the handler you use as AsyncAmdStatusCallback, checking our signature instead of Twilio’s.

AnsweredBy keeps its values, so the rest of the handler stays as it is. To see the price difference, read the comparison.