Skip to main content

Agent Stream WebSocket

Connect call audio you already carry over a WebSocket (a PBX, a telephony platform such as Twilio, Exotel or Klicko, or your own app) to a 60db voice agent. The agent listens, answers in its voice, uses its tools (your Webhook (JSON) tools and Call transfer) and knowledge base, and can press keys, transfer to a person or hang up. No phone line or UDP ports are needed: everything runs over HTTPS, port 443.

🚀 Quick Start

1. Start the call (from your server)

The url is single use and valid for 55 seconds. It carries no API key, so you can hand it to the component that streams audio. See Start stream call for overrides and metadata.

2. Connect and stream (Node.js 22+)

🔌 Connection

🎧 Styles

The style is picked from your first message.

Native style

You get {"event":"started","call_id":"…","format":"mulaw","frame_bytes":160}, then audio as binary messages in both directions.

Twilio Media Streams style

Send your usual Twilio, Exotel or Klicko messages: no adapter, no change to the request.
  • mediaFormat may be nested in start (Twilio) or at the top of it (Klicko).
  • Encodings: audio/x-mulaw, pcmu, mulaw (μ-law) or audio/x-l16, l16, pcm16, pcm16_8k (PCM16). The rate must be 8000.
  • pcma and 16 kHz formats close the socket with 1008.
  • There is no started reply. Audio comes back as {"event":"media","streamSid":"…","streamId":"…","media":{"payload":"…"}}.
  • mark is ignored. Base64 in JSON is about 1.7 times the native bytes.

📨 Messages

From the agent

From you

Tools During a Stream Call

A stream call uses the agent’s tools exactly like a phone call. Add them on the agent (dashboard → agent → Tools & webhooks → Add tool, or tools / transfer_targets in the API).

Webhook (JSON) tools

Your own functions, such as checking availability or booking a table. They do not go over this socket. 60db calls your server directly:
  1. Define the tool on the agent with a JSON Schema, and set the agent’s Tool webhook (tool_webhook_url):
  1. During the call, when the agent uses it, 60db sends a signed POST to your tool_webhook_url with the tool name and arguments (headers X-60db-Signature, X-60db-Timestamp).
  2. Reply with any JSON object within about 6 seconds, e.g. { "booked": true, "table": 12 }. The agent turns it into its spoken answer. A slow or failed reply reaches the agent as {"error": "tool_unavailable", …}, so it can apologise.
The request and reply formats, signature checks and example servers (Node.js, Python) are in Agent Tools and Webhooks. An agent with tools must have a tool_webhook_url, or starting the call returns 400 VALIDATION_ERROR (field: tool_webhook_url).

Call transfer tool

Built in: no webhook needed. Set transfer_targets on the agent (or in overrides for one call). When the caller asks for a person, the agent says a short line and this socket receives:
Put the caller through on your platform, then reply within 10 seconds with {"event":"transfer_result","outcome":"joined"} (or busy, declined, no_answer, failed). See Call transfer.

Keypad

With call_defaults.dtmf: true the agent can press keys ({"event":"dtmf","digits":"1"} arrives on this socket) and collect the caller’s keys (send {"event":"dtmf","digits":"5#"}).

❌ Close Codes

📊 Limits and Pricing

After the call, find it in Agents → History (label Stream), or use Get call, Get transcript and Get recording.