#is there a way to dynamically route twilio calls to specific agents?

1 messages · Page 1 of 1 (latest)

tawdry groveBOT
#
AI-generated Answer for jxhnmo

Yes. Use the Register Twilio calls integration to choose the agent at runtime. With this approach, your Twilio webhook hits your server, you run your routing logic (e.g., caller ID, IVR selection, CRM lookup), then call ElevenLabs’ register_call endpoint with the desired agent_id. ElevenLabs returns TwiML that you pass back to Twilio to connect that call to the selected agent. Note: when using register_call, call transfer features aren’t available. (elevenlabs.io)

If you don’t need per-call routing, the native Twilio integration lets you import a Twilio number and assign it to one specific agent for inbound calls (static mapping). (elevenlabs.io)

If you only need per-call personalization (not switching agents), you can keep the native integration and use the Twilio personalization webhook to inject dynamic variables/overrides when the assigned agent answers. (elevenlabs.io)

Sources:
Register Twilio calls | ElevenLabs Documentation
Twilio native integration | ElevenLabs Documentation
Twilio personalization | ElevenLabs Documentation

proper echo
#

I am integrating a Twilio Voice Call with your Conversation AI using the https://api.elevenlabs.io/v1/convai/twilio/register-call endpoint.

I have two agents. One works perfectly, the other hangs up immediately with a WebSocket 1008 error.

The Issue: When I route a call to the Failing Agent, the Twilio Stream connects, but ElevenLabs immediately closes the connection with Code 1008 ("Invalid message received"). When I route the exact same TwiML/Stream to the Working Agent, it works fine.

All configuration (Audio Format: 8kHz ÎĽ-law, TwiML) appears identical. I suspect the Failing Agent might be in a corrupted state or 'Draft' mode regarding its Workflow, as the API seems to return no nodes/edges for it compared to the working one.

What could be the issue and how to resolve?

tawdry groveBOT
#
AI-generated Answer for jxhnmo

Likely causes and the fastest checks (all from our docs)

  • Agent audio format mismatch
    Twilio streams ÎĽ-law at 8 kHz. The agent must be set to ÎĽ-law 8000 for BOTH:

    • Output (Voice → “μ-law 8000 Hz”)
    • Input (Advanced → “μ-law 8000 Hz”)
      If one agent differs, our Twilio WebSocket will reject frames. Verify these settings on the failing agent. (elevenlabs.io)
  • Return the TwiML exactly as provided by register-call
    The register-call endpoint returns TwiML that should be passed directly to Twilio. Altering it (e.g., changing the Stream URL or parameters) can lead to a protocol mismatch. (elevenlabs.io)

  • Required dynamic variables not supplied
    If the failing agent requires dynamic variables, you must pass them via conversation_initiation_client_data in the register-call request; missing required variables will cause the call to fail at start. Check Call History errors like “Missing required dynamic variables …”. (elevenlabs.io)

  • Authentication/allowlist blocking this agent
    If the failing agent has authentication enabled or an allowlist configured, connections from non-allowed origins are rejected. Compare the two agents’ Authentication settings or temporarily disable the allowlist to test. The Call History will show errors such as “Host … is not allowed to connect to this agent.” (elevenlabs.io)

  • Versioning/branch state vs. drafts
    If you are using Agent Versioning, calls route to committed versions (including their workflow). Drafts are per-user and not applied unless retrieved explicitly; ensure the branch you’re targeting has a committed version with the expected workflow, or fetch with include_draft when inspecting the config. There’s no documented “corrupted state,” but mismatched branch/version vs. expectations can explain “no nodes/edges” when you compare agents. (elevenlabs.io)

  • Sanity test the agent outside Twilio
    Open a raw Agents WebSocket session (wss://api.elevenlabs.io/v1/convai/conversation?agent_id=...) and send only conversation_initiation_client_data; if the session closes immediately, the issue is in the agent’s configuration rather than Twilio. (elevenlabs.io)

What I would do in order

  1. On the failing agent, set Output = ÎĽ-law 8000 and Input = ÎĽ-law 8000; save. (elevenlabs.io)
  2. Call register-call again and return its TwiML verbatim. (elevenlabs.io)
  3. If the agent needs variables, include them in conversation_initiation_client_data. (elevenlabs.io)
  4. Check Call History for a precise failure reason (allowlist, limits, missing variables). (help.elevenlabs.io)
  5. If using versioning, confirm the branch has a committed version with the expected workflow (don’t rely on uncommitted drafts when comparing). (elevenlabs.io)
  6. If it still fails, reproduce with the Agents WebSocket to isolate the agent config from Twilio. (elevenlabs.io)
proper echo
#

Can ElevenLabs real-time voice reliably handle a Twilio→Twilio forwarded call? Specifically: if Twilio Number A forwards to Twilio Number B (using TwiML <Dial> or similar), will the forwarded call preserve media and CallSid so that register_call works and I can dynamically choose an agent based on the originating Twilio number? Or is Twilio-internal forwarding unsupported for ElevenLabs media streaming?