Skip to main content
Pre-call initialization lets you dynamically select and configure the agent before a call starts. Works on all transports.

Supported Transports

Setup

Phone numbers (Twilio / WhatsApp)

Bind with routing_target_type: "webhook":

WebRTC

Pass server_url in requestData:

Your Server Receives

Verify the Signature

Each call-init request is HMAC-signed with the number’s server_url_secret (returned when you bind the number). Headers: X-TurnCall-Signature: v1=<hex> and X-TurnCall-Timestamp; the HMAC-SHA256 is computed over "{timestamp}.{raw_body}" — the same scheme as event webhooks.
Reject unverified requests — call-init decides which agent answers a real call.

Response Options

Response Fields

What Happens

1

call.initializing webhook event fires (informational)

2

Template {{variables}} are rendered into the system prompt

3

knowledge_context is prepended to the system prompt

4

metadata is stored on the call record

5

call.started event fires

6

Pipeline starts with the resolved configuration

Returning an inline agent

agent and agent_id are alternatives, not a merge: an inline agent replaces the configuration for that call rather than overriding parts of a stored one. Send the whole config, not a patch. Because an inline agent is not a stored agent, it has no row to point at, and that is visible to you:
Every event for such a call carries agent_id: null, and the call does not appear in per-agent listings. This is the correct answer to “which stored agent ran this call” — null means none of them, not not resolved yet.
Everything else still works. The configuration the call ran with is recorded on the call itself, so post-call analysis, the transcript and the call.ended webhook are unaffected. Correlate such calls through call_id, or through metadata you returned in the call-init response — that is what it is for. Knowledge bases linked to a stored agent do not apply, since the call does not run that agent. An inline agent names its own in knowledge_bases, with the same fields as a link (knowledge_base_id, mode, priority, top_k, similarity_threshold, tool_description):
Each id must be a knowledge base in the phone number’s project. One that is not, or an entry TurnCall cannot read, is skipped with a warning and the call still connects. See Knowledge Base.
For persistent, searchable knowledge, use the Knowledge Base API instead of knowledge_context. Use knowledge_context for per-call dynamic data like CRM records or open tickets.