For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Connect a Channel Manager Voice Receiver

Connect a standalone voice runtime to Channel Manager using signed call events, a compatible audio WebSocket, durable event handling, and call-state reconciliation.

A standalone voice application needs an HTTPS receiver for call events and a wss:// endpoint for audio. Events tell your application which call or participant changed. The audio connection carries speech between your runtime and the call. REST operations create and control the call's participants.

Complete Channel Manager provisioning and authentication first. Obtain a provisioned voice use case, its signing secret, and setup-scoped voice:read voice:call access. Use a controlled phone number and synthetic content for acceptance testing. Your application supplies its own agent, session storage, and audio processing.

Backend REST controls the Channel Manager call. Two-way WebSocket audio connects the voice runtime to the provisioned call, and two-way phone audio connects the recipient.
Handle call events and audio as separate inputs to the same application session.

Configure and Verify the Event Receiver

Have the provisioning owner configure the voice use case's webhook_url to your HTTPS receiver and securely supply the returned webhook_secret. A client with use-case:write can set this through the use-case update operation, supplying the voice channel discriminator as well as the URL.

Supplying webhook_url issues a new secret even when the URL text is unchanged. The response returns that secret once. Omit the URL when changing unrelated configuration. Coordinate receiver updates with the secret handoff: this update has no old-secret overlap. The separate messaging secret-rotation operation applies to messaging use cases.

Verify X-AMIGO-CHANNEL-MANAGER-WEBHOOK-SIGNATURE as a lowercase hexadecimal HMAC-SHA256 over the exact request bytes, with the provisioned secret as the key. Compare in constant time before trusting the JSON. Handle repeated header values and comma-combined signatures. Check use_case_id against your trusted configuration. The request must not select an arbitrary secret or destination.

Persist the accepted event before acknowledging it, then perform agent startup and REST calls asynchronously. In particular, acknowledge call.received before trying to attach audio. A read immediately after a callback can race call-state visibility, so retry the read with bounded backoff before deciding the call is missing.

Route Voice Events

Voice events are JSON objects with event, call_ref, use_case_id, and occurred_at (Unix seconds, potentially fractional). They are separate from the messaging inbound-turn envelope and have no messaging idempotency_key. The public OpenAPI describes the REST controls. It does not include this voice event envelope.

  • call.received includes direction: "inbound", phone_number, peer_number, and caller_participant_ref. Create or resume your application session for call_ref, then attach one agent media participant.

  • conference.started and conference.ended track the call lifecycle. Their participant_ref and role can be null. Reconcile started_at and ended_at through a call read.

  • participant.joined and participant.left identify a leg through participant_ref and role. Update that participant's state without treating one participant leaving as proof the whole call ended.

  • participant.dial_completed carries participant_ref, role, and dial_status: answered, no_answer, busy, or failed. An answered dial is not proof a human answered.

  • participant.amd_result carries participant_ref, role, and answered_by for optional answering-machine classification. Treat it separately from dial completion.

Participant roles are caller, agent, operator, transfer_target, and callee. When requested for a dial participant, answering-machine classification can report human, fax, unknown, machine_start, machine_end_beep, machine_end_silence, or machine_end_other. These are classifications, not identity verification or a guarantee of detection accuracy.

An inbound event has this shape, with synthetic values:

Use durable application state to make each lifecycle action idempotent. Key the session by the trusted use case and call_ref, and participant actions by their participant_ref. Do not create another media participant just because an event arrives again. Preserve terminal state if an older event arrives later, and use call reads to reconcile missing or ambiguous events. Callback arrival order and delivery are not guarantees.

Run a Local Event Receiver

Save the following as voice_receiver.py. It verifies signatures and stores lifecycle events in a local SQLite inbox before returning 202. It does not place calls or start an agent. Use Python 3.11 or later and synthetic events. Load CHANNEL_USE_CASE_ID and CHANNEL_WEBHOOK_SECRET from your test configuration. The secret is separate from the API bearer token.

Run python3 voice_receiver.py. Save the synthetic JSON above as voice-event.json, replacing its use-case ID with your configured test use case. In another shell with the same test secret, run:

The inbox contains one row for that lifecycle event after both accepted requests. Check it with SELECT COUNT(*) FROM events in your SQLite client. Also test a validly signed event for another use case and verify 403.

In production, use your application's HTTPS server, approved durable store, request limits, secret management, and asynchronous worker. The worker consumes the inbox and records completed actions. Persisting a receipt alone does not make an external action exactly once. Keep lifecycle state through restarts and reconcile the call before retrying a participant creation. Apply your retention and access policy to callback content.

Implement the Audio Connection

Adding a media participant connects the provisioned audio stream to your wss:// endpoint. The connection uses JSON events with base64-encoded G.711 mu-law audio at 8 kHz. Your agent adapter must decode and encode that format. A generic model WebSocket or a binary PCM socket is not a compatible endpoint.

  1. Accept the connection and process connected, then start. Retain streamSid and read start.customParameters.

  2. Put your call reference and application connection metadata in the participant's stream_context. These string values arrive as custom parameters. Do not rely on URL query parameters. Channel Manager forwards the values you supply rather than inventing your application's session identity.

  3. Authenticate the stream before processing audio. For example, your application can issue a short-lived, single-use token bound to the call, include it in stream_context, and validate it against its own pending connection record. This is your application's access control. A caller-supplied call reference alone is not authentication.

  4. Decode incoming media.payload values and send generated audio as {"event":"media","streamSid":"<received stream ID>","media":{"payload":"<base64 mu-law audio>"}}. Send raw encoded audio without a WAV header.

  5. To interrupt buffered speech, send {"event":"clear","streamSid":"<received stream ID>"}. A named mark can track playback progress. Account for marks associated with cleared audio rather than treating every mark as proof of audibility.

  6. On stop or disconnect, release the local audio session and reconcile the call through REST. Closing a socket is not evidence that every participant has left.

The one-way participant audio fork is a separate listening connection. It does not replace the agent's two-way media participant. Give each fork its own context and connection authorization.

Accept and Clean Up

Follow the controlled voice walkthrough to create a call, attach your media participant, and dial a test recipient. Verify event signatures, session correlation, two-way speech, interruptions, reconnect handling, no-answer behavior, and explicit teardown. For inbound calls, verify that call.received triggers one asynchronous attachment and that duplicate events do not start another agent.

End the test call and read ended_at. Stop the local receiver with Ctrl-C, revoke temporary credentials, and remove the synthetic inbox according to your test-data policy. A local receiver test validates receipt handling, and the controlled call validates the provisioned audio path.

Last updated

Was this helpful?